#include using namespace std; string s; long long t; pair a[8]; int main() { cin >> s; for (int i = 0; i < 8; i++) a[i].second = - i; int n = s.size(); for (int i = 0; i < n; i++) { int u = (s[n - 1 - i] - 'A' + 10); if (i % 3 == 1) u *= 2; else if (i % 3 == 2) u *= 4; u += t; a[u % 8].first++; t = u / 8; if (i % 3 == 2) { a[t % 8].first++; t /= 8; } } while (t > 0) { a[t % 8].first++; t /= 8; } sort(a, a + 8, greater>()); int w = a[0].first; for (int i = 0; i < 8; i++) { cout << -a[i].second; if (i < 7 && a[i].first == a[i + 1].first) cout << " "; else { cout << endl; break; } } }