#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { string s, t; cin >> s >> t; int n = s.size(); int m = t.size(); if(n > m){ cout << s << endl; }else if(n < m){ cout << t << endl; }else{ int i = 0; while(s[i] == t[i])i++; if(s[i] == '4' && t[i] == '7'){ cout << s << endl; }else if(s[i] == '7' && t[i] == '4'){ cout << t << endl; }else if(s[i] > t[i]){ cout << s << endl; }else{ cout << t << endl; } } return 0; }