program digits_parade
  implicit none
  integer(8), parameter :: md = 1000000007_8
  character(100000) :: s
  integer :: n, i, j, k
  integer(8) :: dp(0:100000,0:12) = 0_8
  read(*,*) s
  s = trim(adjustl(s))
  n = len_trim(s)
  dp(0,0) = 1_8
  do i = 1, n
    if (s(i:i) == "?") then
      do k = 0, 9
        do j = 0, 12
          dp(i,mod(10*j+k,13)) = mod(dp(i,mod(10*j+k,13))+dp(i-1,j),md)
        end do
      end do
    else
      k = ichar(s(i:i))-48
      do j = 0, 12
        dp(i,mod(10*j+k,13)) = dp(i-1,j)
      end do
    end if
  end do
  write(*,'(i0)') dp(n,5)
  stop
end program digits_parade