#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i, x, n) for(int i = x; i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define EPS 1e-9 #define INF (1L << 30) #define LINF (1LL << 60) using namespace std; typedef long long ll; typedef unsigned long long ull; int calm(string str) { rep(i, str.size()) { if (str[i] == '4') str.replace(i, 1, "7"); else if (str[i] == '7') str.replace(i, 1, "4"); } return stoi(str); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string a, b; cin >> a >> b; if ((a.find("4") != string::npos && b.find("7") != string::npos) || (a.find("7") != string::npos && b.find("4") != string::npos)) cout << (calm(a) <= calm(b) ? b : a) << endl; else cout << max(stoi(a), stoi(b)) << endl; return 0; }