import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	s = chomp(s);
	int[10] r;
	for(int i=0;i<s.length;i++){
	    int n = to!int(s[i] - '0');
	    r[n]++;
	}
	string s1 = "";
	for(int i=1;i<=9;i++){
	    for(int j=0;j<r[i];j++)
		s1 ~= to!string(i);
	}
	bool[10] used = false;
	string[] ss = ["111","222","333","444","555","666","777","888","999","123","234","345","456","567","678","789"];
	string[] atm = ["11","22","33","44","55","66","77","88","99"];
	int[] anslist;
	for(int i=0;i<16;i++){
	    for(int j=i;j<16;j++){
		for(int k=j;k<16;k++){
		    for(int l=k;l<16;l++){
			for(int m=0;m<9;m++){
			    string temp = ss[i] ~ ss[j] ~ ss[k] ~ ss[l] ~ atm[m];
			    int[10] r1;
			    for(int i1=0;i1<temp.length;i1++){
				int n = to!int(temp[i1] - '0');
				r1[n]++;
			    }
			    int count = 0;
			    for(int i2=1;i2<=9;i2++){
				if(r1[i2] != r[i2]) count += abs(r1[i2] - r[i2]);
			    }
			    int ans = 0;
			    if(count == 1){
				for(int i2=1;i2<=9;i2++){
				    if(r1[i2] != r[i2] && r1[i2] <= 4) ans = i2;
				}
			    }

			    if(ans!=0 && !used[ans]){
				//writef("%d ",ans);
				used[ans] = true;
				anslist ~= ans;
			    }
			}
		    }
		}
	    }
	}
	sort(anslist);
	if(anslist.length > 0)
	    writef("%d",anslist[0]);
	else writef("%d",0);
	for(int i=1;i<anslist.length;i++)
	    writef(" %d",anslist[i]);
	writeln();
    }
}