#include <bits/stdc++.h>
using namespace std;
long long x, y;
long long A[30], B[30];
int f[30], g[100010];
inline int Calc(long long x) {
  int ans = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) ++ans;
    x /= 10;
  }
  return ans;
}
inline long long Next(long long x) {
  long long xx = x % 10;
  if (xx <= 2) return x + 1;
  if (xx == 3) return x + 2;
  if (xx == 4) return x + 3;
  if (xx == 5) return x + 1;
  if (xx == 6) return x + 2;
  if (xx == 8) return x + 1;
  if (xx == 7) {
    long long a = x / 10, b = 1;
    while (a % 10 == 7) {
      ++b;
      a /= 10;
    }
    xx = a % 10;
    if (xx <= 2 || xx == 5 || xx == 8) return x + A[b] * 6 + 1;
    if (xx == 3 || xx == 6)
      return (b == 1) ? (x + 3) : (x + A[b] * 6 + 1 - B[b - 1] * 4);
    if (xx == 4) return x + B[b] * 2 + A[b] * 6 + 1;
    if (xx == 9) {
      int c = 0;
      while (a % 10 == 9) {
        ++c;
        a /= 10;
      }
      x = x - A[b + c] * 9 + A[b] * 2 + B[b + c];
      xx = a % 10;
      if (xx == 4 || xx == 7)
        ++b;
      else if (xx == 3 || xx == 6)
        --b;
      return x + A[b] * 4;
    }
  }
  if (xx == 9) {
    long long a = x / 10, b = 10;
    while (a % 10 == 9) {
      b *= 10;
      a /= 10;
    }
    xx = a % 10;
    if (xx == 4 || xx == 7)
      return x + 5;
    else if (xx == 3 || xx == 6)
      return x + b + 1;
    else
      return x + 1;
  }
}
long long Solve(long long x, long long y) {
  if (y == 1) return Next(x);
  long long ans = Solve(x / 10, (x + y - 1) / 10 - x / 10 + 1) * 10 + x % 10;
  if (y > 20)
    return ans;
  else {
    for (int i = 1; i <= y; ++i)
      f[i] = g[(x + i - 1) / 100000] + g[(x + i - 1) % 100000];
    for (long long tmp = Next(x); tmp < ans; tmp = Next(tmp)) {
      bool flag = 1;
      for (int i = 1; i <= y; ++i)
        if (g[(tmp + i - 1) / 100000] + g[(tmp + i - 1) % 100000] != f[i]) {
          flag = 0;
          break;
        }
      if (flag) return tmp;
    }
    return ans;
  }
}
int main() {
  for (int i = 1; i <= 99999; ++i) g[i] = Calc(i);
  A[1] = 1;
  B[1] = 10;
  for (int i = 2; i <= 15; ++i) A[i] = A[i - 1] * 10 + 1, B[i] = B[i - 1] * 10;
  scanf("%I64d%I64d", &x, &y);
  printf("%I64d\n", Solve(x, y));
  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 x, y;
long long A[30], B[30];
int f[30], g[100010];
inline int Calc(long long x) {
  int ans = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) ++ans;
    x /= 10;
  }
  return ans;
}
inline long long Next(long long x) {
  long long xx = x % 10;
  if (xx <= 2) return x + 1;
  if (xx == 3) return x + 2;
  if (xx == 4) return x + 3;
  if (xx == 5) return x + 1;
  if (xx == 6) return x + 2;
  if (xx == 8) return x + 1;
  if (xx == 7) {
    long long a = x / 10, b = 1;
    while (a % 10 == 7) {
      ++b;
      a /= 10;
    }
    xx = a % 10;
    if (xx <= 2 || xx == 5 || xx == 8) return x + A[b] * 6 + 1;
    if (xx == 3 || xx == 6)
      return (b == 1) ? (x + 3) : (x + A[b] * 6 + 1 - B[b - 1] * 4);
    if (xx == 4) return x + B[b] * 2 + A[b] * 6 + 1;
    if (xx == 9) {
      int c = 0;
      while (a % 10 == 9) {
        ++c;
        a /= 10;
      }
      x = x - A[b + c] * 9 + A[b] * 2 + B[b + c];
      xx = a % 10;
      if (xx == 4 || xx == 7)
        ++b;
      else if (xx == 3 || xx == 6)
        --b;
      return x + A[b] * 4;
    }
  }
  if (xx == 9) {
    long long a = x / 10, b = 10;
    while (a % 10 == 9) {
      b *= 10;
      a /= 10;
    }
    xx = a % 10;
    if (xx == 4 || xx == 7)
      return x + 5;
    else if (xx == 3 || xx == 6)
      return x + b + 1;
    else
      return x + 1;
  }
}
long long Solve(long long x, long long y) {
  if (y == 1) return Next(x);
  long long ans = Solve(x / 10, (x + y - 1) / 10 - x / 10 + 1) * 10 + x % 10;
  if (y > 20)
    return ans;
  else {
    for (int i = 1; i <= y; ++i)
      f[i] = g[(x + i - 1) / 100000] + g[(x + i - 1) % 100000];
    for (long long tmp = Next(x); tmp < ans; tmp = Next(tmp)) {
      bool flag = 1;
      for (int i = 1; i <= y; ++i)
        if (g[(tmp + i - 1) / 100000] + g[(tmp + i - 1) % 100000] != f[i]) {
          flag = 0;
          break;
        }
      if (flag) return tmp;
    }
    return ans;
  }
}
int main() {
  for (int i = 1; i <= 99999; ++i) g[i] = Calc(i);
  A[1] = 1;
  B[1] = 10;
  for (int i = 2; i <= 15; ++i) A[i] = A[i - 1] * 10 + 1, B[i] = B[i - 1] * 10;
  scanf("%I64d%I64d", &x, &y);
  printf("%I64d\n", Solve(x, y));
  return 0;
}

```