#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	string s;
	vector<vector<int> > a, b;
	for(int i=1; i < 10; i++){
		vector<int> v;
		for(int j=0; j< 2; j++) v.push_back(i);
		b.push_back(v);
		v.push_back(i);
		a.push_back(v);
	}
	for(int i=1; i <= 7; i++){
		vector<int> v;
		for(int j=0; j < 3; j++) v.push_back(i+j);
		a.push_back(v);
	}
	while(cin >> s){
		string t = "123456789";

		vector<int> ret;
		rep(q, t.size()){
			int c[10] = {0};
			string r = s + t.substr(q, 1);
			for(int i=0; i < r.size(); i++) c[r[i]-'0']++;
			loop(i, 0, a.size())loop(j, 0, a.size())loop(k, 0, a.size())loop(l, 0, a.size())rep(m, b.size()){
				int d[10] = {0};
				rep(n, 3){d[a[i][n]]++; d[a[j][n]]++; d[a[k][n]]++; d[a[l][n]]++;}
				rep(n, 2)d[b[m][n]]++;
				bool possible = true;
				rep(n, 10) if(c[n] != d[n]) possible = false;
				if(possible) ret.push_back(q+1);
			}
		}
		int n = -1;
		rep(i, ret.size()){
			if(n != ret[i]){cout << (i == 0 ? "" : " ") << ret[i]; n = ret[i];}
		}
		if(n == -1) cout << 0;
		cout << endl;
	}
}