#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int N;
ll dp[100010][13];

int main() {
  int ans = 0;
  string s; cin >> s;
  N = s.size();
  dp[0][0] = 1;
  for(int i = 0; i < N; ++i) {
    int c;
    if(s[i] == '?') c = -1;
    else c = s[i] - '0';

    for(int j = 0; j < 10; j++) {
      if(c != -1 && c != 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;
  }
  ans = dp[N][5];

  cout << ans << endl;
  return 0;
}
