#include int main(void){ int a,b,ad,bd,k=1000000000; scanf("%d%d",&a,&b); while(1){ ad = (a/k)%10; bd = (b/k)%10; if(ad == 4 && bd == 7){printf("%d\n",a);return 0;} if(ad == 7 && bd == 4){printf("%d\n",b);return 0;} if(ad > bd){printf("%d\n",a);return 0;} if(ad < bd){printf("%d\n",b);return 0;} k/=10; } return 0; }