#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;

int main(){
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	int N = S.size();
	int r = (3 - N % 3) % 3;
	rep(i,r) S += '0';
	N = S.size();
	vector<int> cnt(8);
	for(int i = 0; i < N; i += 3){
		string T = S.substr(i, 3);
		int res = 0;
		rep(j,3){
			if(T[j] == '0') break;
			int base = 1;
			rep(k,j) base *= 16;
			res += base * (T[j] - 'A' + 10);
		}
		for(int j = 3; j >= 0; j--){
			int base = 1;
			rep(k,j) base *= 8;
			int q = res / base;
			if(i < N - 3 or q > 0) cnt[q]++;
			res -= base * q;
		}
	}
	int val = 0;
	rep(i,8) val = max(val, cnt[i]);
	vector<int> ans;
	rep(i,8) if(cnt[i] == val) ans.emplace_back(i);
	int siz = ans.size();
	rep(i,siz-1) cout << ans[i] << " ";
	cout << ans[siz-1] << endl;

	return 0;
}