import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write N=list(map(int,list(readline().rstrip()))) mod=10**9+7 C2=[-1,0,1,0,2,0,1,0,2,0] C5=[0,0,0,0,0,1,0,0,0,0] dp=[0]*9 for i in range(1,N[0]): dp[C2[i]*3+C5[i]]+=1 cnt2,cnt5=C2[N[0]],C5[N[0]] for n in N[1:]: prev=dp dp=[0]*9 for c2 in range(3): for c5 in range(3): for i in range(1,10): dp[min(c2+C2[i],2)*3+min(c5+C5[i],2)]+=prev[c2*3+c5] for c2c5 in range(9): dp[c2c5]%=mod for i in range(1,10): dp[C2[i]*3+C5[i]]+=1 for i in range(1,n): dp[min(C2[i]+cnt2,2)*3+min(C5[i]+cnt5,2)]+=1 cnt2+=C2[n] cnt2=min(cnt2,2) cnt5+=C5[n] cnt5=min(cnt5,2) ans=dp[8] if not 0 in N and sum(C2[n] for n in N)>=2 and sum(C5[n] for n in N)>=2: ans+=1 ans%=mod print(ans)