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.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.security.KeyStore.Builder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

import javax.swing.text.html.MinimalHTMLWriter;

public class LuckySegments {
	static StringTokenizer st = null;
    static BufferedReader reader = null;
    public static void main(String[] args) throws Exception {	
		reader = new BufferedReader(new InputStreamReader(System.in));
		double t = System.currentTimeMillis();
		//reader = new BufferedReader(new FileReader("input.txt"));
		int n = NextInt();
		

		long k = NextLong();
		
		int SIZE = 1 << 20;
		long[] a = new long[SIZE];
		int p = 0;
		for (int len = 1; len <= 19; ++len) {
			for (int mask = 0; mask < (1 << len); ++mask) {
				long num = 0;
				for (int i = 0; i < len; ++i)
					num = num * 10 + 4 + 3 * ((mask & (1 << i)) == 0 ? 1 : 0);
				a[p++] = num;
			}
		}
		
		a = Arrays.copyOf(a, p);
		Arrays.sort(a);
		int lower = 0;
		int upper = p + 1 + 1;
		long min_length = Long.MAX_VALUE;
		long begins[] = new long[n];
		long ends[] = new long[n];
		for (int i = 0; i < n; ++i) {
			begins[i] = NextLong();
			ends[i] = NextLong();
			min_length = Math.min(min_length, ends[i] - begins[i] + 1);
		}
		System.err.println(min_length);
		Arrays.sort(begins);
		Arrays.sort(ends);
		//BigInteger totalBegins = BigInteger.ZERO;
		long totalBeginsLong = 0;
		double totalBeginsDouble = 0.0;
		for (int i = 0; i < n; ++i) {
			//totalBegins = totalBegins.add(BigInteger.valueOf(begins[i]));
			totalBeginsLong += begins[i];
			totalBeginsDouble += begins[i];
		}
		while (lower + 1 < upper) {
			int median = (lower + upper) >> 1;
			boolean ok = false;
			int b = 0;
			int e = 0;
			long begSumLong = 0;
			double begSumDouble = 0.0;
			long endSumLong = 0;
			double endSumDouble = 0.0;
			
			for (int i = 0; !ok && i + median - 1 < p; ++i) {
				long first = a[i];
				long second = a[i + median - 1];
				//BigInteger begSum = BigInteger.ZERO;
				
				//BigInteger endSum = BigInteger.ZERO;
				while(b < n && begins[b] <= first) {
					//begSum = begSum.add(BigInteger.valueOf(begins[b]));
					
					begSumDouble += begins[b];
					begSumLong += begins[b];
					//System.err.println("!=" + begSumLong);
					++b;
				}
				while(e < n && ends[e] <= second) {
					//endSum = endSum.add(BigInteger.valueOf(ends[e]));
					endSumLong += ends[e];
					endSumDouble += ends[e];
					++e;
				}
				long need_length = second - first + 1;
				
				if (need_length > min_length)
					continue;
				double operationsDouble = totalBeginsDouble - begSumDouble - (((double)(n - b)) * first);
				operationsDouble +=  ((double)second) * e - endSumDouble;
				long operationsLong = totalBeginsLong - begSumLong - (long)((long)n - b) * first;
				operationsLong += (long)second * e - endSumLong;
				/*if (median == 2) {
					System.err.println(e);
					System.err.println(endSumLong);
					System.err.println(b);
					System.err.println(begSumLong);
					System.err.println(totalBeginsLong);
					System.err.println(operationsDouble);
					System.err.println(operationsLong);
				}*/
				//BigInteger operations = totalBegins.subtract(begSum).subtract(BigInteger.valueOf(first).multiply(BigInteger.valueOf(n - b)));
				//operations = operations.add((BigInteger.valueOf(second).multiply(BigInteger.valueOf(e))).subtract(endSum));
				
				//if (operations.compareTo(BigInteger.valueOf(k)) <= 0) {
				if (operationsDouble < 3.0 * k + 10  && operationsLong <= k) {
					ok = true;
					break;
				}
			}
			if (ok)
				lower = median;
			else
				upper = median;
		}
		System.out.println(lower);
		System.err.println(System.currentTimeMillis() - t);
    }
    static String NextToken() throws IOException {
		while(st == null || !st.hasMoreTokens())
			st = new StringTokenizer(reader.readLine());
		return st.nextToken();
	}
	static int NextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(NextToken());
	}
	static long NextLong() throws NumberFormatException, IOException {
		return Long.parseLong(NextToken());
	}
}
