import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

int M = 1000000007;

int[] tbl = [ 1, 10, 9, 12, 3, 4 ];

void main() {
  string S = readln.chomp;
  auto N = S.length;

  ulong[] items = new ulong[0];
  int baseMod13 = 0;
  foreach(i; 0..N) {
    char c = S[$-1-i];
    if(c == '?') items ~= i % 6;
    c = c != '?' ? c : '0';
    baseMod13 += (tbl[i % 6]*(c - '0')) % 13;
  }
  baseMod13 %= 13;

  int mod13 = ((13+5) - baseMod13) % 13;
  ulong[13][] dp = new ulong[13][items.length];
  if (dp.length == 0) {
    writeln(baseMod13 == 5 ? 1 : 0);
    return;
  }
  foreach(i; 0..10) {
    int mod = (tbl[items[0]] * i)%13;
    dp[0][mod]++;
  }
  foreach(i; 1..dp.length) {
    foreach(j; 0..13) {
      ulong m = 0;
      foreach(k; 0..10) {
        int mod = (tbl[items[i]] * k) % 13;
        int diff = ((13+j) - mod) % 13;
        m = (m + dp[i-1][diff]) % M;
      }
      dp[i][j] = m % M;
    }
  }
  dp[$-1][mod13].writeln;
}
