#define REP(i,x) for(int i=0;i<(int)(x);i++) unsigned char c, x[11] = "dcdcbcbcda"; main(){ while(scanf("%c", &c))if(isdigit(c)) x[c - '0']--; REP(i, 10) if(x[i]%4 == 3) printf("%d ", i); REP(i, 10) if(x[i]%4 == 1) printf("%d\n", i); return 0; }