#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; int main(){ string a, b; cin >> a >> b; if (sz(a) != sz(b)) { cout << (sz(a) > sz(b) ? a : b) << endl; } else { rep(i,sz(a)) { int c1 = a[i] - '0', c2 = b[i] - '0'; if (c1 == c2) continue; if (c1 == 4 && c2 == 7) { cout << a << endl; return 0; } else if (c1 == 7 && c2 == 4) { cout << b << endl; return 0; } else { cout << (c1 > c2 ? a : b) << endl; return 0; } } } return 0; }