import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

void chmin(T)(ref T a, in T b) { if (a > b) a = b; }

void madd(T)(ref T a, in T x) { a += x; a %= MOD; }

int calc(string s) {
    auto dp = new int[][](s.length + 1, 13);
    // dp[i][j]
    // i : i 桁目までみた
    // j : 13 で割った余

    dp[0][0] = 1;
    for (int i = 0; i < s.length; i++) { // i 桁目
        for (int j = 0; j < 13; j++) { // 余り
            foreach (k; s[i] == '?' ? iota(0, 10) : iota(s[i]-'0', s[i]-'0'+1)) {
                // dp[i + 1][(10 * j + k) % 13] += dp[i][j];
                // dp[i + 1][(10 * j + k) % 13] %= MOD;

                madd(dp[i + 1][(10 * j + k) % 13], dp[i][j]);
            }
        }
    }
    return dp[s.length][5];
}

void main() {
    string s = read!string;
    writeln(calc(s));
}
