Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

One day Petya came across an interval of numbers [a, a + l - 1]. Let F(x) be the number of lucky digits of number x. Find the minimum b (a < b) such, that F(a) = F(b), F(a + 1) = F(b + 1), ..., F(a + l - 1) = F(b + l - 1).

Input

The single line contains two integers a and l (1 ≤ a, l ≤ 109) — the interval's first number and the interval's length correspondingly.

Output

On the single line print number b — the answer to the problem.

Examples

Input

7 4


Output

17


Input

4 7


Output

14

Note

Consider that [a, b] denotes an interval of integers; this interval includes the boundaries. That is, <image>

import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main {
    public static void main(String[]args){
    new Main().run();
    }
    void run(){
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong(),l=sc.nextLong()-1;
    long res=func(a,l);
    System.out.println(res);
    }
    private long func(long a,long l){// [a,a+l]
    if(l>20){
        return a%10 + func(a/10,l/10 + (a%10+l%10)/10)*10;
    }
    int[] cnt=new int[(int)(l+1)];
    for (int i = 0; i<l+1; i++){
        cnt[i]=lucky(a+i);
    }
    return func2(a+1,cnt);
    }
    private int lucky(long l) {
    int res=0;
    while(l>0){
        if(l%10==4||l%10==7)res++;
        l/=10;
    }
    return res;
    }
    long INF=1L<<58;
    class E{
    long min;
    int[] cnt;
    E(long min,int[] cnt){
        this.min=min;
        this.cnt=cnt;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj==null) return false;
        if (getClass()!=obj.getClass()) return false;
        final E other = (E) obj;
        if (this.min!=other.min) return false;
        if (!Arrays.equals(this.cnt, other.cnt)) return false;
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67*hash+(int) (this.min^(this.min>>>32));
        hash = 67*hash+Arrays.hashCode(this.cnt);
        return hash;
    }

    }
    HashSet<E> set=new HashSet<E>();
    private long func2(long min, int[] cnt) {
    if(cnt.length==1){
        return func3(min,cnt[0]);
    }
    E key = new E(min,cnt);
    if(set.contains(key))return INF;
    set.add(key);
    long res=INF;
    loop:for (int o = 0; o<10; o++) {
        int i=(int)((min+o)%10);
        int len = (i+cnt.length-1)/10 + 1;
        int[] ncnt=new int[len];
        fill(ncnt,-1);
        len=0;
        for (int j = 0; j<cnt.length; j++) {
        int tmp = cnt[j] - lucky((i+j)%10);
        if(tmp<0 || ncnt[len]!=-1 && ncnt[len]!=tmp)continue loop;
        ncnt[len]=tmp;
        if((i+j)%10==9)len++;
        }
        long tmp2=func2(min/10 + (i<min%10 ? 1:0), ncnt);
        res=min(tmp2*10+i,res);
    }
    return res;
    }

    private long func3(long min, int cnt) {
    long p10=1;
    int dig=1;
    while(p10<min || dig<cnt){
        p10*=10;
        dig++;
    }
    long res=0;
    while(dig>0){
        for (int i = 0;; i++) {
        long tmp = res + p10 * i;
        if(possible(tmp,min,p10/10,dig-1,cnt)){
            res=tmp;break;
        }
        if(i==9)throw new RuntimeException();
        }
        p10/=10;
        dig--;
    }
    return res;
    }

    private boolean possible(long tmp, long min,long p10, int dig, int cnt) {
    if(lucky(tmp) > cnt)return false;
    cnt -= lucky(tmp);
    if(cnt>dig)return false;
    while(cnt<dig){
        tmp += p10*9;
        dig--;
        p10/=10;
    }
    while(dig>0){
        tmp += p10*7;
        dig--;
        p10/=10;
    }
    return tmp>=min;
    }
}
