Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there. 

The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.

And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:

  if s_{i} = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);  if s_{i} is a digit (between 0 to 9, inclusively), then it means that there is digit s_{i} on position i in code;  if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.  The length of the safe code coincides with the length of the hint. 

For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".

After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.

At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...


-----Input-----

The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.

The input limits for scoring 30 points are (subproblem A1):   1 ≤ |s| ≤ 5. 

The input limits for scoring 100 points are (subproblems A1+A2):   1 ≤ |s| ≤ 10^5. 

Here |s| means the length of string s.


-----Output-----

Print the number of codes that match the given hint.


-----Examples-----
Input
AJ

Output
81

Input
1?AA

Output
100

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
letters = set(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'])

def check(s, i):
	tested_s = str(i)
	(used_letters, used_digits) = (dict(), dict())
	for (ch, tested_ch) in zip(s, tested_s):
		if ch == '?':
			continue
		if ch in letters:
			if ch in used_letters:
				if used_letters[ch] != tested_ch:
					return False
			elif tested_ch in used_digits:
				if used_digits[tested_ch] != ch:
					return False
			else:
				used_letters[ch] = tested_ch
				used_digits[tested_ch] = ch
			continue
		if ch != tested_ch:
			return False
	return True

def __starting_point():
	s = input()
	count = 0
	for i in range(10 ** (len(s) - 1), 10 ** len(s)):
		if check(s, i):
			count += 1
	print(count)
__starting_point()


s = input()
num = [str(i) for i in range(10)]
any = 0
alpha = []
for i in s:
	if i == '?':
		any += 1
	elif i not in num and (not i in alpha):
		alpha.append(i)
result = 1
if s[0] in num:
	c = 10
	while alpha != []:
		result *= c
		alpha.pop()
		c -= 1
	result *= 10 ** any
	print(result)
elif s[0] != '?':
	result *= 9
	alpha.pop()
	c = 9
	while alpha != []:
		result *= c
		alpha.pop()
		c -= 1
	result *= 10 ** any
	print(result)
else:
	c = 10
	result *= 9
	while alpha != []:
		result *= c
		alpha.pop()
		c -= 1
	result *= 10 ** (any - 1)
	print(result)


s = input()
abc = [0] * 26
cnt1 = 0
ans = 1
for i in range(len(s)):
	if s[i] == '?':
		if i == 0:
			ans *= 9
		else:
			ans *= 10
	elif s[i] >= 'A' and s[i] <= 'Z':
		if abc[ord(s[i]) - ord('A')] == 0:
			if i == 0:
				abc[ord(s[i]) - ord('A')] = 1
				ans *= 9
				cnt1 += 1
			else:
				abc[ord(s[i]) - ord('A')] = 1
				ans *= 10 - cnt1
				cnt1 += 1
print(ans)


res = 1
started = False
seen = set()
codes = set(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'])
zeroes = 0
for ch in input():
	if ch == '?':
		if started:
			zeroes += 1
		else:
			res *= 9
	elif ch in codes and ch not in seen:
		if not started:
			res *= len(codes) - len(seen) - 1
		else:
			res *= len(codes) - len(seen)
		seen.add(ch)
	started = True
print(res, '0' * zeroes, sep='')


s = input()
si = len(s)
res = 1
seen = {}
Len = 0
if '0' <= s[0] <= '9':
	pass
elif s[0] == '?':
	res *= 9
else:
	res *= 9
	seen[s[0]] = 1
	Len += 1
tmp = ''
for i in range(1, si):
	if '0' <= s[i] <= '9':
		pass
	elif s[i] != '?':
		if seen.get(s[i], 0) == 0:
			res *= 10 - Len
			seen[s[i]] = 1
			Len += 1
		else:
			pass
	else:
		tmp += '0'
print(res, tmp, sep='')


s = input()
ans = 1
table = [0] * 26
for c in s:
	if c == '?':
		ans *= 10
	elif 'A' <= c <= 'J':
		table[ord(c) - ord('A')] += 1
total = 0
for c in range(26):
	if table[c]:
		total += 1
for i in range(total):
	ans *= 10 - i
if 'A' <= s[0] <= 'J':
	ans = ans // 10 * 9
if s[0] == '?':
	ans = ans // 10 * 9
print(ans)


from sys import *
from math import *
s = stdin.readline().strip()
ans = 1
now = 10
was = {}
was['A'] = False
was['B'] = False
was['C'] = False
was['D'] = False
was['E'] = False
was['F'] = False
was['G'] = False
was['H'] = False
was['I'] = False
was['J'] = False
if s[0] == '?':
	ans *= 9
if ord(s[0]) >= ord('A') and ord(s[0]) <= ord('J'):
	ans *= 9
	was[s[0]] = True
	now = 9
cnt = 0
for i in range(1, len(s)):
	if s[i] == '?':
		cnt += 1
	if ord(s[i]) >= ord('A') and ord(s[i]) <= ord('J'):
		if was[s[i]] == False:
			ans *= now
			now -= 1
		was[s[i]] = True
print(ans, end='')
for i in range(cnt):
	print('0', end='')
print()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x) + '\n')
s = get_string()
alpha = list('ABCDEFGHIJ')
visited = []
al = 10
if s[0] == '?':
	count = 9
elif s[0] in alpha:
	count = 9
	al = 9
	visited.append(s[0])
else:
	count = 1
for i in range(1, len(s)):
	if s[i] == '?':
		count = count * 10
	elif s[i] in alpha and s[i] not in visited:
		count = count * al
		al -= 1
		visited.append(s[i])
print(count)


import math
import string
s = input()
pr = set()
ans = 0
for x in s:
	if ord('A') <= ord(x) <= ord('J'):
		pr.add(x)
pr = len(pr)
r = s.count('?')
if s[0] == '?':
	ans = 9 * math.factorial(10) // math.factorial(10 - pr)
	print(str(ans) + '0' * (r - 1))
elif s[0] in string.ascii_uppercase:
	ans = 9 * math.factorial(9) // math.factorial(9 - pr + 1)
	print(str(ans) + '0' * r)
else:
	ans = math.factorial(10) // math.factorial(10 - pr)
	print(str(ans) + '0' * r)


def readln():
	return tuple(map(int, input().split()))
ans = 1
cnt = set()
qcnt = 0
for (i, c) in enumerate(list(input())):
	if c == '?':
		if i == 0:
			ans *= 9
		else:
			qcnt += 1
	elif c.isalpha() and c not in cnt:
		ans *= 10 - len(cnt) - (i == 0)
		cnt.add(c)
print(str(ans) + '0' * qcnt)


s = input()
x = set()
f = False
r = 1
letter = set([c for c in 'ABCDEFGHIJ'])
if s[0] == '?':
	r *= 9
if s[0] in letter:
	x.add(s[0])
	f = True
for c in s[1:]:
	if c == '?':
		r *= 10
	if c in letter:
		x.add(c)
for t in range(len(x)):
	if t == 0 and f:
		r *= 9
	else:
		r *= 10 - t
print(r)


hint = input()
possibilities = 1
zeroes = 0
letters = 'ABCDEFGHIJ'
if hint[0] in letters:
	possibilities *= 9
	i = letters.index(hint[0])
	letters = letters[:i] + letters[i + 1:]
if hint[0] == '?':
	possibilities *= 9
hint = hint[1:]
for char in hint:
	if char == '?':
		zeroes += 1
	elif char in letters:
		possibilities *= len(letters)
		i = letters.index(char)
		letters = letters[:i] + letters[i + 1:]
print(str(possibilities) + '0' * zeroes)


from math import factorial as fact

def main():
	hint = input()
	hint_nodigits = [h for h in hint if not h.isdigit()]
	letters = [h for h in hint_nodigits if h != '?']
	combs_letters = fact(10) // fact(10 - len(set(letters)))
	combs_jolly = 10 ** (len(hint_nodigits) - len(letters))
	if hint[0] == '?':
		combs_jolly = combs_jolly // 10 * 9
	elif hint[0].isalpha():
		combs_letters = combs_letters // 10 * 9
	print(combs_letters * combs_jolly)
main()


s = input()
ans = 1
rem = 10
occured = {}
for x in range(len(s)):
	if s[x] in 'ABCDEFGHIJ':
		if x == 0:
			ans *= 9
			rem = 9
		elif s[x] in occured:
			pass
		else:
			ans *= rem
			rem -= 1
		occured[s[x]] = 1
	elif s[x] == '?':
		if x == 0:
			ans *= 9
		else:
			ans *= 10
print(ans)


s = input()
res = 1
mapa = {}
if s[0] == '?':
	res *= 9
elif s[0].isalpha():
	res *= 9
	mapa[s[0]] = 1
for i in s[1:]:
	if i == '?':
		res *= 10
	elif i.isalpha() and i not in mapa:
		res *= 10 - len(mapa)
		mapa[i] = 1
print(res)


s = input()
G = 'ABCDEFGHIJ'
d = 0
g = dict()
for i in s:
	if i in G:
		g[i] = 1
	if i == '?':
		d += 1
if d >= 1:
	A = 10
	d = d - 1
else:
	A = 1
g = len(g)
for i in range(10, 10 - g, -1):
	A *= i
if s[0] in G or s[0] == '?':
	A *= 9
	A //= 10
print(str(A) + '0' * d)


s = input()
n = len(s)
was = [0, 0, 0, 0, 0]
ans = 1
cnt = 10
k = []
e = set(k)
for i in range(n):
	if s[i] >= 'A' and s[i] <= 'J' and (s[i] not in e):
		e.add(s[i])
		ans *= cnt
		cnt -= 1
	elif s[i] == '?':
		ans *= 10
if s[0] >= 'A' and s[0] <= 'J':
	ans = ans // 10 * 9
if s[0] == '?':
	ans = ans // 10 * 9
print(ans)


s = input()
z = set()
us = 0
ans = 1
if s[0] == '?' or (s[0] >= 'A' and s[0] <= 'J'):
	ans = 9
	z.add(s[0])
	if s[0] >= 'A' and s[0] <= 'J':
		us += 1
i = -1
for x in s:
	i += 1
	if i == 0:
		continue
	if x == '?':
		ans *= 10
	if x >= 'A' and x <= 'J':
		if x not in z:
			ans *= 10 - us
			z.add(x)
			us += 1
print(ans)


letras = [0 for i in range(10)]
s = input()
res = 1
for c in range(len(s)):
	if s[c] == '?':
		if c == 0:
			res *= 9
		else:
			res *= 10
	if s[c].isalpha():
		letras[ord(s[c]) - 65] += 1
cont = 10
lenovo = []
for i in range(10):
	if letras[i] != 0:
		lenovo.append(letras[i])
for i in range(len(lenovo)):
	if s[0].isalpha() and i == 0:
		cont -= 1
		res *= 9
	else:
		res *= cont
		cont -= 1
print(res)


import math
s = input()
ques = s[1:].count('?')
d = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'H': 0, 'I': 0, 'J': 0}
digit = set([str(i) for i in range(0, 10)])
digit.add('?')
ans = 1
ans *= pow(10, ques)
count = 0
for i in range(1, len(s)):
	if s[i] not in digit and d[s[i]] == 0:
		count += 1
		d[s[i]] = 1
start = 10
if s[0] in d and d[s[0]] == 1:
	count -= 1
	ans *= 9
	start = 9
if s[0] in d and d[s[0]] == 0:
	ans *= 9
	start = 9
while count != 0:
	ans *= start
	start -= 1
	count -= 1
if s[0] == '?':
	ans *= 9
print(ans)


import math
import string
s = input()
pr = 0
for x in string.ascii_uppercase[:10]:
	if x in s:
		pr += 1
ans = 0
r = s.count('?')
if s[0] == '?':
	ans = 9 * pow(10, r - 1) * math.factorial(10) // math.factorial(10 - pr)
elif s[0] in string.ascii_uppercase:
	ans = 9 * pow(10, r) * math.factorial(9) // math.factorial(9 - pr + 1)
else:
	ans = pow(10, r) * math.factorial(10) // math.factorial(10 - pr)
print(ans)


I = input()
s = set()
r = 0
for x in I:
	if x == '?':
		r += 1
	if ord(x) > 64:
		s.add(x)
r = 10 ** r
i = 10
for _ in s:
	r *= i
	i -= 1
if ord(I[0]) > 57:
	r = r // 10 * 9
print(r)


s = input()
ans = 1
x = 0
z = 'ABCDEFGHIJ'
L = {}
for item in z:
	L[item] = False
n = len(s)
for i in range(n):
	if s[i] in 'ABCDEFGHIJ' and i == 0:
		ans *= 9
		x += 1
		L[s[i]] = True
	elif s[i] in 'ABCDEFGHIJ' and (not L[s[i]]):
		ans *= 10 - x
		x += 1
		L[s[i]] = True
	elif s[i] == '?' and i == 0:
		ans *= 9
	elif s[i] == '?':
		ans *= 10
print(ans)


s = str(input())
result = 1
n = len(s)
rozne = set()
pytajniki = 0
mnoznik_z_pierwszego = 1
for i in range(0, n):
	if ord(s[i]) >= ord('0') and ord(s[i]) <= ord('9'):
		continue
	elif ord(s[i]) >= ord('A') and ord(s[i]) <= ord('Z'):
		rozne.add(ord(s[i]))
		continue
	elif i == 0:
		mnoznik_z_pierwszego = 9
	else:
		pytajniki = pytajniki + 1
for i in range(0, len(rozne)):
	result = result * (10 - i)
result = result * mnoznik_z_pierwszego
if ord(s[0]) >= ord('A') and ord(s[0]) <= ord('Z'):
	result = result / 10 * 9
print(int(result), end='')
for i in range(pytajniki):
	print('0', end='')
print()


__author__ = 'Karolis'
s = input()
total = 1
was = []
have = 10
for i in range(len(s)):
	if s[i] == '?':
		if i == 0:
			total *= 9
		else:
			total *= 10
	elif s[i] >= 'A' and s[i] <= 'J' and (was.count(s[i]) == 0):
		was.append(s[i])
		if i == 0:
			total *= 9
		else:
			total *= have
		have -= 1
print(total)


input_str = input()
tmp = []
if input_str[0] == '?':
	result = 9
	a = 11
	for c in input_str[1:]:
		if c == '?':
			result *= 10
		elif 'A' <= c <= 'J' and tmp.count(c) == 0:
			tmp.append(c)
			a -= 1
			result *= a
elif 'A' <= input_str[0] <= 'J':
	tmp.append(input_str[0])
	result = 9
	a = 10
	for c in input_str[1:]:
		if c == '?':
			result *= 10
		elif 'A' <= c <= 'J' and tmp.count(c) == 0:
			tmp.append(c)
			a -= 1
			result *= a
else:
	a = 11
	result = 1
	for c in input_str[1:]:
		if c == '?':
			result *= 10
		elif 'A' <= c <= 'J' and tmp.count(c) == 0:
			tmp.append(c)
			a -= 1
			result *= a
print(result)


def main():
	s = input()
	l = []
	i = 1
	result = 1
	for i in range(len(s)):
		if s[i:i + 1] == '?':
			if i == 0:
				result = result * 9
			else:
				result = result * 10
		if s[i:i + 1] >= 'A' and s[i:i + 1] <= 'J':
			if i == 0:
				result = result * 9
				l.append(s[i:i + 1])
			elif l.count(s[i:i + 1]) == 0:
				result = result * (10 - len(l))
				l.append(s[i:i + 1])
	print(result)

def __starting_point():
	main()
__starting_point()


import sys
s = input()
use = [0] * 30
diff = 0
for i in s:
	c = ord(i) - ord('A')
	if 0 <= c and c <= 25:
		use[c] = True
for i in range(0, 30):
	if use[i]:
		diff += 1
ans = 1
for i in range(10, 10 - diff, -1):
	if i == 10 and (ord('A') <= ord(s[0]) and ord(s[0]) <= ord('Z')):
		ans *= 9
	else:
		ans *= i
j = 0
for i in s:
	if i == '?':
		if j == 0:
			ans *= 9
		else:
			ans *= 10
	j += 1
print(ans)


s = input()
ans = 1
m = set()
k = 0
for c in s:
	if 'A' <= c and c <= 'J':
		m.add(c)
for c in s:
	if c == '?':
		k = k + 1
n = len(m)
if s[0] == '?':
	ans = 9
	k = k - 1
if s[0] in m:
	ans = 9
	for i in range(n - 1):
		ans = ans * (9 - i)
else:
	for i in range(n):
		ans = ans * (10 - i)
print(str(ans) + k * '0')


S = input()
chSet = set()
numQ = 0
for s in S:
	if ord(s) >= 65 and ord(s) <= 74:
		chSet.add(s)
	elif s == '?':
		numQ += 1
if len(chSet) != 0:
	cur = 1
	for i in range(10, max(10 - len(chSet), 0), -1):
		cur *= i
	if S[0] not in chSet and S[0] != '?':
		print(cur * pow(10, numQ))
	else:
		ans = cur * pow(10, numQ) * 9 // 10
		print(ans)
elif S[0] != '?':
	print(pow(10, numQ))
else:
	print(pow(10, numQ) * 9 // 10)


(MySet, X, SUM) = (set(), input(), 1)
Num = 10
if not X[0].isnumeric():
	SUM *= 9
	if X[0] != '?':
		MySet.add(X[0])
		Num -= 1
for i in range(1, len(X)):
	if not X[i].isnumeric():
		if X[i] != '?' and X[i] not in MySet:
			MySet.add(X[i])
			SUM *= Num
			Num -= 1
		elif X[i] == '?':
			SUM *= 10
print(SUM)


s = input()
ans = 1
used = [False] * 10
fl = False
for i in range(len(s)):
	c = s[i]
	if c == '?':
		ans *= 10 if i else 9
		continue
	x = ord(c)
	if ord('0') <= x <= ord('9'):
		continue
	used[x - ord('A')] = True
	if i == 0:
		fl = True
cur = 10
for b in used:
	if b:
		ans *= cur
		cur -= 1
if fl:
	ans //= 10
	ans *= 9
print(ans)


hint = input()
seen = []
num = 1
if 'A' <= hint[0] <= 'J':
	num = 9
	seen = [hint[0]]
elif '0' <= hint[0] <= '9':
	num = 1
elif hint[0] == '?':
	num = 9
for l in hint[1:]:
	if 'A' <= l <= 'J':
		if l not in seen:
			num *= 10 - len(seen)
			seen.append(l)
	elif l == '?':
		num *= 10
print(num)


import math
s = input()
d = {'?': 5, '1': 5, '2': 5, '3': 5, '4': 5, '5': 5, '6': 5, '7': 5, '8': 5, '9': 5, '0': 5, 'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'H': 0, 'I': 0, 'J': 0}
digit = set([str(i) for i in range(0, 10)])
digit.add('?')
ans = 1
count = 0
for i in range(1, len(s)):
	if d[s[i]] == 0:
		count += 1
		d[s[i]] = 1
	elif s[i] == '?':
		d[s[i]] += 1
ans *= pow(10, d['?'] - 5)
start = 10
if d[s[0]] == 1:
	count -= 1
	ans *= 9
	start = 9
if d[s[0]] == 0:
	ans *= 9
	start = 9
while count != 0:
	ans *= start
	start -= 1
	count -= 1
if s[0] == '?':
	ans *= 9
print(ans)


def is_digit(ch):
	return ord('0') <= ord(ch) <= ord('9')

def is_letter(ch):
	return ord('A') <= ord(ch) <= ord('J')
s = input()
used_letters = set()
if is_digit(s[0]):
	count = 1
elif is_letter(s[0]):
	count = 9
	used_letters.add(s[0])
elif s[0] == '?':
	count = 9
zeroes_count = 0
for (i, ch) in enumerate(s[1:]):
	if ch == '?':
		zeroes_count += 1
	elif is_letter(ch) and ch not in used_letters:
		count *= 10 - len(used_letters)
		used_letters.add(ch)
print(str(count) + '0' * zeroes_count)


from math import factorial
string = input()
leading_character = string[0]
letters = set()
question_marks = 0
for character in string:
	if character.isalpha():
		letters.add(character)
	elif character == '?':
		question_marks += 1
solution = 0
if leading_character.isalpha():
	number_of_non_leading_letters = len(letters) - 1
	print(str(9 * factorial(9) // factorial(9 - number_of_non_leading_letters)) + '0' * question_marks)
elif leading_character.isdigit():
	print(str(factorial(10) // factorial(10 - len(letters))) + '0' * question_marks)
else:
	print(str(9 * factorial(10) // factorial(10 - len(letters))) + '0' * (question_marks - 1))


from math import factorial

def nchk(n, k):
	ans = 1
	for i in range(n - k + 1, n + 1):
		ans = ans * i
	return ans / factorial(k)

def ml(s, k):
	ans = 1
	for i in range(k):
		ans = ans * s
		s = s - 1
	return ans
str = input()
lset = set()
qc = 0
for c in str:
	if c <= 'J' and c >= 'A':
		lset.add(c)
	elif c == '?':
		qc = qc + 1
lc = len(lset)
ans = 0
if str[0] == '?':
	ans = 9
	qc = qc - 1
	ans = ans * 10 ** qc
	ans = ans * ml(10, lc) * 1
elif str[0] > '?':
	ans = 9
	lc = lc - 1
	ans = ans * 10 ** qc
	ans = ans * ml(9, lc) * 1
else:
	ans = 1
	ans = ans * 10 ** qc
	ans = ans * ml(10, lc) * 1
print(ans)


s = input()
letters = set()
answer = 1
for ch in s:
	if ch == '?':
		answer *= 10
	elif ch >= 'A':
		letters.add(ord(ch))
temp = 10
for i in range(len(letters)):
	answer *= temp
	temp -= 1
if s[0] == '?' or s[0] >= 'A':
	answer = answer // 10 * 9
print(answer)


ans = 1
n = 10
j = 9
d = set()
for i in input():
	if i == '?':
		ans *= min(10, j)
	elif i.isalpha() and i not in d:
		d.add(i)
		ans *= min(n, j)
		n -= 1
	j = 10
print(ans)


a = input()
s = set()
for x in a:
	if ord(x) > 64:
		s |= {x}
r = 10 ** a.count('?')
for i in range(len(s)):
	r *= 10 - i
if ord(a[0]) > 57:
	r = r // 10 * 9
print(r)


from functools import reduce
from operator import mul
s = input()
A = [10] * s.count('?') + [10 - i for i in range(sum((ch in s for ch in 'ABCDEFGHIJ')))]
if A and (not s[0].isdigit()):
	A[0] -= 1
print(reduce(mul, A, 1))


s = input()
l = []
n = '0123456789'
c = 1
z = True
tot = 1
for i in s:
	if i == '?':
		if z:
			c *= 9
		else:
			c *= 10
	elif i in n:
		pass
	elif i not in l:
		if z:
			c *= 9
			l.append(i)
		else:
			c *= 10 - len(l)
			l.append(i)
	z = False
print(c)


s = input()
ans = 1
l = list('ABCDEFGHIJ')
if s[0] == '?':
	ans *= 9
elif s[0] in l:
	ans *= 9
	l.remove(s[0])
for i in s[1:]:
	if i == '?':
		ans *= 10
	elif i in l:
		ans *= len(l)
		l.remove(i)
print(ans)


s = set()
r = f = 1
for c in input():
	if c == '?':
		r *= [10, 9][f]
	elif c.isalpha():
		if c not in s:
			r *= [10, 9][f] - len(s)
			s |= {c}
	f = 0
print(r)


def main():
	hint = input()
	hint_nodigits = [h for h in hint if not h.isdigit()]
	letters = [h for h in hint_nodigits if h != '?']
	combs_letters = 1
	for i in range(10, 10 - len(set(letters)), -1):
		combs_letters *= i
	combs_jolly = 10 ** (len(hint_nodigits) - len(letters))
	if hint[0] == '?':
		combs_jolly = combs_jolly // 10 * 9
	elif hint[0].isalpha():
		combs_letters = combs_letters // 10 * 9
	print(combs_letters * combs_jolly)
main()


n = str(input())
my_dict = {}
my_dict[0] = n[0]
countval = 1
samedig = 0
j = 0
for i in n:
	if j == 0:
		if i >= 'A' and i <= 'J':
			countval = countval * (9 - samedig)
			samedig += 1
			my_dict[i] = i
		elif i == '?':
			countval = countval * 9
		j = 1
	else:
		if i not in my_dict:
			my_dict[i] = i
			if i >= 'A' and i <= 'J':
				countval = countval * (10 - samedig)
				samedig += 1
		if i == '?':
			countval = countval * 10
print(countval)


a = str(input())
q = a.count('?')
l = 0
for i in 'ABCDEFGHIJ':
	if a.find(i) != -1:
		l += 1
if a[0] != '?':
	q = 10 ** q
else:
	q = 9 * 10 ** (q - 1)
l1 = 1
for i in range(0, l):
	l1 *= 10 - i
if a[0] in 'ABCDEFGHIJ':
	l1 //= 10
	l1 *= 9
print(l1 * q)


def f(x, k):
	res = 1
	for i in range(k - x, k):
		res *= i
	return res
t = input()
(s, k) = (set(), t.count('?'))
for i in t:
	if i >= 'A':
		s.add(i)
if t[0] in '123456789':
	print(f(len(s), 11) * 10 ** k)
elif t[0] == '?':
	print(f(len(s), 11) * 9 * 10 ** (k - 1))
else:
	print(9 * f(len(s) - 1, 10) * 10 ** k)


bool = True
items = input()
answer = 1
words = []
check = items[0]
try:
	check = str(int(check))
except:
	answer *= 0.9
for i in items:
	try:
		i = int(i)
	except:
		if i == '?':
			answer *= 10
		else:
			for s in words:
				if s == i:
					bool = False
			if bool:
				words.append(i)
			else:
				bool = True
for i in range(10, 10 - len(words), -1):
	answer *= i
print(int(answer))


def f(x, k):
	res = 1
	for i in range(k - x, k):
		res *= i
	return res
t = input()
(s, k) = (sum((i in t for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')), t.count('?'))
if t[0] in '123456789':
	print(str(f(s, 11)) + '0' * k)
elif t[0] == '?':
	print(str(f(s, 11) * 9) + '0' * (k - 1))
else:
	print(str(9 * f(s - 1, 10)) + '0' * k)


from collections import Counter
s = input()
a = Counter(s)
a1 = a.keys()
c = {'?', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'}
c1 = a1 - (a1 - c)
r = 1
b = 0
if '?' in a:
	r = 10 ** a['?']
	b = len(c1) - 1
else:
	b = len(c1)
r1 = 1
for i in range(b):
	r1 = r1 * (10 - i)
r = r * r1
if s[0] in c:
	print(int(r / 10 * 9))
else:
	print(int(r))


s = list(input())
k = set()
r = 0
for i in range(len(s)):
	if s[i] == '?':
		r = r + 1
	elif ord(s[i]) > 64:
		k.add(s[i])
r = 10 ** r
m = 10
for i in range(len(k)):
	r = r * m
	m = m - 1
if ord(s[0]) > 57:
	r = r // 10 * 9
print(r)


s = input()
cnt = 0
ans = 1
i = 0
cs = set()
for c in s:
	i += 1
	if c == '?':
		if i == 1:
			ans *= 9
		else:
			ans *= 10
	elif c >= 'A' and c <= 'J':
		if c in cs:
			continue
		cs.add(c)
		l = len(cs)
		if i == 1:
			ans *= 9
		else:
			ans *= 11 - l
print(ans)


s = input()
ans = 1
used = list('ABCDEFGHIJ')
if s[0] == '?':
	ans *= 9
elif s[0] in used:
	ans *= 9
	used.remove(s[0])
for sym in s[1:]:
	if sym == '?':
		ans *= 10
	elif sym in used:
		ans *= len(used)
		used.remove(sym)
print(ans)


s = input()
ans = 1
nuls = 0
used = set('ABCDEFGHIJ')
if s[0] == '?':
	ans *= 9
elif s[0] in used:
	ans *= 9
	used.remove(s[0])
for i in range(1, len(s)):
	if s[i] == '?':
		nuls += 1
	if s[i] in used:
		ans *= len(used)
		used.remove(s[i])
print(ans, '0' * nuls, sep='')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
s = input()
d = {}
for c in s:
	if c == '?':
		pass
	elif not c.isdigit():
		if c in d:
			d[c] += 1
		else:
			d[c] = 1
if s[0] == '?':
	print(9 * 10 ** (s.count('?') - 1) * math.factorial(10) // math.factorial(10 - len(d.keys())))
elif s[0].isalpha():
	print(10 ** s.count('?') * 9 * math.factorial(9) // math.factorial(10 - len(d.keys())))
else:
	print(10 ** s.count('?') * math.factorial(10) // math.factorial(10 - len(d.keys())))


input_str = input()
q = 0
tmp = []
for c in input_str:
	if c == '?':
		q += 1
	if 'A' <= c <= 'J' and tmp.count(c) == 0:
		tmp.append(c)
k = 1
for i in range(len(tmp)):
	k *= 10 - i
if input_str[0] == '?':
	print(str(9 * k) + '0' * (q - 1))
elif 'A' <= input_str[0] <= 'J':
	print(str(9 * (k // 10)) + '0' * q)
else:
	print(str(k) + '0' * q)