#include <bits/stdc++.h>
using namespace std;
inline int f(long long x) {
  int res = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) ++res;
    x /= 10;
  }
  return res;
}
inline int get_lg(long long x) {
  int res = 0;
  while (x) ++res, x /= 10;
  return res;
}
inline long long get_nxt(long long x) {
  long long pw10 = 1, t = x;
  while (t % 10 == 7) x -= pw10 * 3, t /= 10, pw10 *= 10;
  if (t % 10 == 9) {
    long long save = pw10;
    while (t % 10 == 9) x -= pw10 * 9, t /= 10, pw10 *= 10;
    if (t % 10 == 4 || t % 10 == 7) return x + pw10 + save * 4;
    if (t % 10 == 3 || t % 10 == 6)
      return save > 1 ? x + pw10 - (save / 10) * 4 : x + pw10 * 2;
    return x + pw10;
  }
  if (t % 10 == 4) return x + pw10 * 3;
  if (t % 10 == 3 || t % 10 == 6)
    return pw10 > 1 ? x + pw10 - (pw10 / 10) * 4 : x + pw10 * 2;
  return x + pw10;
}
inline long long get_nxtb(long long x) {
  long long y = x + 1;
  while (f(y) != f(x)) ++y;
  return y;
}
inline long long get_res(long long x, int d) {
  if (d == 1) return get_nxt(x);
  int mn = 1;
  for (int k = 1; k <= d; ++k)
    if (f(x + k - 1) < f(x + mn - 1)) mn = k;
  long long y = x + mn - 1;
  while (1) {
    y = get_nxt(y);
    bool ok = 1;
    for (int k = 1; k <= d; ++k)
      if (f(x + k - 1) != f(y - mn + k)) {
        ok = 0;
        break;
      }
    if (ok) return y - mn + 1;
  }
}
int main(void) {
  long long a, l;
  scanf("%lld%lld", &a, &l);
  int same = get_lg(l) - 1;
  long long x = a;
  long long rem = 0, pw10 = 1;
  for (int k = 1; k <= same; ++k) {
    rem += pw10 * (x % 10);
    x /= 10;
    pw10 *= 10;
  }
  long long d = l - 1;
  d -= pw10 - 1 - a % pw10;
  d = d / pw10 + (d % pw10 ? 1 : 0) + 1;
  printf("%lld", get_res(x, d) * pw10 + rem);
  return 0;
}

### Prompt

Please formulate a CPP solution to the following problem:

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;
inline int f(long long x) {
  int res = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) ++res;
    x /= 10;
  }
  return res;
}
inline int get_lg(long long x) {
  int res = 0;
  while (x) ++res, x /= 10;
  return res;
}
inline long long get_nxt(long long x) {
  long long pw10 = 1, t = x;
  while (t % 10 == 7) x -= pw10 * 3, t /= 10, pw10 *= 10;
  if (t % 10 == 9) {
    long long save = pw10;
    while (t % 10 == 9) x -= pw10 * 9, t /= 10, pw10 *= 10;
    if (t % 10 == 4 || t % 10 == 7) return x + pw10 + save * 4;
    if (t % 10 == 3 || t % 10 == 6)
      return save > 1 ? x + pw10 - (save / 10) * 4 : x + pw10 * 2;
    return x + pw10;
  }
  if (t % 10 == 4) return x + pw10 * 3;
  if (t % 10 == 3 || t % 10 == 6)
    return pw10 > 1 ? x + pw10 - (pw10 / 10) * 4 : x + pw10 * 2;
  return x + pw10;
}
inline long long get_nxtb(long long x) {
  long long y = x + 1;
  while (f(y) != f(x)) ++y;
  return y;
}
inline long long get_res(long long x, int d) {
  if (d == 1) return get_nxt(x);
  int mn = 1;
  for (int k = 1; k <= d; ++k)
    if (f(x + k - 1) < f(x + mn - 1)) mn = k;
  long long y = x + mn - 1;
  while (1) {
    y = get_nxt(y);
    bool ok = 1;
    for (int k = 1; k <= d; ++k)
      if (f(x + k - 1) != f(y - mn + k)) {
        ok = 0;
        break;
      }
    if (ok) return y - mn + 1;
  }
}
int main(void) {
  long long a, l;
  scanf("%lld%lld", &a, &l);
  int same = get_lg(l) - 1;
  long long x = a;
  long long rem = 0, pw10 = 1;
  for (int k = 1; k <= same; ++k) {
    rem += pw10 * (x % 10);
    x /= 10;
    pw10 *= 10;
  }
  long long d = l - 1;
  d -= pw10 - 1 - a % pw10;
  d = d / pw10 + (d % pw10 ? 1 : 0) + 1;
  printf("%lld", get_res(x, d) * pw10 + rem);
  return 0;
}

```