let m = 1000000007
let ( +^ ) x y = (x + y) mod m

let () =
  let s = read_line () in
  let dp = Array.make_matrix (String.length s + 1) 13 0 in
  dp.(0).(0) <- 1;
  String.iteri (fun i ->
    let go n =
      for j = 0 to 12 do
        dp.(i + 1).((10 * j + n) mod 13) <-
          dp.(i + 1).((10 * j + n) mod 13) +^ dp.(i).(j)
      done in
    function
      | '?' ->
          for i = 0 to 9 do
            go i
          done
      | c -> go (int_of_char c - int_of_char '0')) s;
  Printf.printf "%d\n" dp.(String.length s).(5)
