import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



s = readline().rstrip().decode()

mod = 10 ** 9 + 7

ans = [0] * 13

ans[0] = 1

for check in s:

    dp = [0] * 13

    for i in range(13):

        dp[(i * 10) % 13] = ans[i] % mod

    dp += dp

    for i in range(13):

        if check == '?':

            ans[i] = sum(dp[i + 4:i + 14])

        else:

            ans[i] = dp[i - int(check)]

print((ans[5] % mod))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



s = read().rstrip().decode()

dp = [[0] * 13 for _ in range(len(s))]

mod = 10 ** 9 + 7

if s[0] == '?':

    dp[0] = 10 * [1] + [0] * 3

else:

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

for i, ss in enumerate(s[1:]):

    if ss == '?':

        for j in range(13):

            for k in range(10):

                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]

    else:

        for j in range(13):

            dp[i + 1][(int(ss) + j * 10) % 13] += dp[i][j]

    for j in range(13):

        dp[i + 1][j] %= mod

print((dp[-1][5]))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
s = readline().rstrip().decode()
mod = 10**9 + 7
ans = [0] * 13
ans[0] = 1
for check in s:
    dp = [0] * 13
    for i in range(13):
        dp[(i * 10) % 13] = ans[i] % mod
    dp += dp
    for i in range(13):
        if check == "?":
            ans[i] = sum(dp[i + 4 : i + 14])
        else:
            ans[i] = dp[i - int(check)]
print((ans[5] % mod))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
s = read().rstrip().decode()
dp = [[0] * 13 for _ in range(len(s))]
mod = 10**9 + 7
if s[0] == "?":
    dp[0] = 10 * [1] + [0] * 3
else:
    dp[0][int(s[0])] += 1
for i, ss in enumerate(s[1:]):
    if ss == "?":
        for j in range(13):
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
    else:
        for j in range(13):
            dp[i + 1][(int(ss) + j * 10) % 13] += dp[i][j]
    for j in range(13):
        dp[i + 1][j] %= mod
print((dp[-1][5]))

-s = readline().rstrip().decode() +s = read().rstrip().decode() +dp = [[0] * 13 for _ in range(len(s))] -ans = [0] * 13 -ans[0] = 1 -for check in s: -    dp = [0] * 13 -    for i in range(13): -        dp[(i * 10) % 13] = ans[i] % mod -    dp += dp -    for i in range(13): -        if check == "?": -            ans[i] = sum(dp[i + 4 : i + 14]) -        else: -            ans[i] = dp[i - int(check)] -print((ans[5] % mod)) +if s[0] == "?": +    dp[0] = 10 * [1] + [0] * 3 +else: +    dp[0][int(s[0])] += 1 +for i, ss in enumerate(s[1:]): +    if ss == "?": +        for j in range(13): +            for k in range(10): +                dp[i + 1][(j * 10 + k) % 13] += dp[i][j] +    else: +        for j in range(13): +            dp[i + 1][(int(ss) + j * 10) % 13] += dp[i][j] +    for j in range(13): +        dp[i + 1][j] %= mod +print((dp[-1][5]))