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;
const int MAX = 800 * 1000;
const long long MM = 1000LL * 1000 * 1000 * 1000LL * 1000 * 1000;
const long long D = MM / 1000 * 1000;
pair<long long, long long> s[MAX + 10];
long long a[MAX + 10];
bool mrk[MAX + 10];
vector<pair<long long, long long> > se[MAX + 10];
long long cntl[MAX + 10];
long long sum[MAX + 10][2];
long long cnt[MAX + 10][2];
int head;
int n;
long long k;
long long mns = MM;
long long mxout = 0;
inline bool lucky(long long);
inline void init1();
inline void init2();
long long summove;
long long cntluck;
long long end, st, ep, sp;
inline long long check(int s, int e) {
  long long summove = sum[e][1] + sum[s][0];
  long long cntluck = cntl[e] - (s == 0 ? 0 : cntl[s - 1]);
  if (summove <= k) mxout = max(mxout, cntluck);
  return summove;
}
int main() {
  ios::sync_with_stdio(false);
  init1();
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> s[i].first >> s[i].second, a[head++] = s[i].first,
                                      a[head++] = s[i].second;
  sort(a, a + head);
  head = unique(a, a + head) - a;
  for (int i = 0; i < n; i++) {
    se[(lower_bound(a, a + head, s[i].first) - a)].push_back(
        pair<long long, long long>(0, i));
    se[(lower_bound(a, a + head, s[i].second) - a)].push_back(
        pair<long long, long long>(1, i));
    mns = min(mns, s[i].second - s[i].first);
  }
  for (int i = 0; i < head; i++)
    if (lucky(a[i])) mrk[i] = true;
  init2();
  cerr << (double)clock() / CLOCKS_PER_SEC << endl;
  for (int i = 0; i < head; i++) {
    int s = i, e = (upper_bound(a, a + head, a[i] + mns) - a - 1);
    check(s, e);
    for (int t = 0; t < 13; t++) {
      int m = (s + e) / 2;
      if (check(i, m) <= k)
        s = m;
      else
        e = m;
    }
    s = (lower_bound(a, a + head, a[i] - mns) - a);
    e = i;
    check(s, e);
    for (int t = 0; t < 13; t++) {
      int m = (s + e) / 2;
      if (check(m, i) <= k)
        s = m;
      else
        e = m;
    }
  }
  cout << mxout << endl;
  cerr << (double)clock() / CLOCKS_PER_SEC << endl;
  return 0;
}
void init2() {
  cntl[0] = mrk[0];
  for (int i = 1; i < head; i++) cntl[i] = mrk[i] + cntl[i - 1];
  cnt[0][1] = 0;
  sum[0][1] = 0;
  for (int j = 0; j < (int)se[0].size(); j++)
    if (se[0][j].first == 1) cnt[0][1]++;
  for (int i = 1; i < head; i++) {
    cnt[i][1] = cnt[i - 1][1];
    sum[i][1] = sum[i - 1][1];
    if (MM / ((long long)a[i] - a[i - 1]) >= cnt[i - 1][1])
      sum[i][1] += ((long long)a[i] - a[i - 1]) * cnt[i - 1][1];
    else
      sum[i][1] = k + 1;
    if (sum[i][1] > k) sum[i][1] = k + 1;
    for (int j = 0; j < (int)se[i].size(); j++)
      if (se[i][j].first == 1) cnt[i][1]++;
  }
  cnt[head - 1][0] = 0;
  sum[head - 1][0] = 0;
  for (int j = 0; j < (int)se[head - 1].size(); j++)
    if (se[head - 1][j].first == 0) cnt[head - 1][0]++;
  for (int i = head - 2; i >= 0; i--) {
    cnt[i][0] = cnt[i + 1][0];
    sum[i][0] = sum[i + 1][0];
    if (MM / ((long long)a[i + 1] - a[i]) >= cnt[i + 1][0])
      sum[i][0] += ((long long)a[i + 1] - a[i]) * cnt[i + 1][0];
    else
      sum[i][0] = k + 1;
    if (sum[i][0] > k) sum[i][0] = k + 1;
    for (int j = 0; j < (int)se[i].size(); j++)
      if (se[i][j].first == 0) cnt[i][0]++;
  }
}
void init1() {
  a[0] = 4;
  a[1] = 7;
  head = 2;
  int p = 0;
  for (; p < head; p++) {
    if (MM / a[p] >= 10) {
      long long tmp1 = a[p] * 10 + 4;
      long long tmp2 = a[p] * 10 + 7;
      if (tmp1 <= MM) a[head++] = tmp1;
      if (tmp2 <= MM) a[head++] = tmp2;
    }
  }
}
bool lucky(long long a) {
  while (a) {
    if (!(a % 10 == 4 || a % 10 == 7)) return false;
    a /= 10;
  }
  return true;
}
