def getN():

    return int(eval(input()))

def getNM():

    return list(map(int, input().split()))

def getList():

    return list(map(int, input().split()))

def getArray(intn):

    return [int(eval(input())) for i in range(intn)]

def input():

    return sys.stdin.readline().rstrip()



from collections import defaultdict, deque, Counter

from sys import exit

import heapq

import math

import fractions

import copy

from itertools import permutations

from operator import mul

from functools import reduce

from bisect import bisect_left, bisect_right



import sys

sys.setrecursionlimit(1000000000)

mod = 10 ** 9 + 7



S = eval(input())

N = len(S)

modlist = [0] * 13

splitmod = []



if S[0] == "?":

    for i in range(10):

        modlist[i % 13] += 1

else:

    modlist[int(S[0])] += 1

S = S[1:]



# 前から処理していく

# 10と13は互いに素なので

# a == b (mod z)なら

# 10a == 10b (mod z)

# 例

# 18 == 5 (mod 13)

# 180 == 50 (mod 13)

# 13 * 13 + 11 == 13 * 3 + 11 (mod 13)

for st in S:

    modalta = [0] * 13

    if st == "?":

        # 例えば 7?4の時

        # 7 * 10 + 1, 2, 3...

        for i in range(10):

            # modlist

            for j in range(13):

                opt = (j * 10 + i) % 13

                modalta[opt] += modlist[j]

    else:

        for j in range(13):

            opt = (j * 10 + int(st)) % 13

            modalta[opt] += modlist[j]

    # mod調整

    for i in range(13):

        modalta[i] %= mod

    modlist = copy.deepcopy(modalta)



print((modlist[5] % mod))
def getN():

    return int(eval(input()))

def getNM():

    return list(map(int, input().split()))

def getList():

    return list(map(int, input().split()))

def getArray(intn):

    return [int(eval(input())) for i in range(intn)]

def input():

    return sys.stdin.readline().rstrip()

def rand_N(ran1, ran2):

    return random.randint(ran1, ran2)

def rand_List(ran1, ran2, rantime):

    return [random.randint(ran1, ran2) for i in range(rantime)]

def rand_ints_nodup(ran1, ran2, rantime):

  ns = []

  while len(ns) < rantime:

    n = random.randint(ran1, ran2)

    if not n in ns:

      ns.append(n)

  return sorted(ns)



def rand_query(ran1, ran2, rantime):

  r_query = []

  while len(r_query) < rantime:

    n_q = rand_ints_nodup(ran1, ran2, 2)

    if not n_q in r_query:

      r_query.append(n_q)

  return sorted(r_query)



from collections import defaultdict, deque, Counter

from sys import exit

from decimal import *

import heapq

import math

from fractions import gcd

import random

import string

import copy

from itertools import combinations, permutations, product

from operator import mul

from functools import reduce

from bisect import bisect_left, bisect_right



import sys

sys.setrecursionlimit(1000000000)

mod = 10 ** 9 + 7



#############

# Main Code #

#############



S = eval(input())

N = len(S)



dp = [[0] * 13 for i in range(N)]

str_int = '0123456789'

if S[0] in str_int:

    dp[0][int(S[0])] += 1

else:

    for i in range(10):

        dp[0][i] += 1



for i in range(1, N):

    if S[i] in str_int:

        # 前の段

        for j in range(13):

            dp[i][(10 * j + int(S[i])) % 13] += (dp[i - 1][j] % mod)

    else:

        # 前の段

        for j in range(13):

            # 後ろの段

            # ?なら0 ~ 10で回す

            for l in range(10):

                dp[i][(10 * j + l) % 13] += (dp[i - 1][j] % mod)



print((dp[N - 1][5] % mod))
def getN():
    return int(eval(input()))


def getNM():
    return list(map(int, input().split()))


def getList():
    return list(map(int, input().split()))


def getArray(intn):
    return [int(eval(input())) for i in range(intn)]


def input():
    return sys.stdin.readline().rstrip()


from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys

sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
S = eval(input())
N = len(S)
modlist = [0] * 13
splitmod = []
if S[0] == "?":
    for i in range(10):
        modlist[i % 13] += 1
else:
    modlist[int(S[0])] += 1
S = S[1:]
# 前から処理していく
# 10と13は互いに素なので
# a == b (mod z)なら
# 10a == 10b (mod z)
# 例
# 18 == 5 (mod 13)
# 180 == 50 (mod 13)
# 13 * 13 + 11 == 13 * 3 + 11 (mod 13)
for st in S:
    modalta = [0] * 13
    if st == "?":
        # 例えば 7?4の時
        # 7 * 10 + 1, 2, 3...
        for i in range(10):
            # modlist
            for j in range(13):
                opt = (j * 10 + i) % 13
                modalta[opt] += modlist[j]
    else:
        for j in range(13):
            opt = (j * 10 + int(st)) % 13
            modalta[opt] += modlist[j]
    # mod調整
    for i in range(13):
        modalta[i] %= mod
    modlist = copy.deepcopy(modalta)
print((modlist[5] % mod))

def getN():
    return int(eval(input()))


def getNM():
    return list(map(int, input().split()))


def getList():
    return list(map(int, input().split()))


def getArray(intn):
    return [int(eval(input())) for i in range(intn)]


def input():
    return sys.stdin.readline().rstrip()


def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)


def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]


def rand_ints_nodup(ran1, ran2, rantime):
    ns = []
    while len(ns) < rantime:
        n = random.randint(ran1, ran2)
        if not n in ns:
            ns.append(n)
    return sorted(ns)


def rand_query(ran1, ran2, rantime):
    r_query = []
    while len(r_query) < rantime:
        n_q = rand_ints_nodup(ran1, ran2, 2)
        if not n_q in r_query:
            r_query.append(n_q)
    return sorted(r_query)


from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys

sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
#############
# Main Code #
#############
S = eval(input())
N = len(S)
dp = [[0] * 13 for i in range(N)]
str_int = "0123456789"
if S[0] in str_int:
    dp[0][int(S[0])] += 1
else:
    for i in range(10):
        dp[0][i] += 1
for i in range(1, N):
    if S[i] in str_int:
        # 前の段
        for j in range(13):
            dp[i][(10 * j + int(S[i])) % 13] += dp[i - 1][j] % mod
    else:
        # 前の段
        for j in range(13):
            # 後ろの段
            # ?なら0 ~ 10で回す
            for l in range(10):
                dp[i][(10 * j + l) % 13] += dp[i - 1][j] % mod
print((dp[N - 1][5] % mod))

+def rand_N(ran1, ran2): +    return random.randint(ran1, ran2) + + +def rand_List(ran1, ran2, rantime): +    return [random.randint(ran1, ran2) for i in range(rantime)] + + +def rand_ints_nodup(ran1, ran2, rantime): +    ns = [] +    while len(ns) < rantime: +        n = random.randint(ran1, ran2) +        if not n in ns: +            ns.append(n) +    return sorted(ns) + + +def rand_query(ran1, ran2, rantime): +    r_query = [] +    while len(r_query) < rantime: +        n_q = rand_ints_nodup(ran1, ran2, 2) +        if not n_q in r_query: +            r_query.append(n_q) +    return sorted(r_query) + + +from decimal import * -import fractions +from fractions import gcd +import random +import string -from itertools import permutations +from itertools import combinations, permutations, product +############# +# Main Code # +############# -modlist = [0] * 13 -splitmod = [] -if S[0] == "?": +dp = [[0] * 13 for i in range(N)] +str_int = "0123456789" +if S[0] in str_int: +    dp[0][int(S[0])] += 1 +else: -        modlist[i % 13] += 1 -else: -    modlist[int(S[0])] += 1 -S = S[1:] -# 前から処理していく -# 10と13は互いに素なので -# a == b (mod z)なら -# 10a == 10b (mod z) -# 例 -# 18 == 5 (mod 13) -# 180 == 50 (mod 13) -# 13 * 13 + 11 == 13 * 3 + 11 (mod 13) -for st in S: -    modalta = [0] * 13 -    if st == "?": -        # 例えば 7?4の時 -        # 7 * 10 + 1, 2, 3... -        for i in range(10): -            # modlist -            for j in range(13): -                opt = (j * 10 + i) % 13 -                modalta[opt] += modlist[j] +        dp[0][i] += 1 +for i in range(1, N): +    if S[i] in str_int: +        # 前の段 +        for j in range(13): +            dp[i][(10 * j + int(S[i])) % 13] += dp[i - 1][j] % mod +        # 前の段 -            opt = (j * 10 + int(st)) % 13 -            modalta[opt] += modlist[j] -    # mod調整 -    for i in range(13): -        modalta[i] %= mod -    modlist = copy.deepcopy(modalta) -print((modlist[5] % mod)) +            # 後ろの段 +            # ?なら0 ~ 10で回す +            for l in range(10): +                dp[i][(10 * j + l) % 13] += dp[i - 1][j] % mod +print((dp[N - 1][5] % mod))