#include <iostream>
#include <string>
#include <vector>
using namespace std;
long long MOD = 1000000007;
int main()
{
  string S;
  cin >> S;
  vector<long long> count(13, 0LL);
  count[0] = 1LL;
  for (auto c : S)
  {
    vector<long long> nextgen(13, 0LL);
    for (int digit = 0; digit < 10; digit++)
    {
      if (c == '?' || c == digit + '0')
        for (int i = 0; i < 13; i++)
        {
          int next = (i * 10 + digit) % 13;
          nextgen[next] += count[i];
          nextgen[next] %= MOD;
        }
    }
    count = nextgen;
  }
  cout << count[5] << endl;
}