#include #define rep(i,n) for(int i=0;i ; const ll INF = 1e10; const int MOD = 1000000007; int main(){ string A,B; cin >> A >> B; if(A.size() > B.size()){ cout << A << endl; }else if(A.size() < B.size()){ cout << B << endl; }else{ int n = A.size(); rep(i,n){ if(A[i]==B[i]) continue; if(A[i]=='4' && B[i] == '7'){ cout << A << endl; }else if(A[i] =='7' && B[i] == '4'){ cout << B << endl; }else if(A[i] < B[i]){ cout << B << endl; }else{ cout << A << endl; } break; } } return 0; }