#include <bits/stdc++.h>

using namespace std;
const int N = 1e5+5;
const int MOD = 1e9+7;
long long dp[N][15];
int main()
{
    string s;
    cin >> s;
    int n = s.length();
    if (s[0] == '?')
        for (int i = 0; i<10; i++)
            dp[0][i] = 1;
    else
        dp[0][s[0]-'0'] = 1;
    for (int i = 1; i<n; i++)
    {
        if (s[i] == '?')
        {
            for (int j = 0; j<10; j++)
                for (int k = 0; k<13; k++)
                {
                    dp[i][((k*10)+j)%13]+=dp[i-1][k];
                    dp[i][((k*10)+j)%13]%=MOD;
                }
        }
        else
        {
            for (int k = 0; k<13; k++)
            {
                dp[i][((k*10)+(s[i]-'0'))%13]+=dp[i-1][k];
                dp[i][((k*10)+(s[i]-'0'))%13]%=MOD;
            }
        }
    }
    cout << dp[n-1][5];
}
