unittest
{
	assert( [ "??2??5" ].parse.expand.solve == 768 );
	assert( [ "?44" ].parse.expand.solve == 1 );
	assert( [ "7?4" ].parse.expand.solve == 0 );
	assert( [ "?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???" ].parse.expand.solve == 153716888 );
}



import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	const M = 13;
	
	auto dp = new long[ M ][ 1 + s.length ];
	dp[ 0 ][ 0 ] = 1;
	foreach_reverse( i, c; s )
	{
		auto d = s.length.signed - 1 - i.signed;
		if( c != '?' )
		{
			auto n = c - '0';
			auto m = n.mulMod!M( 10.memoize!( powMod!M )( d ) );
			foreach( mb; 0L .. M )
			{
				dp[ d + 1 ][ mb.addMod!M( m ) ] = dp[ d + 1 ][ mb.addMod!M( m ) ].addMod( dp[ d ][ mb ] );
			}
		}
		else
		{
			foreach( n; 0L .. 10L )
			{
				auto m = n.mulMod!M( 10.memoize!( powMod!M )( d ) );
				foreach( mb; 0L .. M )
				{
					dp[ d + 1 ][ mb.addMod!M( m ) ] = dp[ d + 1 ][ mb.addMod!M( m ) ].addMod( dp[ d ][ mb ] );
				}
			}
		}
	}
	return dp[ $ - 1 ][ 5 ];
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}
