Hi guys im new to programming. this program is throwing a tle.any help?

for _ in range(int(input())):
min,max=map(int,input().split())
count=0
for i in range(min,max+1):
b=str(i)
if (b.count(‘2’)>=b.count(‘3’)>=b.count(‘5’)>=b.count(‘7’)):
count=count+1
print(count)