#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define REV(x) (reverse(x.begin(),x.end())) //reverse
const ll MOD=1e9+7;

int main(){
	string s;
	cin>>s;
	REV(s);
	ll dp[13]={};
	dp[0]=1;
	ll ten=1;
	for(char x:s){
		vector<ll> dp2(13,0);
		FOR(j,0,10){
			ll add = ten*j%13;
			if(x=='?'||(j==(x-'0')))
				FOR(i,0,13)
					(dp2[(add+i)%13]+=dp[i])%=MOD;
		}
		FOR(i,0,13)dp[i]=dp2[i];
		(ten*=10)%=13;
	}
	cout << dp[5] << endl;
}