#include <bits/stdc++.h>
using namespace std;
int i, j, k, ax, lx;
int a[100], b[20], c[20];
inline int init(int x) {
  int s = 0;
  for (; x; x /= 10) {
    s += x % 10 == 4 || x % 10 == 7;
  }
  return s;
}
inline int check(int x) {
  int A = x % 10;
  if (A < 3 || A == 5 || A == 8) {
    return x + 1;
  }
  if (A == 3 || A == 6) {
    return x + 2;
  }
  if (A == 4) {
    return x + 3;
  }
  int s = 0;
  for (; x % 10 == 7; x /= 10) {
    s++;
  }
  if (x % 10 == 4) {
    return (x + 3) * b[s] + c[s] * 4;
  }
  int s1 = init(x);
  int y = x + 1;
  if (s1 == init(y)) {
    return y * b[s] + c[s] * 4;
  }
  if (s1 == init(y) + 1) {
    return y * b[s] + c[s + 1] * 4;
  }
  if (s1 == init(y) - 1) {
    if (s) {
      return y * b[s] + c[s - 1] * 4;
    } else {
      for (; y % 10 == 0;) {
        y /= 10;
        s++;
      }
      return (y + 1) * b[s];
    }
  }
}
int dfs(int x, int y) {
  if (y == 1) {
    return check(x);
  }
  int an = dfs(x / 10, (x + y - 1) / 10 - x / 10 + 1) * 10 + x % 10;
  if (y >= 100) {
    return an;
  } else {
    int i, k;
    for (i = 1; i <= y; i++) {
      a[i] = init(x + i - 1);
    }
    for (k = check(x); k < an; k = check(k)) {
      int F = 0;
      for (i = 1; i <= y; i++) {
        if (a[i] != init(k + i - 1)) {
          F = 1;
          break;
        }
      }
      if (!F) {
        return k;
      }
    }
    return an;
  }
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  b[0] = 1;
  for (i = 1; i <= 19; i++) {
    b[i] = b[i - 1] * 10;
  }
  for (i = 1; i <= 19; i++) {
    c[i] = c[i - 1] * 10 + 1;
  }
  ax = read();
  lx = read();
  printf("%d", dfs(ax, lx));
  printf("\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>
using namespace std;
int i, j, k, ax, lx;
int a[100], b[20], c[20];
inline int init(int x) {
  int s = 0;
  for (; x; x /= 10) {
    s += x % 10 == 4 || x % 10 == 7;
  }
  return s;
}
inline int check(int x) {
  int A = x % 10;
  if (A < 3 || A == 5 || A == 8) {
    return x + 1;
  }
  if (A == 3 || A == 6) {
    return x + 2;
  }
  if (A == 4) {
    return x + 3;
  }
  int s = 0;
  for (; x % 10 == 7; x /= 10) {
    s++;
  }
  if (x % 10 == 4) {
    return (x + 3) * b[s] + c[s] * 4;
  }
  int s1 = init(x);
  int y = x + 1;
  if (s1 == init(y)) {
    return y * b[s] + c[s] * 4;
  }
  if (s1 == init(y) + 1) {
    return y * b[s] + c[s + 1] * 4;
  }
  if (s1 == init(y) - 1) {
    if (s) {
      return y * b[s] + c[s - 1] * 4;
    } else {
      for (; y % 10 == 0;) {
        y /= 10;
        s++;
      }
      return (y + 1) * b[s];
    }
  }
}
int dfs(int x, int y) {
  if (y == 1) {
    return check(x);
  }
  int an = dfs(x / 10, (x + y - 1) / 10 - x / 10 + 1) * 10 + x % 10;
  if (y >= 100) {
    return an;
  } else {
    int i, k;
    for (i = 1; i <= y; i++) {
      a[i] = init(x + i - 1);
    }
    for (k = check(x); k < an; k = check(k)) {
      int F = 0;
      for (i = 1; i <= y; i++) {
        if (a[i] != init(k + i - 1)) {
          F = 1;
          break;
        }
      }
      if (!F) {
        return k;
      }
    }
    return an;
  }
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  b[0] = 1;
  for (i = 1; i <= 19; i++) {
    b[i] = b[i - 1] * 10;
  }
  for (i = 1; i <= 19; i++) {
    c[i] = c[i - 1] * 10 + 1;
  }
  ax = read();
  lx = read();
  printf("%d", dfs(ax, lx));
  printf("\n");
  return 0;
}

```