1 #include <iostream>
2 #include <cstdio>
3 #include <cstdlib>
4 #include <cmath>
5 #include <cctype>
6 #include <cstring>
7 #include <vector>
8 #include <list>
9 #include <deque>
10 #include <stack>
11 #include <queue>
12 #include <algorithm>
13 #include <string>
14 #include <map>
15 #include <set>
16
17
18 using namespace std;
19
20
21 int main()
22 {
23
24
25
26 char s[1000];
27
28 int i,j,k;
29
30
31 while(gets(s))
32 {
33 if(strcmp(s,"E")==0)
34 break;
35
36 int c[3];
37
38 c[0]=c[1]=c[2]=0;
39
40
41 for(i=0;s[i];i++)
42 {
43
44 if(s[i]=='Z')
45 {
46 c[0]++;
47 }
48 else if(s[i]=='O')
49 {
50 c[1]++;
51 }
52 else if(s[i]=='J')
53 {
54 c[2]++;
55 }
56 }
57
58
59
60 while((c[0]>0)&&(c[1]>0)&&(c[2]>0))
61 {
62 cout<<"ZOJ";
63 c[0]--;
64 c[1]--;
65 c[2]--;
66
67 }
68
69
70 while((c[0]>0)&&(c[1]>0))
71 {cout<<"ZO";
72 c[0]--;
73 c[1]--;
74 }
75
76 while((c[0]>0)&&(c[2]>0))
77 {cout<<"ZJ";
78 c[0]--;
79 c[2]--;
80 }
81
82 while((c[1]>0)&&(c[2]>0))
83 {
84 cout<<"OJ";
85 c[1]--;
86 c[2]--;
87 }
88
89 while(c[0]>0)
90 {cout<<"Z";c[0]--;}
91
92 while(c[1]>0)
93 {
94 cout<<"O";
95 c[1]--;
96 }
97
98 while(c[2]>0)
99 {
100 cout<<"J";
101 c[2]--;
102 }
103
104 cout<<endl;
105 }
106
107
108
109
110
111
112
113
114
115
116
117 return 0;
118 }