#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;

bool ok(string s){
	return (s[0] == s[1]+1 && s[1] == s[2]+1) || (s[0] == s[1] && s[1] == s[2]);
}

int main(){
	string s;
	while(cin >> s){
		vector<int> v;
		string t = "123456789";
		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);
		}

		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']++;
			rep(i, a.size())rep(j, a.size())rep(k, a.size())rep(l, 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;
	}
}