#include <bits/stdc++.h>
using namespace std;
int numlucky(int x) {
  int num = 0;
  while (x > 0) {
    if (x % 10 == 4 or x % 10 == 7) num++;
    x /= 10;
  }
  return num;
}
int siguienteiguallucky(int x) {
  int d = x % 10;
  if (d < 3) return x + 1;
  if (d == 3) return x + 2;
  if (d == 4) return x + 3;
  if (d == 5) return x + 1;
  if (d == 6) return x + 2;
  if (d == 8) return x + 1;
  int nx = numlucky(x);
  int xx = x / 10;
  int xx1 = xx + 1;
  int nxx1 = numlucky(xx1);
  if (d == 9) {
    if (nxx1 == nx) return x + 1;
    if (nxx1 == nx + 1) return siguienteiguallucky(xx) * 10;
    return xx1 * 10 + 4;
  }
  if (nxx1 == nx) return x + 3;
  if (nxx1 == nx - 1) return x + 7;
  return siguienteiguallucky(xx) * 10 + 4;
}
int tramaa[50];
bool trama(int a, int l) {
  for (int i = 0; i <= l; i++)
    if (numlucky(a + i) != tramaa[i]) return false;
  return true;
}
int calcula(int a, int l) {
  if (l == 0) return siguienteiguallucky(a);
  int pasos = l / 10;
  if (a % 10 + l % 10 >= 10) pasos++;
  int minimo = calcula(a / 10, pasos) * 10 + a % 10;
  if (l > 20) return minimo;
  for (int i = 0; i <= l; i++) tramaa[i] = numlucky(a + i);
  for (int b = siguienteiguallucky(a); b < minimo; b = siguienteiguallucky(b))
    if (trama(b, l)) return b;
  return minimo;
}
int main() {
  int a, l;
  cin >> a >> l;
  l--;
  cout << calcula(a, l) << endl;
}

### Prompt

Your task is to create 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;
int numlucky(int x) {
  int num = 0;
  while (x > 0) {
    if (x % 10 == 4 or x % 10 == 7) num++;
    x /= 10;
  }
  return num;
}
int siguienteiguallucky(int x) {
  int d = x % 10;
  if (d < 3) return x + 1;
  if (d == 3) return x + 2;
  if (d == 4) return x + 3;
  if (d == 5) return x + 1;
  if (d == 6) return x + 2;
  if (d == 8) return x + 1;
  int nx = numlucky(x);
  int xx = x / 10;
  int xx1 = xx + 1;
  int nxx1 = numlucky(xx1);
  if (d == 9) {
    if (nxx1 == nx) return x + 1;
    if (nxx1 == nx + 1) return siguienteiguallucky(xx) * 10;
    return xx1 * 10 + 4;
  }
  if (nxx1 == nx) return x + 3;
  if (nxx1 == nx - 1) return x + 7;
  return siguienteiguallucky(xx) * 10 + 4;
}
int tramaa[50];
bool trama(int a, int l) {
  for (int i = 0; i <= l; i++)
    if (numlucky(a + i) != tramaa[i]) return false;
  return true;
}
int calcula(int a, int l) {
  if (l == 0) return siguienteiguallucky(a);
  int pasos = l / 10;
  if (a % 10 + l % 10 >= 10) pasos++;
  int minimo = calcula(a / 10, pasos) * 10 + a % 10;
  if (l > 20) return minimo;
  for (int i = 0; i <= l; i++) tramaa[i] = numlucky(a + i);
  for (int b = siguienteiguallucky(a); b < minimo; b = siguienteiguallucky(b))
    if (trama(b, l)) return b;
  return minimo;
}
int main() {
  int a, l;
  cin >> a >> l;
  l--;
  cout << calcula(a, l) << endl;
}

```