local mod = 1000000007
local mfl = math.floor

local s = io.read()
local n = #s
local t = {}
for i = 1, n do
  t[i] = {}
  for j = 0, 12 do
    t[i][j] = 0
  end
end
local sstr = s:sub(1, 1)
if sstr == "?" then
  for i = 0, 9 do
    t[1][i] = 1
  end
else
  t[1][tonumber(sstr)] = 1
end

local jumptbl = {0, 10, 7, 4, 1, 11, 8, 5, 2, 12, 9, 6, 3}

for i = 2, n do
  -- times 10
  local tmp = {}
  for j = 0, 12 do
    tmp[jumptbl[j + 1]] = t[i - 1][j]
  end
  for j = 0, 12 do
    t[i - 1][j] = tmp[j]
  end
  -- add
  sstr = s:sub(i, i)
  if sstr == "?" then
    for num = 0, 9 do
      for j = 0, 12 do
        t[i][(j + num) % 13] = (t[i][(j + num) % 13] + t[i - 1][j]) % 1000000007
      end
    end
  else
    local num = tonumber(sstr)
    for j = 0, 12 do
      t[i][(j + num) % 13] = t[i - 1][j]
    end
  end
end
print(t[n][5])
