#include <iostream>
#include <string>
using namespace std;
const int len = 1e5 + 10;
const long long mod = 1e9 + 7;
long long dp[len][14];
int main()
{
	string s;
	cin >> s;
	int len = s.length(), cur;
	dp[0][0] = 1;
	for (int i = 0; i < len; i++) {
		if (s[i] == '?') cur = -1;
		else cur = s[i] - '0';
		for (int j = 0; j < 10; j++) {
			if (cur != -1 && cur != j) continue;
			for (int k = 0; k < 13; k++) {
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
		for (int j = 0; j < 13; j++) {
			dp[i + 1][j] %= mod;
		}
	}
	cout << dp[len][5];
}
