#include <bits/stdc++.h>
using namespace std;
const int N = 12;
int calc(long long x) {
  int ans = 0;
  for (; x; x /= 10) ans += (x % 10 == 4 || x % 10 == 7);
  return ans;
}
void Mn(long long &x, long long y) { (x == -1 || x > y) ? x = y : 0; }
long long n, k, P[N];
long long f[N][N][2], a[N];
int ans[N];
long long get(long long x, int d) {
  memset(f, -1, sizeof(f));
  int t = calc(x) + d;
  memset(a, 0, sizeof(a));
  int cnt = 0;
  for (; x; x /= 10) a[cnt++] = x % 10;
  f[N - 1][0][0] = 0;
  for (int i = (int)(N - 2); i >= (int)(0); i--)
    for (int j = (int)(0); j <= (int)(t); j++)
      for (int k = (int)(0); k <= (int)(1); k++) {
        long long val = f[i + 1][j][k];
        if (val == -1) continue;
        for (int s = (int)(k ? 0 : a[i]); s <= (int)(9); s++) {
          int y = j + (s == 4 || s == 7);
          if (y <= t) Mn(f[i][y][k || (s > a[i])], val + s * P[i]);
        }
      }
  return f[0][t][1];
}
int main() {
  for (int i = (int)(P[0] = 1); i <= (int)(N - 1); i++) P[i] = P[i - 1] * 10;
  scanf("%lld%lld", &n, &k);
  long long m = n + k - 1, t = 0, b = 0;
  for (; k >= 10; ++b) t += n % 10 * P[b], n /= 10, m /= 10, k /= 10;
  for (int i = (int)(0); i <= (int)(m - n); i++) ans[i] = calc(n + i);
  int times = 0;
  for (long long i = get(n, 0);;) {
    bool fl = 0;
    for (int j = (int)(0); j <= (int)(m - n); j++) {
      int x = calc(i + j);
      if (x != ans[j]) {
        i = get(i + j, ans[j] - x) - j;
        fl = 1;
        break;
      }
    }
    if (!fl) {
      printf("%lld\n", i * P[b] + t);
      break;
    }
  }
}

### Prompt

Your challenge is to write 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;
const int N = 12;
int calc(long long x) {
  int ans = 0;
  for (; x; x /= 10) ans += (x % 10 == 4 || x % 10 == 7);
  return ans;
}
void Mn(long long &x, long long y) { (x == -1 || x > y) ? x = y : 0; }
long long n, k, P[N];
long long f[N][N][2], a[N];
int ans[N];
long long get(long long x, int d) {
  memset(f, -1, sizeof(f));
  int t = calc(x) + d;
  memset(a, 0, sizeof(a));
  int cnt = 0;
  for (; x; x /= 10) a[cnt++] = x % 10;
  f[N - 1][0][0] = 0;
  for (int i = (int)(N - 2); i >= (int)(0); i--)
    for (int j = (int)(0); j <= (int)(t); j++)
      for (int k = (int)(0); k <= (int)(1); k++) {
        long long val = f[i + 1][j][k];
        if (val == -1) continue;
        for (int s = (int)(k ? 0 : a[i]); s <= (int)(9); s++) {
          int y = j + (s == 4 || s == 7);
          if (y <= t) Mn(f[i][y][k || (s > a[i])], val + s * P[i]);
        }
      }
  return f[0][t][1];
}
int main() {
  for (int i = (int)(P[0] = 1); i <= (int)(N - 1); i++) P[i] = P[i - 1] * 10;
  scanf("%lld%lld", &n, &k);
  long long m = n + k - 1, t = 0, b = 0;
  for (; k >= 10; ++b) t += n % 10 * P[b], n /= 10, m /= 10, k /= 10;
  for (int i = (int)(0); i <= (int)(m - n); i++) ans[i] = calc(n + i);
  int times = 0;
  for (long long i = get(n, 0);;) {
    bool fl = 0;
    for (int j = (int)(0); j <= (int)(m - n); j++) {
      int x = calc(i + j);
      if (x != ans[j]) {
        i = get(i + j, ans[j] - x) - j;
        fl = 1;
        break;
      }
    }
    if (!fl) {
      printf("%lld\n", i * P[b] + t);
      break;
    }
  }
}

```