#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define D long long #define U unsigned #define F(i,a) for(i=0;i=0;i--) #define bdF(i,a) for(i=a;i>=1;i--) #define LOCAL D i=0,j=0,k=0,t=0,u=0 #define SIZE 1 using namespace std; D n, m, a, b, d, e; char c; bool g, h; string s; D ans; D p[SIZE]; int main() { LOCAL; cin >> a >> b; d = a; e = b; for (i = 1000000000; i > 0; i /= 10) { if ((a/i) % 10 == 4 && (b/i) % 10 == 7){ a += i * 3; b -= i * 3; } if ((a / i) % 10 == 7 && (b / i) % 10 == 4) { a -= i * 3; b += i * 3; } } if (a > b) cout << d << endl; else cout << e << endl; }