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>
const int MAXN = 100000 + 10;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int cnt, p[20], ans;
long long n, k, num[1 << 20], mnlen = inf;
double sl[MAXN], sr[MAXN];
struct node {
  long long l, r;
  inline bool operator<(const node &A) const {
    return r < A.r || (r == A.r && l < A.l);
  };
  inline bool operator>(const node &A) const {
    return l < A.l || (l == A.l && r < A.r);
  };
};
node l1[MAXN], l2[MAXN];
template <typename T>
inline void read(T &x) {
  T data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = ((T)data << 3) + ((T)data << 1) + (ch ^ '0'), ch = getchar();
  x = data * w;
}
template <typename T>
inline void write(T x, char ch = '\0') {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  if (ch != '\0') putchar(ch);
}
template <typename T>
inline bool chkmin(T &x, T y) {
  return y < x ? (x = y, true) : false;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return y > x ? (x = y, true) : false;
}
template <typename T>
inline T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
inline T max(T x, T y) {
  return x > y ? x : y;
}
inline bool cmp(node a, node b) { return a > b; }
inline void dfs(int x, long long v) {
  if (x > 18) return;
  num[++cnt] = v * 10 + 4;
  dfs(x + 1, num[cnt]);
  num[++cnt] = v * 10 + 7;
  dfs(x + 1, num[cnt]);
}
inline void init() {
  for (register int i = (1), iend = (n); i <= iend; ++i)
    sr[i] = sr[i - 1] + l1[i].r;
  for (register int i = (n), iend = (1); i >= iend; --i)
    sl[i] = sl[i + 1] + l2[i].l;
  dfs(1, 0);
  std::sort(num + 1, num + cnt + 1);
}
int main() {
  read(n);
  read(k);
  for (register int i = (1), iend = (n); i <= iend; ++i) {
    read(l1[i].l), read(l1[i].r);
    l2[i] = l1[i];
    chkmin(mnlen, l1[i].r - l1[i].l + 1);
  }
  std::sort(l1 + 1, l1 + n + 1);
  std::sort(l2 + 1, l2 + n + 1, cmp);
  init();
  int r = 0;
  for (register int l = (1), lend = (cnt); l <= lend; ++l) {
    int lp =
        std::upper_bound(l2 + 1, l2 + n + 1, (node){num[l], inf}, cmp) - l2;
    while (r < cnt && num[r + 1] - num[l] + 1 <= mnlen) {
      int rp =
          std::lower_bound(l1 + 1, l1 + n + 1, (node){0, num[r + 1]}) - l1 - 1;
      if ((double)num[r + 1] * rp - sr[rp] + sl[lp] -
              (double)num[l] * (n - lp + 1) >
          k)
        break;
      r++;
    }
    chkmax(ans, r - l + 1);
  }
  write(ans, '\n');
  return 0;
}
