v = gets.chomp
size = v.size
max = 10 ** size - 1
regexp = /#{v.gsub(??, "\\d")}/

count = 0
(1..max).each do |x|
  if x % 13 == 5 && regexp =~ (x.to_s.rjust(size, ?0))
    count += 1
  end
end

puts count % (10 ** 9 + 7)
