#include int main() { int a, b; int divisor; int result; scanf("%d%d", &a, &b); result = a; for (divisor = 1000000000; divisor > 0; divisor /= 10) { int digitA = a / divisor % 10; int digitB = b / divisor % 10; int sign; if ((digitA == 4 || digitA == 7) && (digitB == 4 || digitB == 7)) { sign = -1; } else { sign = 1; } if (digitA * sign > digitB * sign) { result = a; break; } else if (digitA * sign < digitB * sign) { result = b; break; } } printf("%d\n", result); return 0; }