#include #include #include #include #include using namespace std; #define INF 2000000007 #define MOD 1000003 #define MAX 105 #define REP(i,n) for(int i=0;i<(n);++i) #define REPS(i,s,t) for(int i=(s);i<(t);++i) typedef unsigned int uint; typedef unsigned long long int ull; int main(){ string a; cin >> a; string b; cin >> b; if(a.size()==b.size()){ int i=0; for(i=0;a[i]==b[i];++i) ; if(a[i] > b[i]){ cout << ((a[i]=='7'&&b[i]=='4') ? b : a) << endl; } else{ cout << ((a[i]=='4'&&b[i]=='7') ? a : b) << endl; } } else{ cout << ((a.size() > b.size()) ? a : b) << endl; } return 0; }