/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
??2??5
---+/
/+---test
?44
---+/
/+---test
7?4
---+/
/+---test
?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???
---+/

void main(string[] args) {
  const S = readln.chomp;

  auto dp = new long[13][S.length+1];
  dp[0][0] = 1;

  foreach (i; 1..S.length+1) {
    const long x = S[i-1] == '?'? -1: S[i-1]-'0';

    foreach (j; 0..10) {
      if (x != -1 && x != j) continue;

      foreach (ki; 0..13) {
        dp[i][(ki*10 + j)%13] += dp[i-1][ki];
      }
    }
    foreach (j; 0..13) dp[i][j] %= 1000000007;
  }
  dp[$-1][5].writeln;
}
