import sys

import math

import bisect

import heapq

from collections import Counter





def input():

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





def main():

    mod = 10 ** 9 + 7

    S = list(eval(input()))

    l = len(S)

    dp = [[0] * 13 for _ in range(l + 1)]



    dp[0][0] = 1

    for j in range(1, l + 1):

        if S[j - 1] == "?":

            for k in range(13):

                for q in range(10):

                    new_k = (k * 10 + q) %13

                    dp[j][new_k] += dp[j - 1][k]

                    dp[j][new_k] %= mod

        else:

            n = int(S[j - 1])

            for k in range(13):

                new_k = (k * 10 + n)%13

                dp[j][new_k] += dp[j - 1][k]

                dp[j][new_k] %= mod

    print((dp[l][5]))



if __name__ == "__main__":

    main()

import sys

import math

import bisect

import heapq

from collections import Counter





def input():

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





def main():

    mod = 10 ** 9 + 7

    S = list(eval(input()))

    l = len(S)

    dp = [[0] * 13 for _ in range(l + 1)]



    dp[0][0] = 1

    for j in range(1, l + 1):

        if S[j - 1] == "?":

            for k in range(13):

                for q in range(10):

                    new_k = (k * 10 + q) %13

                    dp[j][new_k] += dp[j - 1][k]

            for k in range(13):

                dp[j][k] %= mod

        else:

            n = int(S[j - 1])

            for k in range(13):

                new_k = (k * 10 + n)%13

                dp[j][new_k] += dp[j - 1][k]

                dp[j][new_k] %= mod

    print((dp[l][5]))



if __name__ == "__main__":

    main()

import sys
import math
import bisect
import heapq
from collections import Counter


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


def main():
    mod = 10**9 + 7
    S = list(eval(input()))
    l = len(S)
    dp = [[0] * 13 for _ in range(l + 1)]
    dp[0][0] = 1
    for j in range(1, l + 1):
        if S[j - 1] == "?":
            for k in range(13):
                for q in range(10):
                    new_k = (k * 10 + q) % 13
                    dp[j][new_k] += dp[j - 1][k]
                    dp[j][new_k] %= mod
        else:
            n = int(S[j - 1])
            for k in range(13):
                new_k = (k * 10 + n) % 13
                dp[j][new_k] += dp[j - 1][k]
                dp[j][new_k] %= mod
    print((dp[l][5]))


if __name__ == "__main__":
    main()

import sys
import math
import bisect
import heapq
from collections import Counter


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


def main():
    mod = 10**9 + 7
    S = list(eval(input()))
    l = len(S)
    dp = [[0] * 13 for _ in range(l + 1)]
    dp[0][0] = 1
    for j in range(1, l + 1):
        if S[j - 1] == "?":
            for k in range(13):
                for q in range(10):
                    new_k = (k * 10 + q) % 13
                    dp[j][new_k] += dp[j - 1][k]
            for k in range(13):
                dp[j][k] %= mod
        else:
            n = int(S[j - 1])
            for k in range(13):
                new_k = (k * 10 + n) % 13
                dp[j][new_k] += dp[j - 1][k]
                dp[j][new_k] %= mod
    print((dp[l][5]))


if __name__ == "__main__":
    main()

-                    dp[j][new_k] %= mod +            for k in range(13): +                dp[j][k] %= mod