#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

string s;
int bs=1, M=1e9+7, d[100005][15]={1};
int main() {
	int i, j, k, t;
	cin>>s;
	reverse(s.begin(), s.end());
	for(i=1; i<=s.size(); i++) {
		if(s[i-1] != '?') {
			t = (s[i-1] - '0') * bs % 13;
			for(j=0; j<13; j++) d[i][(j+t)%13] = (d[i][(j+t)%13] + d[i-1][j]) % M;
		} else {
			for(k=0; k<10; k++) {
				t = k * bs % 13;
				for(j=0; j<13; j++) d[i][(j+t)%13] = (d[i][(j+t)%13] + d[i-1][j]) % M;
			}
		}
		bs = (bs * 10) % 13;
	}
	cout<<d[s.size()][5];
	return 0;
}