#include<bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,m,n) for(int i=m; i<int(n); ++i) #define repll(i,m,n) for(ll i=m; i<ll(n); ++i) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define leng(a) int(a.size()) #define fi first #define se second template<typename T> bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; } template<typename T> bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; } template<typename T> T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; } template<typename T> T lcm(T a, T b){ return a / gcd(a, b) * b; } char comp(char c, char d){ if((c == '4' && d == '7') || (c == '7' && d == '4')){ return c == '4' ? c : d; }else{ return max(c, d); } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string a, b; cin >> a >> b; if(leng(a) != leng(b)){ cout << (leng(a) > leng(b) ? a : b) << endl; }else{ rep(i, 0, leng(a)){ if(a[i] == b[i]) continue; cout << (comp(a[i], b[i]) == a[i] ? a : b) << endl; break; } } return 0; }