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;
pair<long long, long long> A[100000];
pair<long long, long long> B[100000];
struct bigint {
  bigint() { memset(A, 0, sizeof(A)); }
  bigint(unsigned long long x) {
    for (int i = 0; i < ((80 + 15) / 16); i++) {
      A[i] = x & 0xFFFF;
      x = x >> 16;
    }
  }
  bigint& fix() {
    for (int i = 0; i < ((80 + 15) / 16); i++) {
      if (i + 1 < ((80 + 15) / 16)) A[i + 1] += A[i] >> 16;
      A[i] &= 0xFFFF;
    }
    return *this;
  }
  void fixup(int i) {
    for (; i < ((80 + 15) / 16) && A[i] < (1 << 16); i++) {
      if (i + 1 < ((80 + 15) / 16)) A[i + 1] += A[i] >> 16;
      A[i] &= 0xFFFF;
    }
  }
  bigint& operator+=(const bigint& x) {
    for (int i = 0; i < ((80 + 15) / 16); i++) A[i] += x.A[i];
    return fix();
  }
  bigint& operator-=(const bigint& x) {
    int c = 0;
    for (int i = 0; i < ((80 + 15) / 16); i++) {
      A[i] -= x.A[i] + c;
      c = A[i] < 0 ? 1 : 0;
      if (c) A[i] += 1 << 16;
    }
    return *this;
  }
  bigint& operator*=(const bigint& x) {
    for (int i = ((80 + 15) / 16) - 1; i >= 0; i--) {
      A[i] = A[i] * x.A[0];
      fixup(i);
      for (int j = i - 1; j >= 0; j--) {
        int k = i - j;
        A[i] += A[j] * x.A[k];
        fixup(i);
      }
    }
    return fix();
  }
  bigint& operator*=(int x) {
    if (x > 1 << 16) return *this *= bigint(x);
    for (int i = 0; i < ((80 + 15) / 16); i++) {
      A[i] *= x;
    }
    return fix();
  }
  int operator/=(int x) {
    int c = 0;
    for (int i = ((80 + 15) / 16) - 1; i >= 0; i--) {
      int v = (c << 16) + A[i];
      c = v % x;
      A[i] = v / x;
    }
    return c;
  }
  bool operator<(const bigint& x) const {
    for (int i = ((80 + 15) / 16) - 1; i >= 0; i--) {
      if (A[i] != x.A[i]) {
        return A[i] < x.A[i];
      }
    }
    return false;
  }
  bool operator==(const bigint& x) const { return !memcmp(A, x.A, sizeof(A)); }
  string tostr() {
    string ret;
    bigint cpy = *this;
    bigint zero = 0;
    while (!(cpy == zero)) {
      ret += '0' + (cpy /= 10);
    }
    reverse(ret.begin(), ret.end());
    return ret.empty() ? "0" : ret;
  }
  int A[((80 + 15) / 16)];
};
int main() {
  vector<long long> v;
  for (int i = 1; i <= 18; i++) {
    for (int j = 0; j < 1 << i; j++) {
      long long x = 0;
      for (int k = 0; k < i; k++) {
        x *= 10;
        x += (j & 1 << k) ? 7 : 4;
      }
      v.push_back(x);
    }
  }
  sort(v.begin(), v.end());
  int N;
  long long K;
  cin >> N >> K;
  long long mnsp = 0x7FFFFFFFFFFFFFFFLL;
  for (int i = 0; i < N; i++) {
    cin >> A[i].second >> A[i].first;
    A[i].first++;
    mnsp = min(mnsp, A[i].first - A[i].second);
  }
  sort(A, A + N);
  for (int i = 0; i < N; i++) swap(A[i].first, A[i].second);
  memcpy(B, A, sizeof(B));
  sort(A, A + N);
  bigint hsuminit = 0;
  for (int i = 0; i < N; i++) hsuminit += A[i].first;
  int lo = 0;
  int hi = v.size();
  while (lo < hi) {
    int md = (lo + hi + 1) / 2;
    bool ok = false;
    int posh = 0;
    int posl = 0;
    bigint hsum = hsuminit;
    bigint lsum = 0;
    for (int i = 0; !ok && i + md <= v.size(); i++) {
      long long lk = v[i];
      long long hk = v[i + md - 1];
      if (hk - lk + 1 > mnsp) continue;
      while (posh < N && A[posh].first <= lk) {
        hsum -= A[posh++].first;
      }
      while (posl < N && B[posl].second <= hk) {
        lsum += B[posl++].second - 1;
      }
      bigint t0 = hk;
      t0 *= posl;
      t0 -= lsum;
      bigint t1 = lk;
      t1 *= N - posh;
      bigint tmp = hsum;
      tmp -= t1;
      t1 = tmp;
      t0 += t1;
      ok = t0 < K + 1;
    }
    if (ok)
      lo = md;
    else
      hi = md - 1;
  }
  cout << lo << endl;
}
