#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

const ll MOD=1e9+7;

int main() {
  string s; cin>>s;
  int n=s.size();

  vector<vector<ll>> dp(100002, vector<ll>(13));
  dp[0][0]=1;
  rep(dgt, n) {
    rep(mo, 13) {
      if (s[dgt]=='?') {
        rep(nxt, 10) dp[dgt+1][(mo*10+nxt)%13]+=dp[dgt][mo];
      }
      else dp[dgt+1][(mo*10+s[dgt]-'0')%13]+=dp[dgt][mo];
    }
    rep(i, 13) dp[dgt+1][i]%=MOD;
  }
  printf("%llu\n", dp[n][5]);
  return 0;
}
