#include int cmp(long long a, long long b) { long long aa=0, bb=0; while (a != 0 || b != 0) { int an = a % 10; int bn = b % 10; if (an == 7 && bn == 4) { aa = aa * 10 + 4; bb = bb * 10 + 7; } else if (an == 4 && bn == 7) { aa = aa * 10 + 7; bb = bb * 10 + 4; } else { if (a != 0) aa = aa * 10 + an; if (b != 0) bb = bb * 10 + bn; } a /= 10; b /= 10; } while (aa != 0 || bb != 0) { if (aa != 0) { a = a * 10 + aa % 10; aa /= 10; } if (bb != 0) { b = b * 10 + bb % 10; bb /= 10; } } return a > b; } int main() { long long a, b; std::cin >> a; std::cin >> b; if (cmp(a, b)) std::cout << a << std::endl; else std::cout << b << std::endl; return 0; }