Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya has n number segments [l1; r1], [l2; r2], ..., [ln; rn]. During one move Petya can take any segment (let it be segment number i) and replace it with segment [li + 1; ri + 1] or [li - 1; ri - 1]. In other words, during one move Petya can shift any segment to the left or to the right by a unit distance. Petya calls a number full if it belongs to each segment. That is, number x is full if for any i (1 ≤ i ≤ n) the condition li ≤ x ≤ ri is fulfilled.

Petya makes no more than k moves. After that he counts the quantity of full lucky numbers. Find the maximal quantity that he can get.

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 1018) — the number of segments and the maximum number of moves. Next n lines contain pairs of integers li and ri (1 ≤ li ≤ ri ≤ 1018).

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the %I64d specificator.

Output

Print on the single line the single number — the answer to the problem.

Examples

Input

4 7
1 4
6 9
4 7
3 5


Output

1


Input

2 7
40 45
47 74


Output

2

Note

In the first sample Petya shifts the second segment by two units to the left (it turns into [4; 7]), after that number 4 becomes full.

In the second sample Petya shifts the first segment by two units to the right (it turns into [42; 47]), and shifts the second segment by three units to the left (it turns into [44; 71]), after that numbers 44 and 47 become full.
#include <bits/stdc++.h>
using namespace std;
int n, N, i, j, l, r, h, res;
long long m, mx, LE, a[525525], b[100100], c[100100], le[525525], ri[525525];
long double cur;
void rec(int l, long long s) {
  if (l > 0) a[n++] = s;
  if (l < 18) rec(l + 1, s * 10 + 4);
  if (l < 18) rec(l + 1, s * 10 + 7);
}
int main() {
  rec(0, 0);
  sort(a, a + n);
  N = n;
  scanf("%d%I64d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d", &b[i], &c[i]);
    if (i == 0 || c[i] - b[i] < mx) mx = c[i] - b[i];
  }
  sort(b, b + n);
  sort(c, c + n);
  for (i = j = 0; i < N; i++) {
    if (i > 0) {
      cur = a[i] - a[i - 1];
      cur *= j;
      ri[i] = (cur < 0.25e19) ? ri[i - 1] + (a[i] - a[i - 1]) * j : (m + 10);
    }
    for (; j < n && c[j] <= a[i]; j++) {
      ri[i] += a[i] - c[j];
      if (ri[i] > m + 10) ri[i] = m + 10;
    }
  }
  for (i = N - 1, j = n - 1; i >= 0; i--) {
    if (i < N - 1) {
      cur = a[i + 1] - a[i];
      cur *= n - 1 - j;
      le[i] = (cur < 0.25e19) ? le[i + 1] + (a[i + 1] - a[i]) * (n - 1LL - j)
                              : (m + 10);
    }
    for (; j >= 0 && b[j] >= a[i]; j--) {
      le[i] += b[j] - a[i];
      if (le[i] > m + 10) le[i] = m + 10;
    }
  }
  for (i = 0; i < N; i++) {
    if (le[i] + ri[i] > m) continue;
    LE = le[i];
    l = i;
    r = N - 1;
    while (l < r) {
      h = (l + r) / 2 + 1;
      if (a[h] - a[i] > mx || LE + ri[h] > m)
        r = h - 1;
      else
        l = h;
    }
    if (r - i + 1 > res) res = r - i + 1;
  }
  printf("%d\n", res);
  return 0;
}
