#include #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int main() { map mp; rep(i, 0, 10) mp['0' + i] = i; rep(i, 0, 6) mp['A' + i] = 10 + i; string N; cin >> N; while (N.size() % 3) N = "0" + N; cout << N << endl; vector c(8, 0); rep(i, 0, N.size() / 3) { int x = 0; rep(j, 0, 3) { x *= 16; x += mp[N[i * 3 + j]]; } rep(j, 0, 4) { if (x == 0 && i == 0) break; c[x % 8]++; x /= 8; } } int cmax = 0; rep(i, 0, 8) cmax = max(cmax, c[i]); rep(i, 0, 8) if (c[i] == cmax) cout << i << " "; cout << endl; }