import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Data.Array

main = do
    s <- getLine
    let arr = array ((0,0),(12,9)) [((i,j), (i*10+j) `mod` 13)| i <- [0..12], j <- [0..9]]
    let f v c | c == '?' = VU.create $ do
                                vec <- VUM.replicate 13 (0 :: Int)
                                forM_ [0..12] $ \i -> do
                                    forM_ [0..9] $ \j -> do
                                        let a = v VU.! i
                                        VUM.modify vec (\b -> (a + b) `mod` 1000000007) (arr ! (i,j))
                                return vec
              | otherwise = VU.create $ do
                                vec <- VUM.replicate 13 (0 :: Int)
                                forM_ [0..12] $ \i -> do
                                    VUM.write vec (arr ! (i, digitToInt c)) (v VU.! i)
                                return vec
    let ans = foldl' f (VU.fromList (1 : replicate 12 0)) s
    print $ ans VU.! 5