import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    immutable int MD = 10 ^^ 9 + 7;
    
    auto s = readln.chomp.to!(dchar[]);
    
    s.reverse();
    
    debug { s.writeln; }
    
    int[] digs;
    foreach (i; 0 .. 10) { digs ~= i; }
    
    auto dp = new int[][] (s.length + 1, 13);
    dp[0][0] = 1;
    int mult = 1;
    foreach (i, c; s) {
        int[] toCheck;
        
        if (c == '?') {
            toCheck = digs;
        } else {
            int e = c - '0';
            toCheck ~= e;
        }
        
        foreach (d; toCheck) {
            int added = (d.to!long * mult) % 13;
            foreach (j; 0 .. 13) {
                dp[i+1][(j + added) % 13] = (dp[i+1][(j + added) % 13] + dp[i][j]) % MD;
            }
        }
        
        mult = (mult.to!long * 10) % 13;
    }
    
    debug { dp.each!writeln; }
    
    dp[s.length][5].writeln;
}