using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramD a = new ProgramD();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            int K = A + B;

            if (K % 2 == 0)
                Console.WriteLine(K / 2);
            else
                Console.WriteLine("IMPOSSIBLE");

        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] input_p = Console.ReadLine().Split(' ');
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
                p[i] = int.Parse(input_p[i]);

            int count = 0;

            for (int i = 0; i < n; i++)
            {
                if (p[i] != i + 1)
                    count++;
            }

            if (count == 2 || count == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }

    class ProgramC
    {
        public void main()
        {
            //入力
            string input = Console.ReadLine();
            int n = int.Parse(input);

            string[] input_a = Console.ReadLine().Split(' ');
            long[] a = new long[n + 1];
            for (int i = 0; i < n + 1; i++)
                a[i] = long.Parse(input_a[i]);

            string[] input_b = Console.ReadLine().Split(' ');
            long[] b = new long[n];
            for (int i = 0; i < n; i++)
                b[i] = long.Parse(input_b[i]);

            long count = 0;

            for (int i = 0; i < n; i++)
            {
                //二人を集計して比較、
                count += Math.Min(a[i] + a[i + 1], b[i]);
                //倒しきれない場合はa[i + 1]を0にして次へ
                if(a[i] <= b[i])
                    a[i + 1] = Math.Max(a[i + 1] - (b[i] - a[i]), 0);

            }

            //答え出力
            Console.WriteLine(count);
        }



    }
    
    class ProgramD
    {
        public void main()
        {
            //入力
            string s = Console.ReadLine();

            //桁DP
            long[,] dp = new long[s.Length, 13];
            long MOD = 1000000000 + 7;



            //DP（i桁目までを考えたときに余りを考える）
            for(int i = 0;i < s.Length;i++)
            {
                if(i == 0)
                {
                    if(s[0] == '?')
                    {
                        for (int j = 0; j < 10; j++)
                            dp[0, j] = 1;
                    }
                    else
                        dp[0, s[0] - '0'] = 1;

                    continue;
                }

                if(s[i] == '?')
                {
                    for (int l = 0; l < 10; l++)
                        for (int k = 0; k < 13; k++)
                        {
                            dp[i, (k * 10 + l) % 13] += dp[i - 1, k];
                            dp[i, (k * 10 + l) % 13] %= MOD;
                        }
                }
                else
                {
                    for (int k = 0; k < 13; k++)
                    {
                        dp[i, (k * 10 + (s[i] - '0')) % 13] += dp[i - 1, k];
                        dp[i, (k * 10 + (s[i] - '0')) % 13] %= MOD;

                    }
                }


            }
            
            Console.WriteLine(dp[s.Length - 1,5]);

        }
    }

    

    class ProgramE
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int[] a = new int[n];

            for (int i = 0; i < n; i++)
                a[i] = int.Parse(s[i]) - 1;

            for (int i = 0; i < n; i++)
            {
                int temp = a[a[i]];
                int count = 1;
                while (a[i] != temp)
                {
                    temp = a[temp];
                    count++;

                }

                Console.Write(count + " ");
            }
        }


    }

    
}




    

Measured memory_bytes: 21472