CF670F.Restore a Number

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Vasya decided to pass a very large integer nn to Kate. First, he wrote that number as a string, then he appended to the right integer kk — the number of digits in nn .

Magically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remembers, is a non-empty substring of nn (a substring of nn is a sequence of consecutive digits of the number nn ).

Vasya knows that there may be more than one way to restore the number nn . Your task is to find the smallest possible initial integer nn . Note that decimal representation of number nn contained no leading zeroes, except the case the integer nn was equal to zero itself (in this case a single digit 0 was used).

输入格式

The first line of the input contains the string received by Kate. The number of digits in this string does not exceed 10000001000000 .

The second line contains the substring of nn which Vasya remembers. This string can contain leading zeroes.

It is guaranteed that the input data is correct, and the answer always exists.

输出格式

Print the smalles integer nn which Vasya could pass to Kate.

输入输出样例

  • 输入#1

    003512
    021
    

    输出#1

    30021
    
  • 输入#2

    199966633300
    63
    

    输出#2

    3036366999
    
首页