CF146B.Lucky Mask

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya calls a mask of a positive integer nn the number that is obtained after successive writing of all lucky digits of number nn from the left to the right. For example, the mask of number 7217499472174994 is number 77447744 , the mask of 77 is 77 , the mask of 99990479999047 is 4747 . Obviously, mask of any number is always a lucky number.

Petya has two numbers — an arbitrary integer aa and a lucky number bb . Help him find the minimum number cc (c>a) such that the mask of number cc equals bb .

输入格式

The only line contains two integers aa and bb (1<=a,b<=105)(1<=a,b<=10^{5}) . It is guaranteed that number bb is lucky.

输出格式

In the only line print a single number — the number cc that is sought by Petya.

输入输出样例

  • 输入#1

    1 7
    

    输出#1

    7
    
  • 输入#2

    100 47
    

    输出#2

    147
    
首页