#include <bits/stdc++.h>
int f[11][3][19][4];
int n, k, dig_a[20], aadd;
int typ[10] = {2, 2, 2, 1, 0, 2, 1, 0, 2, 2};
int ten[10] = {1,      10,      100,      1000,      10000,
               100000, 1000000, 10000000, 100000000, 1000000000};
void turn(int i, int j, int p, int q, int d) {
  int v = f[i][j][p][q] + d * ten[i];
  if (i == 9 && d != 0) return;
  i++;
  if (dig_a[i] > d)
    j = 2;
  else if (dig_a[i] < d)
    j = 0;
  p += ((dig_a[i]) == 4 || (dig_a[i]) == 7) - ((d) == 4 || (d) == 7);
  if (q == 3 && d != 9) q = typ[d];
  if (v < f[i][j][p][q]) f[i][j][p][q] = v;
}
char dd[22];
int main() {
  int i, j, p, q, r, d, len, ldd = 0, var = 0, _n, x, y, pp,
                             ans = 0x3f3f3f3f << 1;
  scanf("%d %d", &n, &k);
  while (k >= 10) {
    r = dd[ldd++] = n % 10 + 48;
    k = (n + k - 1) / 10;
    n /= 10;
    r -= 48;
    k -= n - 1;
  }
  dd[ldd] = 0;
  memset(dig_a, 0, sizeof dig_a);
  for (len = 0, _n = n; _n; _n /= 10) dig_a[len++] = _n % 10;
  if (len == 0) len = 1;
  for (pp = 0, _n = (n / 10); _n; _n /= 10)
    pp -= ((_n % 10) == 4 || (_n % 10) == 7);
  for (_n = (n / 10) + 1; _n; _n /= 10)
    pp += ((_n % 10) == 4 || (_n % 10) == 7);
  memset(f, 0x3f, sizeof f);
  f[0][1][9][3] = 0;
  for (i = 0; i < len; i++)
    for (j = 0; j < 3; j++)
      for (p = 0; p <= 18; p++)
        for (q = 0; q < 4; q++)
          if (f[i][j][p][q] < 0x3f3f3f3f)
            for (d = 0; d < 10; d++) turn(i, j, p, q, d);
  for (x = n % 10, y = 0; y < 10; y++)
    for (j = 0; j < 2; j++)
      if (j == 0 || y > x) {
        p = 9 + ((y) == 4 || (y) == 7) - ((x) == 4 || (x) == 7);
        for (q = 0; q < 4; q++)
          if (f[len][j][p][q] <= 200000000 && f[len][j][p][q] * 10 + y < ans) {
            for (i = 0; i < k; i++) {
              d = p - 9;
              if (x + i > 9) d += pp;
              if (y + i > 9) d -= (q == 0 ? -1 : (q == 1));
              d += (((x + i) % 10) == 4 || ((x + i) % 10) == 7) -
                   (((y + i) % 10) == 4 || ((y + i) % 10) == 7);
              if (d) break;
            }
            if (i == k) ans = f[len][j][p][q] * 10 + y;
          }
      }
  printf("%d", ans);
  for (; ldd; ldd--) putchar(dd[ldd - 1]);
  putchar('\n');
  return 0;
}

### Prompt

In Cpp, your task is to solve 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>
int f[11][3][19][4];
int n, k, dig_a[20], aadd;
int typ[10] = {2, 2, 2, 1, 0, 2, 1, 0, 2, 2};
int ten[10] = {1,      10,      100,      1000,      10000,
               100000, 1000000, 10000000, 100000000, 1000000000};
void turn(int i, int j, int p, int q, int d) {
  int v = f[i][j][p][q] + d * ten[i];
  if (i == 9 && d != 0) return;
  i++;
  if (dig_a[i] > d)
    j = 2;
  else if (dig_a[i] < d)
    j = 0;
  p += ((dig_a[i]) == 4 || (dig_a[i]) == 7) - ((d) == 4 || (d) == 7);
  if (q == 3 && d != 9) q = typ[d];
  if (v < f[i][j][p][q]) f[i][j][p][q] = v;
}
char dd[22];
int main() {
  int i, j, p, q, r, d, len, ldd = 0, var = 0, _n, x, y, pp,
                             ans = 0x3f3f3f3f << 1;
  scanf("%d %d", &n, &k);
  while (k >= 10) {
    r = dd[ldd++] = n % 10 + 48;
    k = (n + k - 1) / 10;
    n /= 10;
    r -= 48;
    k -= n - 1;
  }
  dd[ldd] = 0;
  memset(dig_a, 0, sizeof dig_a);
  for (len = 0, _n = n; _n; _n /= 10) dig_a[len++] = _n % 10;
  if (len == 0) len = 1;
  for (pp = 0, _n = (n / 10); _n; _n /= 10)
    pp -= ((_n % 10) == 4 || (_n % 10) == 7);
  for (_n = (n / 10) + 1; _n; _n /= 10)
    pp += ((_n % 10) == 4 || (_n % 10) == 7);
  memset(f, 0x3f, sizeof f);
  f[0][1][9][3] = 0;
  for (i = 0; i < len; i++)
    for (j = 0; j < 3; j++)
      for (p = 0; p <= 18; p++)
        for (q = 0; q < 4; q++)
          if (f[i][j][p][q] < 0x3f3f3f3f)
            for (d = 0; d < 10; d++) turn(i, j, p, q, d);
  for (x = n % 10, y = 0; y < 10; y++)
    for (j = 0; j < 2; j++)
      if (j == 0 || y > x) {
        p = 9 + ((y) == 4 || (y) == 7) - ((x) == 4 || (x) == 7);
        for (q = 0; q < 4; q++)
          if (f[len][j][p][q] <= 200000000 && f[len][j][p][q] * 10 + y < ans) {
            for (i = 0; i < k; i++) {
              d = p - 9;
              if (x + i > 9) d += pp;
              if (y + i > 9) d -= (q == 0 ? -1 : (q == 1));
              d += (((x + i) % 10) == 4 || ((x + i) % 10) == 7) -
                   (((y + i) % 10) == 4 || ((y + i) % 10) == 7);
              if (d) break;
            }
            if (i == k) ans = f[len][j][p][q] * 10 + y;
          }
      }
  printf("%d", ans);
  for (; ldd; ldd--) putchar(dd[ldd - 1]);
  putchar('\n');
  return 0;
}

```