#include using namespace std; typedef long long ll; #define int long long signed main() { int A, B; cin >> A >> B; int cA = A, cB = B; for (int w = 1; w < 1e10; w *= 10) { int a = A / w % 10, b = B / w % 10; int plusA = 0, plusB = 0; if (a == 4 && b == 7) plusA = 3, plusB = -3; if (a == 7 && b == 4) plusA = -3, plusB = 3; cA += w * plusA; cB += w * plusB; } printf("%lld\n", (cA > cB) ? A : B); return 0; }