S=gets.strip
N=S.size
MOD=10**9+7
dp=Array.new(N){Array.new(13,0)}

for i in 0..N-2
    for j in 0..12
        if i==0
            if (S[i]=="?" && j<10) || S[i].to_i==j
                dp[i][j]=1
            end
        end
        if S[i+1]=="?"
            for k in 0..9
                dp[i+1][(j*10+k)%13]+=dp[i][j]
                dp[i+1][(j*10+k)%13]%=MOD
            end
        else
            dp[i+1][(j*10+S[i+1].to_i)%13]+=dp[i][j]
            dp[i+1][(j*10+S[i+1].to_i)%13]%=MOD
        end
    end
end
puts dp[N-1][5]% MOD
