#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int x, n;
signed long long p10[22];
int a0[22];
int a[22];
int b[22];
int c1[22];
int c2[22];
int f(int x) {
  int ans = 0;
  while (x) {
    ans += x % 10 == 4 || x % 10 == 7;
    x /= 10;
  }
  return ans;
}
bool check(signed long long xn) {
  signed long long z = xn;
  memset((a), 0, sizeof(a));
  int l = 0;
  while (z) {
    a[l++] = z % 10;
    z /= 10;
  }
  int xx = n;
  for (int i = 0; i < (int)(10); i++) {
    if (a[i] == a0[i]) continue;
    if (n >= p10[i + 1]) return false;
    memcpy(c1, a, sizeof(a));
    memcpy(c2, a0, sizeof(a0));
    signed long long k1 = xn;
    signed long long k2 = x;
    for (int j = (9); j >= (int)(0); j--) {
      while (xx >= p10[j]) {
        if (f(k1) != f(k2)) return false;
        xx -= p10[j] - 1;
        k1 += p10[j] - 1;
        k2 += p10[j] - 1;
        if (f(k1) != f(k2)) return false;
        xx -= 1;
        k1 += 1;
        k2 += 1;
      }
    }
    break;
  }
  return true;
}
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  p10[0] = 1;
  for (int i = (1); i <= (int)(19); i++) {
    p10[i] = p10[i - 1] * 10;
  }
  scanf("%d%d", &x, &n);
  int z = x;
  memset((a0), 0, sizeof(a0));
  int l = 0;
  while (z) {
    a0[l++] = z % 10;
    z /= 10;
  }
  signed long long xx = x + 1000000000;
  for (int zz = 0; zz < (int)(10); zz++) {
    for (int l = (9); l >= (int)(1); l--) {
      xx -= (signed long long)p10[l] * 1000;
      for (int i = 0; i < (int)(10000); i++) {
        xx += p10[l - 1];
        if (xx <= x) continue;
        if (check(xx)) break;
      }
    }
  }
  cout << xx << endl;
  return 0;
}

### Prompt

Please provide a cpp coded solution 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;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int x, n;
signed long long p10[22];
int a0[22];
int a[22];
int b[22];
int c1[22];
int c2[22];
int f(int x) {
  int ans = 0;
  while (x) {
    ans += x % 10 == 4 || x % 10 == 7;
    x /= 10;
  }
  return ans;
}
bool check(signed long long xn) {
  signed long long z = xn;
  memset((a), 0, sizeof(a));
  int l = 0;
  while (z) {
    a[l++] = z % 10;
    z /= 10;
  }
  int xx = n;
  for (int i = 0; i < (int)(10); i++) {
    if (a[i] == a0[i]) continue;
    if (n >= p10[i + 1]) return false;
    memcpy(c1, a, sizeof(a));
    memcpy(c2, a0, sizeof(a0));
    signed long long k1 = xn;
    signed long long k2 = x;
    for (int j = (9); j >= (int)(0); j--) {
      while (xx >= p10[j]) {
        if (f(k1) != f(k2)) return false;
        xx -= p10[j] - 1;
        k1 += p10[j] - 1;
        k2 += p10[j] - 1;
        if (f(k1) != f(k2)) return false;
        xx -= 1;
        k1 += 1;
        k2 += 1;
      }
    }
    break;
  }
  return true;
}
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  p10[0] = 1;
  for (int i = (1); i <= (int)(19); i++) {
    p10[i] = p10[i - 1] * 10;
  }
  scanf("%d%d", &x, &n);
  int z = x;
  memset((a0), 0, sizeof(a0));
  int l = 0;
  while (z) {
    a0[l++] = z % 10;
    z /= 10;
  }
  signed long long xx = x + 1000000000;
  for (int zz = 0; zz < (int)(10); zz++) {
    for (int l = (9); l >= (int)(1); l--) {
      xx -= (signed long long)p10[l] * 1000;
      for (int i = 0; i < (int)(10000); i++) {
        xx += p10[l - 1];
        if (xx <= x) continue;
        if (check(xx)) break;
      }
    }
  }
  cout << xx << endl;
  return 0;
}

```