#include using namespace std; bool great(int x,int y){ if(x == 4 && y == 7) return false; if(y == 4 && x == 7) return true; else return x < y; } int main(){ int A,B,A_,B_; bool ans; int numA[10] = {}; int numB[10] = {}; cin >> A >> B; A_ = A; B_ = B; for(int i=9;i>=0;i--){ numA[i] = A%10; A /= 10; numB[i] = B%10; B /= 10; } for(int i=0;i<10;i++){ if(numA[i] == numB[i]) continue; else if(great(numA[i],numB[i])){ ans = true; } else ans = false; break; } if(ans) cout << B_ << endl; else cout << A_ << endl; return 0; }