#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "< P; char c[5]; int x[3]; int main(){ scanf("%s",c+0); scanf("%s",c+1); scanf("%s",c+2); REP(i,3)x[i]=(c[i]=='?')?-1:(c[i]-'0'); int p = min_element(x,x+3)-x; x[p] = 1; if(min({x[0],x[1],x[2]})==x[1] || max({x[0],x[1],x[2]})==x[1])putchar('1'); x[p] = 4; if(min({x[0],x[1],x[2]})==x[1] || max({x[0],x[1],x[2]})==x[1])putchar('4'); puts(""); return 0; }