#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int md = 1e9+7;
long long dp[13] = {1};
string s;
int main(){
	cin >> s;
	rep(i,s.size()){
		long long temp[13] = {};
		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] % md;
	}
	printf("%lld\n", dp[5]);
}