#include <bits/stdc++.h>
using namespace std;
long long a, l;
long long bigger(long long num) {
  long long ins = 0, rep = 0, now = 0, idx = 1;
  for (;; idx *= 10) {
    now = num / idx % 10;
    if (now == 9) {
      ins++;
      continue;
    }
    if (ins == 0 && now == 4 || ins <= 1 && now == 7) {
      rep *= 10, rep += 4;
      continue;
    }
    if (ins == 1 && now == 4) {
      num = num - num % idx + 3 * idx + rep * 10 + 4;
      break;
    }
    if (now == 4 || now == 7) {
      num = num - num % idx + idx + rep * 100 + 44;
      break;
    }
    if (ins) {
      num =
          num - num % idx + idx + ((now == 3 || now == 6) ? rep : rep * 10 + 4);
      break;
    }
    if (now < 4) {
      num = num - num % idx + (4 - now) * idx + rep;
      break;
    }
    if (now < 7) {
      num = num - num % idx + (7 - now) * idx + rep;
      break;
    }
    ins++;
  }
  return num;
}
long long smaller(long long num) {
  long long idx = 1;
  for (; num; idx *= 10)
    if (num / idx % 10 == 4 || num / idx % 10 == 7) break;
  return num + idx - num % idx;
}
int digit(long long num) {
  int ret = 0;
  for (; num; num /= 10)
    if (num % 10 == 4 || num % 10 == 7) ret++;
  return ret;
}
int main() {
  cin >> a >> l;
  long long idx = 1, rep = 0, rt = a + l - 1;
  for (; l >= 10; l /= 10, a /= 10, idx *= 10, rt /= 10) rep += idx * (a % 10);
  long long st = a + 1;
  for (;;) {
    bool done = 1;
    for (long long i = 0; a + i <= rt; ++i) {
      long long x = digit(st + i), y = digit(a + i), z;
      if (x > y) {
        for (z = st + i; x != y; x--) z = smaller(z);
        st = z - i;
        done = 0;
        break;
      }
      if (y > x) {
        for (z = st + i; x != y; y--) z = bigger(z);
        st = z - i;
        done = 0;
        break;
      }
    }
    if (done) break;
  }
  cout << st * idx + rep << endl;
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a, l;
long long bigger(long long num) {
  long long ins = 0, rep = 0, now = 0, idx = 1;
  for (;; idx *= 10) {
    now = num / idx % 10;
    if (now == 9) {
      ins++;
      continue;
    }
    if (ins == 0 && now == 4 || ins <= 1 && now == 7) {
      rep *= 10, rep += 4;
      continue;
    }
    if (ins == 1 && now == 4) {
      num = num - num % idx + 3 * idx + rep * 10 + 4;
      break;
    }
    if (now == 4 || now == 7) {
      num = num - num % idx + idx + rep * 100 + 44;
      break;
    }
    if (ins) {
      num =
          num - num % idx + idx + ((now == 3 || now == 6) ? rep : rep * 10 + 4);
      break;
    }
    if (now < 4) {
      num = num - num % idx + (4 - now) * idx + rep;
      break;
    }
    if (now < 7) {
      num = num - num % idx + (7 - now) * idx + rep;
      break;
    }
    ins++;
  }
  return num;
}
long long smaller(long long num) {
  long long idx = 1;
  for (; num; idx *= 10)
    if (num / idx % 10 == 4 || num / idx % 10 == 7) break;
  return num + idx - num % idx;
}
int digit(long long num) {
  int ret = 0;
  for (; num; num /= 10)
    if (num % 10 == 4 || num % 10 == 7) ret++;
  return ret;
}
int main() {
  cin >> a >> l;
  long long idx = 1, rep = 0, rt = a + l - 1;
  for (; l >= 10; l /= 10, a /= 10, idx *= 10, rt /= 10) rep += idx * (a % 10);
  long long st = a + 1;
  for (;;) {
    bool done = 1;
    for (long long i = 0; a + i <= rt; ++i) {
      long long x = digit(st + i), y = digit(a + i), z;
      if (x > y) {
        for (z = st + i; x != y; x--) z = smaller(z);
        st = z - i;
        done = 0;
        break;
      }
      if (y > x) {
        for (z = st + i; x != y; y--) z = bigger(z);
        st = z - i;
        done = 0;
        break;
      }
    }
    if (done) break;
  }
  cout << st * idx + rep << endl;
  return 0;
}

```