#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9+7;

int main(){
  string S;
  cin >> S;
  int n = S.size();
  vector<vector<long long>> dp(n+1,vector<long long>(13,0));
  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<=9; j++){
      if (c != -1 && c != j) continue;
      for (int k=0; k<13; k++){
        dp[i+1][(10*k+j)%13] += dp[i][k];
      }
    }
    for (int j=0; j<13; j++) dp[i+1][j] %= MOD;
  }
  cout << dp[n][5] << endl;
}
