import std.stdio, std.string, std.conv;

void main() {
    string s = readln.chomp;
    long mod = 1_000_000_007;
    long[][] dp = new long[][](100001, 13);
    dp[0][0] = 1;
    foreach (i, x; s) {
        if (x == '?') {
            foreach (j; 0 .. 13) {
                foreach (k; 0 .. 10) {
                    dp[i+1][(10*j+k)%13] = (dp[i+1][(j*10+k)%13] + dp[i][j]) % mod;
                }
            }
        } else {
            foreach (j; 0 .. 13) {
                dp[i+1][(10*j+(x-'0'))%13] = (dp[i+1][(10*j+(x-'0'))%13] + dp[i][j]) % mod;
            }
        }
    }
    dp[s.length][5].writeln;
}