#include using namespace std; using ll = long long; using P = pair; using T = tuple; #define al(a) a.begin(), a.end() #define ral(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define db(a, b) cout << #a << ": " << a << " " << #b << ": " << b << endl; int main() { string s, t; cin >> s >> t; if (sz(s) > sz(t)) cout << s << endl; else if (sz(s) < sz(t)) cout << t << endl; else { int n = sz(s); string ns = s, nt = t; rep(i, n) { if (s[i] == '4' && t[i] == '7') swap(ns[i], nt[i]); if (s[i] == '7' && t[i] == '4') swap(ns[i], nt[i]); } if (ns > nt) cout << s << endl; else cout << t << endl; } return 0; }