import std.stdio;
import std.conv;
import std.string;
import std.array;

void main()
{
    ulong D = 1000000007;

    string S = readln.chomp;

    ulong[] b_mod = new ulong[13];
    b_mod[0] = 1;
    ulong[] c_mod;
    foreach (char c; S){
        c_mod = new ulong[13];

        for (int i = 0; i < 13; i++){
            if (c != '?'){
                int c_n = c - '0';
                int m = (i * 10 + c_n) % 13;
                c_mod[m] += b_mod[i];

                c_mod[m] %= D;
            } else {
                for (int j = 0; j < 10; j++){
                    int m = (i * 10 + j) % 13;
                    c_mod[m] += b_mod[i];

                    c_mod[m] %= D;
                }
            }
        }

        for (int i = 0; i < 13; i++) b_mod[i] = c_mod[i];
    }

    writeln(c_mod[5]);
}

