// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



using i32 = std::int_fast32_t;

using i64 = std::int_fast64_t;

template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;



#define REP(i, stop) FOR(i, 0, stop)

#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

#define RREP(i, n) for (int i = n; i-- > 0;)

#define ALL(v) (v).begin(), (v).end()

#define RALL(v) (v).rbegin(), (v).rend()

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }



template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }

template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }



void LOG(const int& x) { cerr << x << "\n"; }

template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }

template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }

template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }



i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }

i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }

i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }

i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }

i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }

i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }

i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }



struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;



i64 dp[100010][13];

i64 q[6][10] = {

  {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},

  {0, 10, 7, 4, 1, 11, 8, 5, 2, 12},

  {0, 9, 5, 1, 10, 6, 2, 11, 7, 3},

  {0, 12, 11, 10, 9, 8, 7, 6, 5, 4},

  {0, 3, 6, 9, 12, 2, 5, 8, 11, 1},

  {0, 4, 8, 12, 3, 7, 11, 2, 6, 10},

};



const i64 M = 1000000007;

signed main() {

  string S;

  cin >> S;

  i64 k = 0;

  dp[0][0] = 1;

  RREP(i, S.size()) {

    char c = S[i];

    if (c == '?') {

      REP(j, 10) {

        REP(r, 13) {

          (dp[k + 1][(r + q[k % 6][j]) % 13] += dp[k][r]) %= M;

        }

      }

    } else {

      i64 d = c - '0';

      REP(r, 13) {

        (dp[k + 1][(r + q[k % 6][d]) % 13] += dp[k][r]) %= M;

      }

    }

    k += 1;

  }

  cout << dp[k][5] << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.45887042820652x):
#include <cstdio>

#include <utility>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)



i64 D[13];

i64 E[13];

const i64 M = 1000000007;

signed main() {

	D[0] = 1;

	while(true) {

		char c = getchar();

		if (c == '\n') {

			break;

		} else if (c == '?') {

			REP(r, 13) {

				i64 s = 0;

				REP(j, 10) {

					s += D[(j - r + 13) * 9 % 13];

				}

				E[r] = s % M;

			}

		} else {

			i64 d = c - '0';

			REP(r, 13) {

				i64 s = D[(d - r + 13) * 9 % 13];

				E[r] = s % M;

			}

		}

		swap(D, E);

	}

	printf("%d", D[5]);

}