lucky-kitties
Source: hackerearth
Difficulty: EASY

It’s well know fact among kitties that digits 4 and 7 are lucky digits.
Today, N boxes of fish bites arrived. Each box has a unique integer label on it, ranged between 1 and N, inclusive. The boxes are going to be given away to the kitties in increasing order of their labels. That is, the first box given away will be the box with label 1, and the last one will be the box with label N.

The kitties are ordered in line for the fish bites. While there is any fish bites box left, it’s given away to the cat who is the first in line for it. This cat counts the total number of lucky digits among all box labels received by him. As soon as this number exceeds K, the cat becomes lucky and leaves the line, and the next cat occupies his place.

Your task is to find out the number of kitties that are going to be lucky at the end of the described process.

Input format

The first line of the input contains the integer K. The second line contains the integer N, without leading zeros.

Output format

In the only line of the output print the number of lucky kitties modulo 1,000,000,007.

Constraints

N is between 1 and 10^10000 and K is between 1 and 10, inclusive.

SAMPLE INPUT
3
74

SAMPLE OUTPUT
7


k = eval(input())
n = eval(input())

i=1
a=0
b=0
cnt=0

while(i<=n):
	a+=str(i).count('4')
	b+=str(i).count('7')
	if(a+b>k):
		cnt+=1
		a=0
		b=0
	i+=1
print(cnt)



k = int(input())
n = int(input())
lucky = 0
kc = 0

for i in range(1, n+1):
	s = str(i)
	kc += s.count('4')
	kc += s.count('7')
	
	if kc>k:
		lucky += 1
		kc =0

print(lucky)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
x = eval(input())
y = eval(input())
i=1
z=0
w=0

count = 0

while(i<=y):
	z = z + str(i).count('4')
	w = w + str(i).count('7')
	
	if((z+w) > x):
		count = count+1
		z=0
		w=0
	i = i+1
print(count)