#include <bits/stdc++.h>

#define MOD 1000000007

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> a(13, 0);
	a[0] = 1;
	for (int i = 0; i < s.size(); i++) {
		int k = s[i] - '0';
		vector<int> b(13, 0);
		if (k < 10) {
			for (int j = 0; j < 13; j++) {
				int t = (j * 10 + k) % 13;
				b[t] = (b[t] + a[j]) % MOD;
			}
		} else {
			for (int j = 0; j < 13; j++) {
				for (k = 0; k < 10; k++) {
					int t = (j * 10 + k) % 13;
					b[t] = (b[t] + a[j]) % MOD;
				}
			}
		}
		a = b;
	}
	cout << a[5] << endl;
	return 0;
}