#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
const int mod = 1e9+7;

ll dp[13] = {1};

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        ll temp[13] = {0};
        rep(j,13){
            if(s[i] != '?') temp[(j*10+s[i]-'0')%13] += dp[j];
            else rep(k,10) temp[(j*10+k)%13] += dp[j];
        }
        rep(j,13) dp[j] = temp[j] % mod;
    }
    printf("%lld\n", dp[5]);
}
