#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int main(){ string A, B; cin >> A >> B; if(A.length() > B.length()){ cout << A << endl; } else if(A.length() < B.length()){ cout << B << endl; } else { bool flg = false; rep(i,A.length()){ if(A[i] == B[i]) continue; if(A[i] == '4' && B[i] == '7'){ flg = false; break; } else if(A[i] == '7' && B[i] == '4'){ flg = true; break; } else{ if(A[i] < B[i]){ flg = true; break; } else { flg = false; break; } } } if(flg) cout << B << endl; else cout << A << endl; } return 0; }