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 si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);  if si is a digit (between 0 to 9, inclusively), then it means that there is digit si 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...

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| ≤ 105.  Here |s| means the length of string s.

Print the number of codes that match the given hint.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class A {

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		boolean[] visit = new boolean[10];
		BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
		// StringTokenizer t = new StringTokenizer(rd.readLine(), " ");
		String s = rd.readLine();
		int l = s.length();
		BigInteger out = BigInteger.valueOf(1);
		int used = 0;
		for (int i = 0; i < l; i++) {
			char c = s.charAt(i);
			if (c == '?') {
				if (i != 0)
					out = out.multiply(BigInteger.valueOf(10));
				else
					out = out.multiply(BigInteger.valueOf(9));
			} else if (c <= 'J' && c >= 'A') {
				if (!visit[c - 'A']) {
					visit[c - 'A'] = true;
					if (i != 0)
						out = out.multiply(BigInteger.valueOf(10 - used));
					else
						out = out.multiply(BigInteger.valueOf(9 - used ));
					used++;
				}
			}
		}
		System.out.println(out);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String s = in.readLine();
        long ans = 1;
        int zeros = 0;
        HashSet<Character> H = new HashSet<Character>();
        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) == '?')
                if (i == 0)
                    ans *= 9;
                else
                    zeros++;
            else if (Character.isLetter(s.charAt(i)))
                H.add(s.charAt(i));
        if (H.size() > 10)
            out.println(0);
        else {
            if (H.size() > 0) {
                if (Character.isLetter(s.charAt(0)))
                    ans *= 9;
                else
                    zeros++;
                for (int i = 1; i < H.size(); i++)
                    ans *= 10 - i;
            }
            out.print(ans);
            for (int i = 0; i < zeros; i++)
                out.print("0");
            out.println();
        }
        out.flush();
        out.close();
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    static BigInteger fast_pow(int pangkat) {
        if (pangkat == 1) return BigInteger.TEN;
        if (pangkat == 0) return BigInteger.ONE;
        if (pangkat % 2 == 0) {
            BigInteger temp = fast_pow(pangkat / 2);
            return temp.multiply(temp);
        } else {
            BigInteger temp = fast_pow(pangkat - 1);
            return temp.multiply(BigInteger.TEN);
        }
    }

    static boolean isDigit(char A) {
        if (A >= '0' && A <= '9') return true;
        else return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String temp = sc.next();
        int i, pan = temp.length(), tanya = 0;
        int fak2 = 0;
        boolean arr[] = new boolean[300];
        for(i=0;i<=290;i++) arr[i] = false;
        for(i=0;i<pan;i++) {
            if (temp.charAt(i) == '?')
                tanya++;
            else if (isDigit(temp.charAt(i)) == false) {
                if (arr[temp.charAt(i)] == false)
                    fak2++;
                arr[temp.charAt(i)] = true;
            }
        }
        BigInteger ans = fast_pow(tanya);
        if (temp.charAt(0) == '?') ans = ans.divide(BigInteger.TEN).multiply(BigInteger.valueOf(9));
        int fak = 10;
        BigInteger faktorial = BigInteger.TEN;
        if (fak2 == 0) faktorial = BigInteger.ONE;
        if (isDigit(temp.charAt(0)) == false
                && temp.charAt(0) != '?')
                    faktorial = BigInteger.valueOf(9);
        for(i=fak-1;i>fak-fak2;i--) faktorial = faktorial.multiply(BigInteger.valueOf(i));
        System.out.println(ans.multiply(faktorial));
    }
}

import java.util.LinkedList;
import java.util.Scanner;

public class Task316A2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		LinkedList<Character> aj = new LinkedList<Character>();
		int c = 1;
		boolean flag = false;
		if (s.charAt(0) == '?') {
			c = 9;
		} else if ((s.charAt(0) >= 'A') && (s.charAt(0) <= 'J')) {
			c = 9;
			aj.add(s.charAt(0));
			flag = true;
		}

		int qCount = 0;
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				qCount++;
			} else if ((s.charAt(i) >= 'A') && (s.charAt(i) <= 'J')) {
				if (!aj.contains(s.charAt(i))) {
					c *= (10 - aj.size());
					aj.add(s.charAt(i));
				}
			}
		}
		System.out.print(c);
		for (int i = 0; i < qCount; i++) {
			System.out.print(0);
		}
	}
}

import java.util.Scanner;

public class SpecialTask {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        long soln=1;
        int diff=0;
        boolean offset=false;
        boolean [] chars = new boolean[10];
        for(int i=0;i<s.length();i++){
            if(s.charAt(i) == '?'){
                if(i == 0) soln*=9;
                else soln*=10;
            }
            int x = s.charAt(i)- 'A';
            if(x >=0 && x < chars.length){
                if(!chars[x])diff++;
                chars[x]=true;
                if(i == 0) offset=true;
            }
        }
        int start=10;
        for(int i=0;i<diff;i++){
            if(i == 0 && offset)
                soln*=9;
            else soln*=start;
            start--;
        }
        System.out.println(soln);
        scan.close();

    }

}

import java.util.*;
import java.math.*;

public class a
{
    public static void main(String argv[])throws Exception
    {
        BigInteger []table = new BigInteger[11];
        for(int i = 0; i < 11; i++)
            table[i] = BigInteger.valueOf(i);

        String input = new Scanner(System.in).nextLine();
        boolean pass[] = new boolean[26];
        BigInteger ans = BigInteger.ONE;
        boolean check = false;
        int comma = 0;
        for(int i = 0; i < input.length(); i++)
        {
            char c = input.charAt(i);
            if(c == '?')
            {
                if(i != 0)
                    comma++;
                else
                    ans = table[9];
            }
            else if('A' <= c && c <= 'J')
            {
                pass[c - 'A'] = true;
                if(i == 0)
                    check = true;
            }
        }

        for(int i = 0, k = 0; i < 26; i++)
            if(pass[i])
            {
                ans = ans.multiply(table[((check && k == 0)? 9: (10 - k))]);
                k++;
            }
        System.out.print(ans);
        for(int i = 0; i < comma; i++)
            System.out.print("0");
        System.out.println("");
    }
}

import java.util.HashSet;
import java.util.Scanner;

public class SpecialTask {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new java.util.Scanner(System.in);
		String s = in.next();
//		long startTime = System.currentTimeMillis();

		HashSet<Character> letters = new HashSet<Character>();
		int numQuestionMarks = 0;
		for (char c: s.toCharArray()) {
		  if (c == '?')
		    numQuestionMarks+=1;
		  else if (c > 64 && c < 91)
		    letters.add(c);
		}

		int combinations = 1;
		int numLetters = letters.size();
		for(int i = 10-(numLetters-1); i <= 10; i++)
		  combinations*=i;

		if (s.charAt(0) == '?') {
		  combinations*=9;
		  numQuestionMarks-=1;
		} else if (s.charAt(0) > 64 && s.charAt(0) < 91) {
		  combinations/=10;
		  combinations*=9;
		}

		StringBuilder b = new StringBuilder(numQuestionMarks*2);
		for (int i = 0; i < numQuestionMarks; i++)
			b.append("0");

	    System.out.println(combinations+b.toString());
//		println("%d ms".format(System.currentTimeMillis()-startTime));
		in.close();
	}

}

import java.io.*;
import java.util.*;
public class a316
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
       // System.out.println("Enter");
        String s=in.readLine();
        String s1="";
        int i,j=1,pro=1,k=0,num=10,nc=0;
        int A[]=new int[10];
        if(s.charAt(0)=='?')
            {
                j=9;
            }
        else if(Character.isLetter(s.charAt(0))==true)
               {
                  A[(int)s.charAt(0)-65]=9;
                   k++;
                }
        for(i=1;i<s.length();i++)
        {
            if( Character.isLetter(s.charAt(i))==true)
            {
                if(A[(int)s.charAt(i)-65]==0)
               {
                   A[(int)s.charAt(i)-65]=num-k;
                   k++;
                }
                nc++;
            }
            else if(s.charAt(i)!='?')
            nc++;
        }
        for(i=0;i<10;i++)
        {
           // System.out.println(A[i]);
            if(A[i]!=0)
            pro*=A[i];
        }
        System.out.print(pro*j);
        for(i=0;i<(s.length()-1-nc);i++)
        System.out.print("0");
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class A
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}
		catch (NullPointerException e)
		{
			line=null;

		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	long NextLong()
	{
		String n = inputParser.nextToken();
		long val = Long.parseLong(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	double NextDouble()
	{
		String n = inputParser.nextToken();
		double val = Double.parseDouble(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		//String filePath="input.txt";
        String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new A(filePath);
	}

	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}

	public A(String inputFile)
	{
		openInput(inputFile);
		readNextLine();
    	String s=line;

	    System.out.println(get(s));

		closeInput();
	}

	String get(String s)
	{
		BigInteger ret=BigInteger.ONE;
		int ten=0;
		int cnt=10;
		int N=s.length();
		boolean [] p = new boolean[10];
		for(int i=0; i<N; i++)
		{
			char c=s.charAt(i);
			if(c=='?')
			{
				if(i>0)ten++;
				else ret=ret.multiply(new BigInteger("9"));
			}
			else if(c>='A'&&c<='J')
			{
				if(!p[c-'A'])
				{
					p[c-'A']=true;
					if(i==0)cnt--;
					ret=ret.multiply(new BigInteger(""+cnt));
					if(i>0)cnt--;
				}
			}
		}
		StringBuilder sb=new StringBuilder();
		sb.append(ret);
		for(int i=0; i<ten; i++)
			sb.append(0);
		return sb.toString();
	}

}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main implements Runnable {

	public void _main() throws IOException {
		char[] s = next().toCharArray();
		int letters = 0;
		boolean[] was = new boolean[10];
		int[] a = new int[11];
		for (int i = 0; i < s.length; i++) {
			int cur = 1;
			if (s[i] == '?') {
				if (i == 0) {
					cur = 9;
				} else {
					cur = 10;
				}
			}
			if (Character.isLetter(s[i])) {
				if (!was[s[i] - 'A']) {
					cur = 10 - letters;
					if (i == 0) {
						cur = 9;
					}
					was[s[i] - 'A'] = true;
					++letters;
				}
			}
			++a[cur];
		}
		BigInteger res = BigInteger.ONE;
		for (int i = 2; i < 10; i++) {
			if (a[i] > 0) {
				res = res.multiply(BigInteger.valueOf(i).pow(a[i]));
			}
		}
		out.print(res);
		for (int i = 0; i < a[10]; i++) {
			out.print(0);
		}
		out.println();
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	private String next() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String rl = in.readLine();
			if (rl == null)
				return null;
			st = new StringTokenizer(rl);
		}
		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.UK);
		new Thread(new Main()).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			//in = new BufferedReader(new FileReader("a.in"));
			//out = new PrintWriter(new FileWriter("a.out"));

			_main();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(202);
		}
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * User: ������
 * Date: 12.06.2013
 * Time: 16:17:08
 */
public class ABBYY_3_A {
    Scanner scanner = new Scanner(System.in);
    BufferedReader buffered = new BufferedReader(new InputStreamReader(System.in));
    StreamTokenizer in = new StreamTokenizer(buffered);

    PrintWriter out = new PrintWriter(System.out);

    int nextInt() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    boolean isLetter(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J';
    }

    void main() throws Exception {
        String s = buffered.readLine();
        long ans = 1;
        boolean firstLetter = false;
        Set<Character> chars = new HashSet<Character>();
        if (s.charAt(0) == '?') ans *= 9;
        if (isLetter(s.charAt(0))) {
            firstLetter = true;
            chars.add(s.charAt(0));
        }

        int k0 = 0;
        for (int i=1; i<s.length(); i++) {
            char c = s.charAt(i);
            if (c == '?') k0++;
            if (isLetter(c)) chars.add(c);
        }

        for (int i=0; i<chars.size(); i++) {
            if (i==0 && firstLetter) ans *= 9;
            else ans *= 10-i;
        }

        System.out.print(ans);
        for (int i=0; i<k0; i++)
            System.out.print(0);
        System.out.println();
        System.out.flush();
    }

    public static void main(String[] args) throws Exception {
        new ABBYY_3_A().main();
    }
}

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Problem4 {

	private static Set<Character> lettersused = new HashSet<Character>();
	private static long questionMarksUsed=0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner in = new Scanner(System.in);

		while (in.hasNextLine()) {
			   String line = in.nextLine();
			   getCombinations(line);
		}

	}

	private static void getCombinations(String safe) {

        if(safe==null || safe.isEmpty()) {
            System.out.println(0);
        }
        for(int i=0; i<safe.length(); i++) {
            treatCharacter(safe.charAt(i));
        }

        long aux=1;
        if(Character.isDigit(safe.charAt(0))) {
        	for(int i=0 ; i<lettersused.size();i++) {
            	aux*=10-i;
            }
        }
        else {
	       	if (safe.charAt(0)=='?') {
	        	aux=9;
	        	questionMarksUsed--;
	        	for(int i=0 ; i<lettersused.size();i++) {
	            	aux*=10-i;
	            }
	        }
	        else {
	        	aux=9;
	        	for(int i=0 ; i<lettersused.size()-1;i++) {
	            	aux*=9-i;
	            }
	        }
        }

       // BigDecimal res = new BigDecimal(Long.toString(aux));
        StringBuilder xx = new StringBuilder(Long.toString(aux));
        //System.out.println(xx.append("bb"));
        //StringBuilder aaa =Long.toString(aux);
        for (int i=0; i<questionMarksUsed ; i++) {
        	xx=xx.append("0");
        }
        /*
        Long aux2 = questionMarksUsed/300;
        for(int i=0; i<aux2 ; i++) {
        	res = res.multiply(new BigDecimal(Double.toString(Math.pow(10, 300))));
        }
        res = res.multiply(new BigDecimal(Double.toString(Math.pow(10, (questionMarksUsed - 300*aux2)))));

        */

        System.out.println(xx.toString());

        lettersused.clear();
    }

    private static void treatCharacter(char c) {
        // TODO Auto-generated method stub
        if(c=='?') {
            questionMarksUsed++;
        }

        else if(!Character.isDigit(c)) {
        	checkLetter(c);
        }

    }

    private static void checkLetter(Character c) {

    	if(lettersused.size()<10 && !lettersused.contains(c)) {
    		lettersused.add(c);
    	}
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class ABBYY_A {
	public static void main(String[] args) throws Exception {
		int[] factorial = {1,10,90,720,5040,30240,151200,604800,1814400,3628800,3628800};
		int[] factorial2 = {1,9,81,648,4536,27216,136080,544320,1632960,3265920,3265920};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		boolean[] good = new boolean[10];
		int letters = 0;
		int any = 0;
		boolean firstany = false;
		boolean firstletter = false;
		if(s[0] == '?'){
			any++;
			firstany = true;
		}
		else if(s[0] <= 'J' && s[0] >= 'A' && !good[s[0] - 'A']){
			good[s[0] - 'A'] = true;
			letters++;
			firstletter = true;
		}
		for(int i = 1; i < s.length; i++){
			if(s[i] == '?'){
				any++;
			}
			else if(s[i] <= 'J' && s[i] >= 'A' && !good[s[i] - 'A']){
				good[s[i] - 'A'] = true;
				letters++;
			}
		}
		if(firstany){
			System.out.println(BigInteger.TEN.pow(any - 1).multiply(BigInteger.valueOf(9*factorial[letters])).toString());
		}
		else if(firstletter){
			System.out.println(BigInteger.TEN.pow(any).multiply(BigInteger.valueOf(factorial2[letters])).toString());
		}
		else{
			System.out.println(BigInteger.TEN.pow(any).multiply(BigInteger.valueOf(factorial[letters])).toString());
		}
	}
}

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class abby1
 {
   public static void main(String args[]) throws IOException
    {
     BufferedReader cin=new BufferedReader(new InputStreamReader(System.in));
	 String s=cin.readLine();
	 int l=s.length();
	 int alpha[]=new int[10];
	 char c[]=s.toCharArray();
	 int oops=0;
	 int mark=0;
	 int numb=0;
	 int mult=1;
	 int fin=0;
	 //if (c[0]>=48 && c[0]<=57)
	      //oops++;
	 for(int i=0;i<l;i++)
	 {
	    if(c[i]=='?')
		     mark++;
         else if (c[i]>=65 && c[i]<=74)
                  alpha[c[i]-65]++;
         else
               numb++;
      }
      for(int i=0;i<10;i++)
	  	  {
		    if(alpha[i]!=0)
			       fin++;
		     else ;
          }
		 //int total=fin+mar;
		 //System.out.println("value of final" + fin);
         int nine=9;
		 int ten=10;
      if(c[0]>=65 && c[0]<=74)
       {
         mult=9;
      for(int i=0;i<(fin-1);i++)
	      {
			   mult=mult*nine;
         	       nine--;
		   }
        }
        else
         {
          for(int i=0;i<fin;i++)
	      {
			   mult=mult*ten;
         	       ten--;
		   }
        }
       if(c[0]=='?')
	     {
		   mult=mult*9;
	      for(int i=0;i<(mark-1);i++)
	      {
           mult=mult*10;
           }
	      }
         else
          {
            for(int i=0;i<mark;i++)
	       {
           mult=mult*10;
           }
          }
      System.out.println(mult);
		  }
}

import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        BigInteger result = BigInteger.ONE;
        boolean[] exist = new boolean[10];
        for (int i = 0; i < 10; ++i) {
            exist[i] = false;
        }
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == '?') {
                if (i != 0) {
                    result = result.multiply(BigInteger.valueOf(10L));
                } else {
                    result = result.multiply(BigInteger.valueOf(9L));
                }
            } else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J') {
                exist[s.charAt(i) - 'A'] = true;
            }
        }
        int count = 0;
        for (int i = 0; i < 10; ++i) {
            if (exist[i]) {
                count++;
            }
        }
        if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J') {
            result = result.multiply(BigInteger.valueOf(9L));
            for (int i = 9; i >= 10 - count + 1; --i) {
                result = result.multiply(BigInteger.valueOf((long) (i)));
            }
        } else {
            for (int i = 10; i >= 10 - count + 1; --i) {
                result = result.multiply(BigInteger.valueOf((long) (i)));
            }
        }
        System.out.println(result);
    }
}

//******************
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);

        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();

        solver.main(in, out);

        out.close();
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        if (!hasNext())
            throw new RuntimeException();
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e) {
                return false;
            }
        return true;
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

class Task {
    void main(InputReader in, PrintWriter out) throws Exception {
        String s = in.next();
        int len = s.length();
        int i, j;
        BigInteger tp = BigInteger.valueOf(1);
        long tt = 0;
        boolean d[] = new boolean[26];
        for(i = 0; i < 26; i++) d[i] = false;
        for (i = 1; i < len; i++) {
            if ((int)s.charAt(i) >= (int)'A' && (int)s.charAt(i) <= (int)'J')
                d[(int)s.charAt(i)-(int)'A'] = true;
            if (s.charAt(i) == '?') tt++;
                //tp = tp.multiply(BigInteger.valueOf(10));
        }
        //for(i = 0; i < 26; i++)
        //  out.println(d[i]+" ");
        int cnt = 0;
        for (i = 0; i < 26; i++)
            if (d[i] == true) cnt++;

        //out.println("cnt = "+cnt);

        if(s.charAt(0) == '?') {
            BigInteger ans = BigInteger.valueOf(9);
            for (i = 10; i >= 10-cnt+1; i--)
                ans = ans.multiply(BigInteger.valueOf(i));
            //ans = ans.multiply(tp);
            out.print(ans);
            //return;
        }
        else if((int)s.charAt(0) >= (int)'A' && (int)s.charAt(0) <= (int)'J') {
            if(d[(int)s.charAt(0)-(int)'A'] == true) {
                BigInteger ans = BigInteger.valueOf(9);
                cnt--;
                for (i = 9; i >= 9-cnt+1; i--)
                    ans = ans.multiply(BigInteger.valueOf(i));
                //ans = ans.multiply(tp);
                out.print(ans);
                //return;
            }
            else {
            //  out.println("tp = "+tp);
                BigInteger ans = BigInteger.valueOf(9);
                for (i = 9; i >=9-cnt+1; i--)
                    ans = ans.multiply(BigInteger.valueOf(i));
                //ans = ans.multiply(tp);
                out.print(ans);
                //return;
            }
        }
        else {
            BigInteger ans = BigInteger.valueOf(1);
            for (i = 10; i >= 10-cnt+1; i--)
                ans = ans.multiply(BigInteger.valueOf(i));
            //ans = ans.multiply(tp);
            out.print(ans);
            //return;
        }
        for(i = 0; i < tt; i++)
            out.print(0);
        out.println();
    }
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Abbyy_A1 {
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        //in = new BufferedReader(new FileReader("in.txt"));
        out = new PrintWriter(System.out);
        //stk = new StringTokenizer(in.readLine());
        int i,j=0,k,l,m,n,c[];String s;
        c=new int[10];
        Arrays.fill(c, 0);
        s=in.readLine();
        for(i=0;i<s.length();i++){
            l=s.charAt(i)-65;
            if(s.charAt(i)=='?'&&i!=0){
                j++;
            }
            else if(l>=0&&l<10){
                c[l]++;
            }

        }
        /*for(i=0;i<10;i++)
            System.out.print(c[i]+" ");
        System.out.println("");*/
        BigInteger ans=BigInteger.valueOf(1);
        l=s.charAt(0)-65;
        //System.out.println(l+"  "+c[l]);
        if(l>=0&&l<10){
            ans=BigInteger.valueOf(9);
            c[l]=0;
            k=9;
            //System.out.println("nj");
        }
        else if(s.charAt(0)=='?'){
            ans=BigInteger.valueOf(9);
            k=10;
        }
        else{
            ans=BigInteger.valueOf(1);
            k=10;
        }

        for(i=0;i<10;i++){
            if(c[i]>0){
                ans=ans.multiply(BigInteger.valueOf(k));
                k--;
            }

        }
        BigInteger ans1;
        /*if(j>0)
         ans1=BigInteger.valueOf(10).pow(j);
        else
            ans1=BigInteger.valueOf(1);*/
        //ans=ans.multiply(ans1);
        System.out.print(ans);
        for(i=0;i<j;i++)
            System.out.print("0");
        System.out.println("");
}
static void printf(String format, Object... args) {
        System.out.printf(format, args);
        out.printf(format, args);
    }

    static int ni() throws Exception {
        while (!stk.hasMoreTokens()) {
            stk = new StringTokenizer(in.readLine());
        }
        return Integer.parseInt(stk.nextToken());
    }

    static long nl() throws Exception {
        while (!stk.hasMoreTokens()) {
            stk = new StringTokenizer(in.readLine());
        }
        return Long.parseLong(stk.nextToken());
    }

    static double nd() throws Exception {
        while (!stk.hasMoreTokens()) {
            stk = new StringTokenizer(in.readLine());
        }
        return Double.parseDouble(stk.nextToken());
    }

    static String ns() throws Exception {
        while (!stk.hasMoreTokens()) {
            stk = new StringTokenizer(in.readLine());
        }
        return stk.nextToken();
    }

    static int min(int a, int b) {
        return a < b ? a : b;
    }

    static int max(int a, int b) {
        return a > b ? a : b;
    }

    static long min(long a, long b) {
        return a < b ? a : b;
    }

    static long max(long a, long b) {
        return a > b ? a : b;
    }

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class jmain {

	/**
	 * @param args
	 */

	static BufferedReader brscan = new BufferedReader(new InputStreamReader(
			System.in));
	static PrintWriter pw = new PrintWriter(System.out);
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		boolean[] alpha = new boolean[200];
		String strin = new String();

		// input //
		strin = brscan.readLine();
		long prob = 1;
		long probten = 0;
		int len = strin.length();
		int remaining = 10;

		for (int ii = 0; ii < len; ++ii)
		{
			char c = strin.charAt(ii);
			if (ii==0) {
				if (c=='?') {
					prob *= 9;
				} else if (!Character.isDigit(c) && !alpha[c]) {
					alpha[c] = true;
					prob *=9;
					remaining -= 1;
				}
			} else {
				if (c=='?') {
					probten += 1;
				} else if (!Character.isDigit(c) && !alpha[c]) {
					alpha[c] = true;
					prob *= remaining;
					remaining -= 1;
				}
			}
		}

		pw.print(prob);
		for (int i = 0; i < probten; ++i)
		{
			pw.print('0');
		}
		pw.println();
		pw.close();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;

public class Main {

        public static void main(String[] args) throws IOException {

                    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                            String s = br.readLine();
                                    int result = 1;
                                            int com = 9;
                                                    HashSet<Character> v = new HashSet<Character>();
                                                            for (int i = 0; i < s.length(); i++) {
                                                                            if (s.charAt(i) == '?')
                                                                                result *= 9 + (i != 0? 1 : 0);
                                                                                else if (s.charAt(i) <= 'Z' && s.charAt(i) >= 'A' && !v.contains(s.charAt(i))) {
                                                                                v.add(s.charAt(i));
                                                                                result *= com-- + (i != 0? 1 : 0);
                                                                                }
                                                                                }
                                                                    System.out.println(result);

                                                                        }

}

import java.util.*;
public class cf316a {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String x = in.next().trim();
    int firstType = 0;
    if(Character.isDigit(x.charAt(0)))
      firstType = 0;
    else if(x.charAt(0) == '?')
      firstType = 1;
    else
      firstType = 2;
    int qCount = 0;
    HashSet<Character> letters = new HashSet<Character>();
    for(char c : x.toCharArray()) {
      if(c == '?') qCount++;
      else if(Character.isDigit(c)) {

      }
      else {
        letters.add(c);
      }
    }
    long ans = 1;
    for(int i=0; i<letters.size(); i++)
      ans *= (10-i);
    if(firstType == 2) ans = (ans/10)*9;
    if(firstType == 1) {
      ans *= 9;
      qCount--;
    }
    System.out.print(ans);
    for(int i=0; i<qCount; i++)
      System.out.print("0");
  }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashSet;

public class A {

	public static void main(String[] args)throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		char s[]=reader.readLine().toCharArray();
		int count=10;
//		long ret=1;

		BigInteger []big=new BigInteger[11];
		for(int i=0;i<big.length;i++)
			big[i]=new BigInteger(i+"");

		boolean v[]=new boolean [11];
		int num1=0;
		int num2=0;
		long l=10;
		for(int i=0;i<s.length;i++)
		{
			if(s[i]=='?')
				num1++;
			else if(s[i]>='A' &&s[i]<='J')
			{
				if(!v[s[i]-'A'])
				{
					num2++;
					v[s[i]-'A']=true;
				}
			}
		}

		//BigInteger n1=big[1];
		count =9;
		long ret=1;
		if(s[0]=='?')
		{
//			ret=9;
//			ret=big[9];
//			count=10;
			num1--;
			ret=9;
		//	n1=big[9];
		}
		else if(s[0]>='A' && s[0]<='J')
		{
//			ret=9;
//			ret=big[9];
			count=9;
//			v[s[0]-'A']=true;
//			n1=big[9];
			l=9;

		}
		num2--;
		for(int i=0;i<num2;i++)
		{
			l*=count--;
		}
		if(num2>=0)
		{
			ret*=l;
		}
		StringBuilder b=new StringBuilder();
		for(int i=0;i<num1;i++)
			b.append("0");
		String ss=ret+b.toString();
////n1=n1.multiply(big[10].pow(num1));
//		n1=n1.multiply(new BigInteger(b.toString()));
//		//System.out.println(n1);
////System.out.println(num2);
//
//if(num2>=0)
//		n1=n1.multiply(new BigInteger(l+""));

		System.out.println(ss);
	}

}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
    public static void main (String[] args) throws FileNotFoundException
    {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run() throws FileNotFoundException
    {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }
    BigInteger myPow(BigInteger a, int p)
    {
        if (p == 0)
            return BigInteger.ONE;
        BigInteger tmp, res;
        tmp = myPow(a, (int)(p / 2));
        res = tmp;
        res = res.multiply(tmp);
        if (p % 2 == 1)
        {
            res = res.multiply(a);
        }
        return res;
    }
    void solve ()
    {
        String sstr = in.nextLine();
        int n = sstr.length();
        int cnt1 = 0, cnt2 = 0;
        char str[] = sstr.toCharArray();
        BigInteger ans;
        ans = BigInteger.ONE;
        Boolean used[];
        used = new Boolean[30];
        int fl = 10;
        for (int i = 0; i < 30; i++)
        {
            used[i] = false;
        }
        if (str[0] == (char)'?')
        {
            ans = BigInteger.valueOf(9);
        }
        else if (str[0] >= 'A' && str[0] <= 'J')
        {
            ans = BigInteger.valueOf(9);
            used[str[0] - 'A'] = true;
            fl = 9;
        }
        for (int i = 1; i < n; i++)
        {
            if (str[i] == '?')
            {
                cnt1++;
            }
            else if (str[i] >= 'A' && str[i] <= 'J')
            {
                if (!used[str[i] - 'A'])
                {
                    cnt2++;
                    used[str[i] - 'A'] = true;
                }
            }
        }
        BigInteger cnt3;
        cnt3 = BigInteger.ONE;
        for (int i = fl; i > fl - cnt2; i--)
        {
            cnt3 = cnt3.multiply(BigInteger.valueOf(i));
        }
        ans = ans.multiply(cnt3);
        out.print(ans);
        for (int i = 0; i < cnt1; i++)
            out.print("0");
    }

}

import java.util.*;
public class P316A1 {
	P316A1(Scanner in) {
		String s = in.next();
		long ans = 1;
		boolean[] seen = new boolean['J'-'A'+1];
		int specials = 10;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == '?')
				ans *= (i==0 ? 9 : 10);
			else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J') {
				if (seen[s.charAt(i)-'A'])
					continue;
				seen[s.charAt(i)-'A'] = true;
				ans *= (i==0 ? 9 : specials);
				specials--;
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new P316A1(new Scanner(System.in));
	}
}

import java.io.*;
import java.util.*;

public class Main {

    // system
    public static String charset = "UTF-8";
    public static Locale locale = new Locale("en", "US");
    public static PrintWriter stdOut, fileOut;
    public static Scanner stdIn, fileIn;

    // A
    public static void main(String[] args) {
        setIO(null, null);
        Scanner input = stdIn;
        PrintWriter output = stdOut;

        String s = input.next();
        int[] arr = new int[255];
        for (char c = 'A'; c <= 'J'; c++) {
            arr[c] = 0;
        }
        int q = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '?') q++;
            else if (c >= 'A' && c <= 'J') {
                arr[c]++;
            }
        }
        char first = s.charAt(0);
        long total = 1;
        if (first == '?') {
            total *= 9;
            q--;
        }
        int count = 10;
        if (first >= 'A' && first <= 'J') {
            total *= 9;
            count = 9;
            arr[first] = 0;
        }
        for (char c = 'A'; c <= 'J'; c++) {
            if (arr[c] > 0) {
                total *= count;
                count--;
            }
        }
        String nullstr = "";
        if (q != 0) {
            char[] chars = new char[q];
            Arrays.fill(chars, '0');
            nullstr = new String(chars);
        }

        output.print(total);
        output.println(nullstr);

        input.close();
        output.close();
    }

    // system
    public static void setIO(String fileInName, String fileOutName) {
        // Standard input
        stdIn = new Scanner(new BufferedInputStream(System.in), charset);
        stdIn.useLocale(locale);

        // Standard output
        try {
            stdOut = new PrintWriter(new OutputStreamWriter(System.out, charset), true);
        }
        catch (UnsupportedEncodingException e) {
            System.err.println(e);
        }

        // File input
        if (fileInName != null) {
            try {
                File file = new File(fileInName);
                if (file.exists()) {
                    fileIn = new Scanner(file, charset);
                    fileIn.useLocale(locale);
                }
            }
            catch (IOException ioe) {
                System.err.println("Could not open " + fileInName);
            }
        }

        // File output
        if (fileOutName != null) {
            try {
                OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(fileOutName), charset);
                fileOut = new PrintWriter(osw, true);
            }
            catch (IOException e) {
                System.err.println(e);
            }
        }
    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	Scanner in;
	PrintWriter out;
	public static void main(String[] args) throws IOException
	{
		new Main().run();
	}

	public void run() throws IOException
	{
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		String s = in.next();
		int[] cnt = new int[15];
		for (int i = 0; i < s.length(); ++i)
			if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
				cnt[s.charAt(i) - 'A']++;
		int let = 0;
		for (int i = 0; i < 10; ++i)
			if (cnt[i] > 0)
				let++;
		BigInteger ans = BigInteger.ONE;
		for (int i = 1; i < s.length(); ++i)
			if (s.charAt(i) == '?')
				ans = ans.multiply(BigInteger.valueOf(10));
		if (s.charAt(0) == '?')
		{
			ans = ans.multiply(BigInteger.valueOf(9));
			for (int j = 1; j <= 10; ++j)
				ans = ans.multiply(BigInteger.valueOf(j));
			for (int j = 1; j <= 10 - let; ++j)
				ans = ans.divide(BigInteger.valueOf(j));
		}
		else if (s.charAt(0) >= 'A' && s.charAt(0) <= 'Z')
		{
			ans = ans.multiply(BigInteger.valueOf(9));
			for (int j = 1; j <= 9; ++j)
				ans = ans.multiply(BigInteger.valueOf(j));
			for (int j = 1; j <= 10 - let; ++j)
				ans = ans.divide(BigInteger.valueOf(j));
		}
		else
		{
			for (int j = 1; j <= 10; ++j)
				ans = ans.multiply(BigInteger.valueOf(j));
			for (int j = 1; j <= 10 - let; ++j)
				ans = ans.divide(BigInteger.valueOf(j));
		}
		out.println(ans);
		out.flush();
	}
}

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author RiaD
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA1 solver = new TaskA1();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA1 {
    public void solve(int testNumber, Reader in, OutputWriter out) {
        String s = in.nextString();
        Set<Character> set = new HashSet<Character>();
        long ans = 1;
        int nulls = 0;
        for(int i = 0; i < s.length(); ++i){
            if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
                set.add(s.charAt(i));
            if(s.charAt(i) == '?' && i == 0)
                ans *= 9;
            else if (s.charAt(i) == '?')
                ++nulls;
        }

        for(int i = 0; i < set.size(); ++i){
            if(i == 0 && s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
                ans *= 9;
            else
                ans *= 10 - i;
        }

        out.print(ans);
        for(int i = 0; i < nulls; ++i)
            out.print(0);
    }
}

class Reader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public Reader(BufferedReader reader) {
        this.reader = reader;
    }

    public Reader(InputStream stream) {
        this(new BufferedReader(new InputStreamReader(stream)));
    }

    public String nextString() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(readLine());
        }
        return tokenizer.nextToken();
    }

    private String readLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

class OutputWriter extends PrintWriter {

    public OutputWriter(OutputStream out) {
        super(out);
    }

    public OutputWriter(java.io.Writer writer){
        super(writer);
    }

    }

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.next();
        BigInteger ans = BigInteger.ONE;
        boolean fs = ('A' <= s.charAt(0) && s.charAt(0) <= 'J');
        int nn = 0;
        for(char it = 'A'; it <= 'J'; it++)
        {
            for(int i = 0; i < s.length(); i++)
            {
                if (s.charAt(i) == it)
                {
                    nn++;
                    break;
                }
            }
        }
        int k = 10;
        if (fs)
        {
            k--;
            nn--;
            ans = ans.multiply(BigInteger.valueOf(k));
        }
        while(nn != 0)
        {
            ans = ans.multiply(BigInteger.valueOf(k));
            k--;
            nn--;
        }
        k = 10;
        for(int i = 0; i < s.length(); i++)
        {
            if (s.charAt(i) == '?')
                ans = ans.multiply(BigInteger.valueOf(i == 0?9:10));
        }
        System.out.println(ans.toString());
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}

import java.io.InputStreamReader;
import java.io.IOException;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

public class palin {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(System.out);
		Scanner scan = new Scanner(System.in);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		String str = in.next();
		long res = 1;
		int cq = 0, a[] = new int[10], c = 10;
		for (int i = 0; i < str.length(); i++) {
			if (i == 0) {
				if (str.charAt(i) == '?') {
					res *= 9;
				} else {
					if ((int) str.charAt(i) > 64) {
						a[(int) str.charAt(i) - 65] = 9;
						res *= 9;
						c--;
					}
				}
			} else {
				if (str.charAt(i) == '?') {
					cq++;
				} else {
					if ((int) str.charAt(i) > 64) {
						if (a[(int) str.charAt(i) - 65] == 0) {
							a[(int) str.charAt(i) - 65] = c;
							res *= c;
							c--;
						}
					}
				}
			}
		}
		out.print(res);
		for (int i = 0; i < cq; i++) {
			out.print('0');
		}
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class AABBY {

    public void solve() throws IOException {

        Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        char a[] = br.readLine().toCharArray();

        int b[] = new int[27];
        int ques = 0;
        int quesFirst = 1;
        int chars = 0;

        Set set = new HashSet();
        long ans = 1;
        for (int i = 0; i < a.length; i++) {
            if (a[i] == '?') {
                if (i == 0) {
                    ans *= 9;
                } else {
                    ans *= 10;
                }
            } else if (a[i] > 60) {
                if (i == 0) {
                    ans *= 9;
                    ques++;
                    set.add(a[i]);
                } else {
                    if (!set.contains(a[i])) {
                        set.add(a[i]);
                        ans *= 10 - ques;
                        ques++;
                    }
                }
            }
        }
        System.out.println(ans);

    }

    public static void main(String[] args) throws IOException {
        new AABBY().solve();

    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main implements Runnable {

	public void _main() throws IOException {
		char[] s = next().toCharArray();
		BigInteger res = BigInteger.ONE;
		int letters = 0;
		boolean[] was = new boolean[10];
		for (int i = 0; i < s.length; i++) {
			int cur = 1;
			if (s[i] == '?') {
				if (i == 0) {
					cur = 9;
				} else {
					cur = 10;
				}
			}
			if (Character.isLetter(s[i])) {
				if (!was[s[i] - 'A']) {
					cur = 10 - letters;
					if (i == 0) {
						cur = 9;
					}
					was[s[i] - 'A'] = true;
					++letters;
				}
			}
			res = res.multiply(BigInteger.valueOf(cur));
		}
		out.println(res);
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	private String next() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String rl = in.readLine();
			if (rl == null)
				return null;
			st = new StringTokenizer(rl);
		}
		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.UK);
		new Thread(new Main()).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			//in = new BufferedReader(new FileReader("a.in"));
			//out = new PrintWriter(new FileWriter("a.out"));

			_main();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(202);
		}
	}

}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	static final long MOD = 1000000007;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int qq = 1;
		//int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			String str = nextToken();
			BigInteger ret = BigInteger.ONE;
			TreeSet<Character> set = new TreeSet<Character>();
			for(int i = 0; i < str.length(); i++)	{
				int cand = i == 0 ? 9 : 10;
				if(str.charAt(i) == '?')	{
					ret = ret.multiply(BigInteger.valueOf(cand));
				}
				else if(Character.isLetter(str.charAt(i)) && set.add(str.charAt(i)))	{
					cand -= set.size()-1;
					ret = ret.multiply(BigInteger.valueOf(cand));
				}
			}
			pw.println(ret);
		}
		pw.close();
	}

	static class Vertex	implements Comparable<Vertex> {
		public int x,y,w;

		public Vertex(int x, int y, int w) {
			super();
			this.x = x;
			this.y = y;
			this.w = w;
		}

		public int compareTo(Vertex curr)	{
			return w - curr.w;
		}
	}

	static class State	{
		public int x,y;

		public State(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

	}

	private static void exitImmediately()	{
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}

	private static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}

/*
ID: BryatnMark
LANG: JAVA
TASK: AC
 */
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;
public class Main {
    public static void main(String args[]) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.main(in, out);
        out.close();
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    String next() {
        if (!hasNext())
            throw new RuntimeException();
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e) {
                return false;
            }
        return true;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
    BigDecimal nextBigDecimal()
    {
        return new BigDecimal(next());
    }
}

class Task {
    final int maxn = 111111;
    BigInteger ans;
    char[] s=new char[maxn];
    String ss;
    BigInteger one=BigInteger.ONE;
    BigInteger ten=BigInteger.TEN;
    BigInteger pow(BigInteger a,int b)
    {
        BigInteger t=a,res=BigInteger.ONE;
        while(b>0)
        {
            if((b&1)>0)
                res=res.multiply(t);
            t=t.multiply(t);
            b>>=1;
        }
        return res;
    }
    void main(InputReader in, PrintWriter out) throws Exception {
        ss=in.next();
        s=ss.toCharArray();
        int len=ss.length();
        int k,i,cnt=0;
        int[] c=new int [28];
        if(s[0]=='0')
        {
            out.println(0);
            return;
        }
        if(s[0]>='0'&&s[0]<='9')
            k=1;
        else if(s[0]=='?')
            k=2;
        else
            k=3;
        for(i=0;i<len;++i)
        {
            if(s[i]=='?')
                cnt++;
            else if(s[i]>='A'&&s[i]<='Z')
                c[s[i]-'A']=1;
        }
        int t=0;
        for(i=0;i<26;++i)
            t+=c[i];

        BigInteger ans=BigInteger.ONE;

        //out.println(cnt + " " +t+ " "+ k);
        if(k==1)
        {
            for(i=10;i>10-t;--i)
                ans=ans.multiply(BigInteger.valueOf(i));
        }
        else if(k==2)
        {
            for(i=10;i>10-t;--i)
                ans=ans.multiply(BigInteger.valueOf(i));
            if(cnt>0)
            {
                ans=ans.multiply(BigInteger.valueOf(9));
                cnt--;
            }
        }
        else
        {
            ans=BigInteger.valueOf(9);
            for(i=9;i>10-t;--i)
                ans=ans.multiply(BigInteger.valueOf(i));
        }
        out.print(ans);
        for(i=0;i<cnt;++i)
            out.print("0");
        out.println();

    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class jvcls
{
    public static List<Integer>[] g;
    public static  boolean [] prime;
    public static boolean [] visited;
    public static StringTokenizer st;
    public static BufferedReader br;
    public static PrintWriter out;
    public static int[] tree;

    public static void main(String... args)throws  IOException{

        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        String s = nextToken();
        Set<Character> letset = new HashSet<Character>();
        int k =0;
        int kq=0;
        for (int i=0;i<s.length();++i)
        {

            if(s.charAt(i)>='A' && s.charAt(i)<='J'&& !letset.contains(s.charAt(i)))
            {
                letset.add(s.charAt(i));
                k++;
            }

            if(s.charAt(i)=='?')
                kq++;

        }

        if(k==0 && kq==0)
        {
            out.print(1);
            out.close();
            return;
        }
        else
            if(kq==1  && k==0 && s.charAt(0)=='?'){out.print(9); out.close();return;}

        BigInteger ans  = BigInteger.ONE;
        BigInteger m = BigInteger.TEN;
        for (int i =0;i<k;i++)
        {
            ans=  ans.multiply(m);
            m=m.subtract(BigInteger.ONE);
        }

        BigInteger nine = BigInteger.TEN;
        nine = nine.subtract(BigInteger.ONE);

        if(s.charAt(0)>='0' && s.charAt(0)<='9' )
        {

            for (int i =0;i<kq;i++)
                ans= ans.multiply(BigInteger.TEN)   ;
            out.print(ans);
        }
        else
        {

                for (int i =0;i<kq;i++)
                    ans = ans.multiply(BigInteger.TEN);
                out.print(ans.divide(BigInteger.TEN).multiply(nine));

        }

        out.close();
    }
  public static   long gcd (long a, long b) {

        return b>0 ? gcd (b, a % b) : a;

    }

    public static void dfs(int v, List<Integer> way)
    {

        visited[v]=true;
        for (int i =0; i<g[v].size(); i++){

            int p = g[v].get(i);
            if(!visited[p]){
          //      found++;
                way.add(p+1);
                dfs(p, way);
            };

        }

    }
    public static void Resheto(int n)
    {
        prime[0] = prime[1] = false;
        for (int i=2; i<=n; ++i)
            if (prime[i])
                if (i * 1l * i <= n)
                    for (int j=i*i; j<=n; j+=i)
                        prime[j] = false;
    }

    public static String nextToken() throws IOException {
        while ( st == null || !st.hasMoreTokens() ) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public static int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public static double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public static long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public static int[] ReadIntArray(int n) throws IOException {
        int[] a = new int[n];
        for ( int i = 0; i < n; i++ ) {
            a[i] = nextInt();
        }
        return a;

    }
    public static void PrintArray(int[] arr) throws IOException
    {
        for ( int anArr : arr ) out.print(anArr+" ");

    }
    public static long[] ShuffleArray(long [] arr)
    {
        Random rnd = new Random();

        int n = arr.length;
        long    temp;
        int     ind;
        while (n > 1)
        {
            ind = rnd.nextInt(n--);
            temp = arr[ind];
            arr[ind] = arr[n];
            arr[n] = temp;
        }

        return arr;
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Alik
 */
public class A {
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String s = in.readLine();
        BigInteger ans = BigInteger.ONE;
        BigInteger ten [] = new BigInteger [11];
        for (int i = 0; i < 11; i++) ten[i] = new BigInteger(i + "");
        int k = 10;
        boolean w [] = new boolean [300];

        for (int i = 0; i < s.length(); i++) {
            if (i == 0 && (s.charAt(i) < '0' || s.charAt(i) > '9')) {
                ans = ans.multiply(ten[9]);
                if (s.charAt(i) != '?') { k--; w[s.charAt(i)] = true;}
            } else
            if (s.charAt(i) == '?') ans = ans.multiply(ten[10]); else
            if ((s.charAt(i) >= 'A' && s.charAt(i) <= 'J')  && !w[s.charAt(i)]) { ans = ans.multiply(ten[k]); k--; w[s.charAt(i)] = true;}
        }
        System.out.println(ans);
    }
}

	import java.util.Arrays;
/*
 * by the name of allah
 *
 * Hazem
 *
 *
 * */
import java.util.Scanner;
import java.util.Scanner;
public class Main{
	    public static void main(String[] args) {
	        Scanner sc=new Scanner(System.in);
	        String str = sc.next();
	        int ans =1 ;String tmp = ""; int x=10;
	        for(int i=0 ; i<str.length();i++){
	        	if(str.charAt(i)=='?' && i!=0) ans = ans *10 ;
	        	if(str.charAt(i)=='?' && i==0) ans = ans *9 ;

	        	if((str.charAt(i)>='A' && str.charAt(i)<='J' && !tmp.contains(str.charAt(i)+"")) && i==0){ans*=x-1; x--;} ;
	        	if((str.charAt(i)>='A' && str.charAt(i)<='J') && i!=0 && !tmp.contains(str.charAt(i)+"")){ans*=x; x--;} ;
	        	if((str.charAt(i)>='A' && str.charAt(i)<='J') ) tmp+=str.charAt(i);

	        }
	System.out.println(ans);

	      }

	    public static boolean ispalindorm(String str){
	    	int i = 0 ; int j = str.length()-1;
	    	while(true){
	    		if(i==j || i-j>1 ) break;
	    		if(str.charAt(i)!=str.charAt(j))return false ;

	    		j--;i++;

	    	}
		return true;

	    }

	        }

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner cin = new Scanner(System.in);
        BigInteger ten=BigInteger.valueOf(10);
        String str;
        int[] mark=new int[11];
        int i,len;
        while(cin.hasNext()){
            str=cin.next();
            len=str.length();
            BigInteger ans=BigInteger.ONE;
            for(i=0;i<10;i++)
                mark[i]=0;
            boolean fi=false;
            if(str.charAt(0)=='?')ans=BigInteger.valueOf(9);
            else if(str.charAt(0)>='A'){
                fi=true;
                mark[str.charAt(0)-'A']=1;
            }
            for(i=1;i<len;i++){
                if(str.charAt(i)=='?')ans=ans.multiply(ten);
                else if(str.charAt(i)>='A'){
                    mark[str.charAt(i)-'A']=1;
                }
            }
            int cnt=0;
            for(i=0;i<10;i++)
                if(mark[i]==1)cnt++;
            for(i=0;i<cnt;i++){
                if(i==0&&fi)ans=ans.multiply(BigInteger.valueOf(9));
                else ans=ans.multiply(BigInteger.valueOf(10-i));
            }
            System.out.println(ans);
        }

    }
}

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskA2 solver = new TaskA2();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA2 {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    char[] input = in.next().toCharArray();
	    long ans = 1;
	    int zeros = 0;
	    boolean[] letter = new boolean[26];
	    for(int i = 0; i < input.length; i++) {
		    char c = input[i];
		    if(Character.isDigit(c)) continue;
		    if(c >= 'A' && c <= 'Z'){
			    letter[c - 'A'] = true;
			    continue;
		    }
		    if(i != 0) zeros++;
		    else ans *= 9;
	    }
	    int different = 0;
	    for(boolean b : letter) if (b) different++;
	    for(int i = 10; i > 10 - different; i--) {
		    if (i == 10 && input[0] >= 'A' && input[0] <= 'Z') ans *= (i - 1);
		    else ans *= i;
	    }
	    out.print(ans);
	    for(int i = 0; i < zeros; i++) out.print(0);

    }
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			if (Character.isValidCodePoint(c))
				res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public String next() {
		return readString();
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void close() {
		writer.close();
	}
	public void print(long i) {
		writer.print(i);
	}
	public void print(int i) {
		writer.print(i);
	}
}

import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.math.BigInteger.ONE;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class A {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	static void solve() throws Exception {
		String s = next();
		BigInteger ans = ONE;
		boolean have[] = new boolean[10];
		int cnt = 0;
		int tens = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			int mul;
			if (c == '?') {
				mul = i == 0 ? 9 : 10;
			} else if ('0' <= c && c <= '9') {
				mul = 1;
			} else if ('A' <= c && c <= 'J') {
				if (have[c - 'A']) {
					mul = 1;
				} else {
					have[c - 'A'] = true;
					mul = i == 0 ? 9 : 10 - cnt;
					++cnt;
				}
			} else {
				throw new AssertionError();
			}
			if (mul == 10) {
				++tens;
			} else if (mul != 1) {
				ans = ans.multiply(BigInteger.valueOf(mul));
			}
		}
		out.print(ans);
		for (int i = 0; i < tens; i++) {
			out.print('0');
		}
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class A {

    static StringTokenizer st;
    static BufferedReader in;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        String s = next();
        BigInteger ans = BigInteger.ONE;
        int cnt = 0;
        boolean[]used = new boolean[256];
        for (int i = 0; i < s.length(); i++) {
            char w = s.charAt(i);
            if (Character.isDigit(w))
                continue;
            if (w=='?') {
                if (i==0)
                    ans = ans.multiply(BigInteger.valueOf(9));
                else
                    ans = ans.multiply(BigInteger.valueOf(10));
            }
            else {
                used[w] = true;
            }
        }
        for (int i = 0; i < 256; i++) {
            if (used[i])
                cnt++;
        }
        int q = 10;
        if (Character.isLetter(s.charAt(0))) {
            ans = ans.multiply(BigInteger.valueOf(9));
            q--;
            cnt--;
        }
        for (int i = cnt; i >= 1; i--) {
            ans = ans.multiply(BigInteger.valueOf(q));
            q--;
        }
        pw.println(ans);
        pw.close();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * User: bpk
 * Date: 13.06.13
 * Time: 21:27
 */
public class SpecialTaskA2 {

    public static void printNumberOfCodes(String string) {
        long result = 1;
        List<Character> characters = new LinkedList<Character>();
        int numberOfQuestionMarks = 0;

        if (string.isEmpty()) {
            System.out.println(0);
            return;
        }

        char firstChar = string.charAt(0);
        boolean isQuestionMark = isQuestionMark(firstChar);
        boolean isFirstCharAlphabet = isCharOfAlphabet(firstChar);

        if (string.length() == 1 && !isFirstCharAlphabet && !isQuestionMark) {
            System.out.println(1);
            return;
        }

        if (isQuestionMark) {
            result = result * 9;
        }

        if (isFirstCharAlphabet) {
            if (!characters.contains(firstChar)) {
                characters.add(firstChar);
            }
            result = result * 9;
        }

        for (int i = 1; i < string.length(); i++) {
            char character = string.charAt(i);
            if (characters.size()<10 && isCharOfAlphabet(character)) {
                if (!characters.contains(character)) {
                    result = result * (10-characters.size());
                    characters.add(character);
                }
            } else if (isQuestionMark(character)) {
                numberOfQuestionMarks++;
            }
        }

        System.out.print(result);
        for(int i=0;i<numberOfQuestionMarks;i++){
            System.out.print("0");
        }
    }

    private static boolean isCharOfAlphabet(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J';
    }

    private static boolean isQuestionMark(char c) {
        return c == '?';
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String inputString = in.readLine();
        in.close();
        SpecialTaskA2.printNumberOfCodes(inputString);
    }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static void main(String [] args ) {
		try{
			String str;
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			BufferedOutputStream bos = new BufferedOutputStream(System.out);
			String eol = System.getProperty("line.separator");
			byte [] eolb = eol.getBytes();

			str  = br.readLine();
			int numQ = 0;
			int [] numL = new int[10];
			for(int i = 0 ; i < 10 ; i++) {
				numL[i] = 0;
			}
			for(int i = 1 ; i < str.length() ; i++) {
				char c = str.charAt(i);
				if(c=='?') {
					numQ++;
				} else {
					int x = Character.getNumericValue(c);
					if((x>=10)&&(x<35)) {
						numL[x-10] ++;
					}
				}
			}
			BigInteger ans = new BigInteger("1");
			BigInteger ten = new BigInteger("10");
			char c = str.charAt(0);
			if(c=='?') {
				ans = ans.multiply(new BigInteger("9"));
			}
			int sp = 0;
			int x = Character.getNumericValue(c);
			if((x>=10)&&(x<35)) {
				sp = x-10;
				int numDiff =  0;
				for(int i = 0 ; i < 10 ; i++) {
					if(i!=sp) {
						if(numL[i]>0) {
							numDiff++;
						}
					}
				}
				ans = ans.multiply(new BigInteger("9"));
				int iter = 9;
				while(numDiff>0) {
					ans = ans.multiply(new BigInteger(new Integer(iter).toString()));
					iter--;
					numDiff--;
				}
			} else {
				int numDiff =  0;
				for(int i = 0 ; i < 10 ; i++) {
					if(numL[i]>0) {
						numDiff++;
					}
				}
				int iter = 10;
				while(numDiff>0) {
					ans = ans.multiply(new BigInteger(new Integer(iter).toString()));
					iter--;
					numDiff--;
				}
			}

			bos.write(ans.toString().getBytes());
			for(int i = 0 ; i < numQ ; i++) {
				bos.write("0".getBytes());
			}
			bos.write(eolb);
			bos.flush();
		}  catch(IOException ioe) {
			ioe.printStackTrace();
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class A {
	BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

    public long nCr(int n, int k){
		long ans = 1;
		int cb[] = new int[k];

		for (int i=0; i<k; i++)
			cb[i] = i + 1;
		for (int i=n; i>=n-k+1; i--){
			ans *= i;
			for (int j=0; j<cb.length; j++)
				if (ans % cb[j] == 0){
					ans /= cb[j];
					cb[j] = 1;
				}
		}
		return ans;
	}

    public boolean ischar(char c){
    	return c >= 'A' && c <= 'Z';
    }

	public void solve() throws IOException {
		char[] S = reader.readLine().toCharArray();

		boolean[] set = new boolean[26];
		long ans = 1;
		for(int i = 0; i < S.length; i++){
			if( ischar(S[i]) ){
				set[ S[i]-'A' ] = true;
			}
			else if( S[i] == '?') {
				if(i == 0)
					ans *= 9;
				else
					ans *= 10;
			}
		}
		int count = 0;
		for(int i = 0; i < 26; i++){
			if( set[i] ) count++;
		}
		if( ischar(S[0]) && count >= 10){
			out.println(0); return;
		}

		for(int i = 1; i <= count; i++){
			ans = ans * (11-i);
		}
		if(ischar(S[0])){
			ans = ans / 10 * 9;
		}

//		if(ischar(S[0])){
//			long ans2 = 9;
//			ans2 *= nCr(9, count-1);
//			for(int i = 1; i <= count-1; i++)
//				ans2 *= i;
//			ans *= ans2;
//		}
//		else{
//			long ans2 = nCr(10, count);
//			for(int i = 1; i <= count; i++)
//				ans2 *= i;
//			ans *= ans2;
//		}
		out.println( ans );
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new A().run();
	}

	public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class SpecialTask {
	public static void main(String[] args) {
		PrintWriter pw = new PrintWriter(System.out);
	    reader(System.in);
	    String s = n();
	    int[] arr = new int[10];
	    int res = 1;
	    int k = 10;
	    if (s.charAt(0) == '?') {
			res = 9;
    	}
	    else if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J') {
			arr[s.charAt(0) - 'A']++;
			res = 9;
			k = 9;
    	}
	    int cntQ = 0;
	    for (int i = 1; i < s.length(); i++) {
	    	if (s.charAt(i) == '?') {
	    		cntQ++;
	    	}
	    	else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J' && arr[s.charAt(i) - 'A'] == 0) {
    			arr[s.charAt(i) - 'A']++;
    			res *= k;
    			k--;
	    	}
	    }
	    StringBuilder sb = new StringBuilder();
	    sb.append(res);
	    for (int i = 0; i < cntQ; i++)
	    	sb.append(0);
	    pw.println(sb);
	    pw.close();
	}

	private static BufferedReader br;
	private static StringTokenizer st;

	static void reader(InputStream stream) {
	    try {
	        br = new BufferedReader(new InputStreamReader(stream));
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	}

	static String n() {
	    while (st == null || !st.hasMoreTokens()) {
	        try {
	            st = new StringTokenizer(br.readLine());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	    }
	    return st.nextToken();
	}

	static int nI() {
	    return Integer.parseInt(n());
	}

	static long nL() {
	    return Long.parseLong(n());
	}
}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class A
{
	public static void main(String [] args) throws IOException
	{
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		String s = stdin.readLine();
		char c = s.charAt(0);
		int ans = 1;
		if (c == '?')
			ans *= 9;
		int cnt = 0, cnt2 = 0;
		boolean [] seen = new boolean[10];
		Arrays.fill(seen,false);
		if ( (int)c >= (int)'A' && (int)c <= (int)'J')
		{
			seen[(int)c-(int)'A'] = true;
			cnt = 1;
			ans *= 9;
		}
		for (int i = 1; i < s.length(); i++)
		{
			char d = s.charAt(i);
			if ( cnt < 10 && (int)d >= (int)'A' && (int)d <= (int)'J' && !seen[(int)d-'A'])
			{
				seen[(int)d - (int)'A'] = true;
				ans *= 10-cnt;
				cnt++;
			}
			else if (d == '?')
				cnt2++;
		}
		System.out.print(ans);
		for (int i = 0; i < cnt2; i++)
			System.out.print('0');
		System.out.println();
	}
}

import java.io.*;
import java.util.*;
import java.lang.*;

public class candle
	{
public static void main(String args[]) throws IOException
		{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int a[] = new int[11];
		char c[] = s.toCharArray();
		int result = 1;
		int m = 10;
		if('0'<=c[0] && c[0]<='9')
			{
			for(int i=1;i<c.length;i++)
				{
				if('A'<=c[i] && c[i]<='J')
					{
					a[c[i]-64]++;
					if(a[c[i]-64] == 1)
						{
						result = result*m;
						m--;
						}
					}
				else if(c[i] == '?')
					result = 10*result;
				}

			}
		else if(c[0] == '?')
			{
			result = 9;
			for(int i=1;i<c.length;i++)
				{
				if(c[i] == '?')
					result = result*10;
				else if('A' <= c[i] && c[i]<= 'J')
					{
					a[c[i]-64]++;
					if(a[c[i]-64] == 1)
						{
						result = result*m;
						m--;
						}
					}
				}
			}
		else
			{
			a[c[0]-64]++;
			result = 9;
			m = 9;
			for(int i=1;i<c.length;i++)
				{
				if(c[i] == '?')
					result = result*10;
				else if('A' <= c[i] && c[i]<= 'J')
					{
					a[c[i]-64]++;
					if(a[c[i]-64] == 1)
						{
						result = result*m;
						m--;
						}
					}

				}
			}
	        System.out.println(result);

		}
	}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Codeforces {
	FastScanner in;
	PrintWriter out;

	long fact(long count) {
		if (count == 0) return 1;
		else return fact(count - 1) * count;
	}

	public void solve() throws IOException {
		char[] c = in.next().toCharArray();
		BigInteger ans = BigInteger.ONE;
		if (c.length == 1) {
			if (c[0] >= '0' && c[0] <= '9') out.println(1);
			else out.println(9);
			return;
		}
		boolean[] was = new boolean[1000];
		boolean first = false;
		int count = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] == '?') {
				if (i != 0) ans = ans.multiply(BigInteger.valueOf(10));
				else {
					ans = ans.multiply(BigInteger.valueOf(9));
				}
			}
			if (c[i] >= 'A' && c[i] <= 'J') {
				if (i == 0) first = true;
				if (!was[c[i]]) {
					count++;
				}
				was[c[i]] = true;
			}
		}

		int dif = 10;
		if (first) {
			dif--;
			count--;
			ans = ans.multiply(BigInteger.valueOf(9));
		}
		long cur = 1;
		for (int i = 0; i < count; i++) {
			cur *= dif;
			dif--;
		}
		ans = ans.multiply(BigInteger.valueOf(cur));

		out.println(ans);
	}

	public void run() {
		try {
			in = new FastScanner();
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		boolean hasNext() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String s = br.readLine();
					if (s == null) {
						return false;
					}
					st = new StringTokenizer(s);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return true;
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new Codeforces().run();
	}
}

import java.util.*;

public class A1 // safe cracking beaver; http://codeforces.com/contest/316/problem/A1
{
	public static void main ( String [] args )
	{
		Scanner sc = new Scanner ( System.in );
		String input = sc.nextLine();

		// alg
		long answer = 1;
		StringBuilder strAnswer = new StringBuilder("");
		int numLetsSeen = 0;
		boolean[] letters = new boolean[10]; //A B C D E F G H I J; true means we've seen it before

		char front = input.charAt(0);
		if(front == '?')
			answer *= 9;
		else if (Character.isLetter(front))
		{
			letters[front - 'A'] = true;
			answer *= 9;
			numLetsSeen++;
		}
		// else if it's just a number, do nothing

		for(int i = 1; i < input.length(); i++)
		{
			char thisLet = input.charAt(i);
			if(thisLet == '?')
				strAnswer.append("0");
			//else if (Character.isLetter(thisLet))
			else if(thisLet - 'A' >= 0 && thisLet - 'A' < 10)
			{
				if(letters[thisLet - 'A'])
					continue; //we've seen it before
				answer *= (10 - numLetsSeen);
				numLetsSeen++;
				letters[thisLet - 'A'] = true;
			}
			//else if it's just a number, do nothing
		}

		//end alg. Print

		System.out.println(answer + strAnswer.toString());
	}
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package Practice;

import java.io.*;
import java.util.*;
/**
 *
 * @author Rohan
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        solve();
    }

    public static void solve() throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String S=br.readLine();
        boolean first_char=false;
        char fchar='A'; int qcount=0,count=10; int[] arr=new int[26]; long res=1;
        Arrays.fill(arr,0);
        for(int i=0;i<S.length();i++){
            if(i==0 && S.charAt(i)>='A' && S.charAt(i)<='J'){
                first_char=true; fchar=S.charAt(i); arr[S.charAt(i)-'A']=count; --count;
            }
            else if(i==0 && S.charAt(i)=='?') res*=9;
            else if(S.charAt(i)>='A' && S.charAt(i)<='J'){
                if(arr[S.charAt(i)-'A']==0){
                    arr[S.charAt(i)-'A']=count; --count;
                }
            }
            else if(S.charAt(i)=='?') ++qcount;
        }
        if(first_char) --arr[fchar-'A'];
        for(int i=0;i<26;i++) if(arr[i]>0) res*=arr[i];
        System.out.print(res);
        for(int i=0;i<qcount;i++) System.out.print("0");
        System.out.println();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class test {
	public static void main(String args[])
	{
		String s;
		BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
		try {
			s = rd.readLine();
			BigDecimal res = new BigDecimal(Integer.toString(1));
			BigDecimal x = new BigDecimal(Integer.toString(10));
			BigDecimal y = new BigDecimal(Integer.toString(1));
			BigDecimal z = new BigDecimal(Integer.toString(1));
			BigDecimal w = new BigDecimal(Integer.toString(-1));
			int n = s.length();
			int i;
			boolean [] cnt = new boolean[15];

			int sum = 0;
			if (s.charAt(0) == '?')
			{
					res = res.multiply(x.add(w));
					sum--;
			}

			for (i = 0;i < n;i++)
			{
				if (s.charAt(i) == '?')
				{
					sum++;
				}
				if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J')
					cnt[s.charAt(i) - 'A'] = true;
			}

			boolean flag = false;
			if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J')
				flag = true;

			for (i = 0;i < 10;i++)
			{
				if (cnt[i])
				{
					if (flag)
					{
						res = res.multiply(x.add(w));
						flag = false;
					}
					else
						res = res.multiply(x);
					x = x.add(w);

				}
			}
			System.out.print(res);
			for (i = 0;i < sum;i++)
				System.out.print(0);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class A
{
	public static void main(String [] args) throws IOException
	{
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		String s = stdin.readLine();
		char c = s.charAt(0);
		BigInteger ans = BigInteger.valueOf(1);
		if (c == '?')
			ans = ans.multiply(BigInteger.valueOf(9));
		int cnt = 0;
		boolean [] seen = new boolean[10];
		Arrays.fill(seen,false);
		if ( (int)c >= (int)'A' && (int)c <= (int)'J')
		{
			seen[(int)c-(int)'A'] = true;
			cnt = 1;
			ans = ans.multiply(BigInteger.valueOf(9));
		}
		for (int i = 1; i < s.length(); i++)
		{
			char d = s.charAt(i);
			if ( (int)d >= (int)'A' && (int)d <= (int)'J' && !seen[(int)d-'A'])
			{
				seen[(int)d - (int)'A'] = true;
				ans = ans.multiply(BigInteger.valueOf(10-cnt));
				cnt++;
			}
			else if (d == '?')
				ans = ans.multiply(BigInteger.valueOf(10));
		}
		System.out.println(ans);
	}
}

import java.util.*;
public class P316A1 {
	P316A1(Scanner in) {
		String s = in.next();
		long ans = 1;
		boolean[] seen = new boolean['J'-'A'+1];
		int specials = 10;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i) == '?')
				ans *= (i==0 ? 9 : 10);
			else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J') {
				if (seen[s.charAt(i)-'A'])
					continue;
				seen[s.charAt(i)-'A'] = true;
				ans *= (i==0 ? 9 : specials);
				specials--;
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new P316A1(new Scanner(System.in));
	}
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	public void solve() throws Exception {
		String s = sc.nextToken();
		int letters = 0;
		int questions = 0;

		boolean used [] = new boolean [26];
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				questions++;
			} else if (Character.isLetter(s.charAt(i))) {
				if (!used[s.charAt(i) - 'A']) {
					letters++;
					used[s.charAt(i) - 'A'] = true;
				}
			}
		}
		int all = 10;
		long result = 1;
		if (Character.isLetter(s.charAt(0))) {
			result = 9; letters--; all--;
		} else if (!Character.isDigit(s.charAt(0))) {
			result = 9; questions--;
		}
		for (int j = all; letters > 0; j--, letters--)
			result = result * j;
		out.print(result);
		for (int i = 0; i < questions; i++) {
			out.print("0");
		}
		out.println();
	}

	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Solution(), "", (1 << 26));
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

}

import java.util.*;
import java.math.*;
public class main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        int[] hash = new int[26];
        for(int i=0;i<26;i++)hash[i]=0;
        String now;
        now=cin.nextLine();
        char[] s = now.toCharArray();
        int len = now.length();
        int may = 0;
        int letter = 0;

        for(int i = 0;i<len;i++)
            if(s[i]=='?')may ++;
            else if(s[i]>='A'&&s[i]<='Z'){
                if(hash[s[i]-'A']==0){
                    letter ++;
                    hash[s[i]-'A']=1;
                }
            }

        BigInteger ans = BigInteger.valueOf(1);
        int pow1 = 10;
        for(int i =1;i<=letter;i++){
            if(s[0]>='A'&&s[0]<='J'&&i==1)ans = ans.multiply(BigInteger.valueOf(9));
            else ans = ans.multiply(BigInteger.valueOf(pow1));
            if(pow1==0)break;
            pow1 --;
        }
        for(int i=1;i<=may;i++){
            if(s[0]=='?'&&i==1)ans = ans.multiply(BigInteger.valueOf(9));
            else ans = ans.multiply(BigInteger.valueOf(10));
        }
    //  ans = ans.multiply(pow1.pow(letter));
    //  ans = ans.multiply(pow2.pow(may));
        System.out.println(ans);

    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
    public static void main (String[] args) throws FileNotFoundException
    {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run() throws FileNotFoundException
    {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }
    void solve ()
    {
        String sstr = in.nextLine();
        int n = sstr.length();
        int cnt1 = 0, cnt2 = 0;
        char str[] = sstr.toCharArray();
        BigInteger ans;
        ans = BigInteger.ONE;
        Boolean used[];
        used = new Boolean[30];
        int fl = 10;
        for (int i = 0; i < 30; i++)
        {
            used[i] = false;
        }
        if (str[0] == (char)'?')
        {
            ans = BigInteger.valueOf(9);
        }
        else if (str[0] >= 'A' && str[0] <= 'J')
        {
            ans = BigInteger.valueOf(9);
            used[str[0] - 'A'] = true;
            fl = 9;
        }
        for (int i = 1; i < n; i++)
        {
            if (str[i] == '?')
            {
                cnt1++;
            }
            else if (str[i] >= 'A' && str[i] <= 'J')
            {
                if (!used[str[i] - 'A'])
                {
                    cnt2++;
                    used[str[i] - 'A'] = true;
                }
            }
        }
        BigInteger cnt3;
        cnt3 = BigInteger.ONE;
        for (int i = fl; i > fl - cnt2; i--)
        {
            cnt3 = cnt3.multiply(BigInteger.valueOf(i));
        }
        for (int i = 0; i < cnt1; i++)
        {
            ans = ans.multiply(BigInteger.valueOf(10));
        }
        ans = ans.multiply(cnt3);
        out.print(ans);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class jmain {

	/**
	 * @param args
	 */

	static BufferedReader brscan = new BufferedReader(new InputStreamReader(
			System.in));
	static PrintWriter pw = new PrintWriter(System.out);
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		boolean[] alpha = new boolean[200];
		String strin = new String();

		// input //
		strin = brscan.readLine();
		long prob = 1;
		long probten = 0;
		int len = strin.length();
		int remaining = 10;

		for (int ii = 0; ii < len; ++ii)
		{
			char c = strin.charAt(ii);
			if (ii==0) {
				if (c=='?') {
					prob *= 9;
				} else if (!Character.isDigit(c) && !alpha[c]) {
					alpha[c] = true;
					prob *=9;
					remaining -= 1;
				}
			} else {
				if (c=='?') {
					probten += 1;
				} else if (!Character.isDigit(c) && !alpha[c]) {
					alpha[c] = true;
					prob *= remaining;
					remaining -= 1;
				}
			}
		}

		pw.print(prob);
		for (int i = 0; i < probten; ++i)
		{
			pw.print('0');
		}
		pw.println();
		pw.close();
	}

}

import java.util.LinkedList;
import java.util.Scanner;

public class Task316A2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		LinkedList<Character> aj = new LinkedList<Character>();
		int c = 1;
		boolean flag = false;
		if (s.charAt(0) == '?') {
			c = 9;
		} else if ((s.charAt(0) >= 'A') && (s.charAt(0) <= 'J')) {
			c = 9;
			aj.add(s.charAt(0));
			flag = true;
		}

		int qCount = 0;
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				qCount++;
			} else if ((s.charAt(i) >= 'A') && (s.charAt(i) <= 'J')) {
				if (!aj.contains(s.charAt(i))) {
					c *= (10 - aj.size());
					aj.add(s.charAt(i));
				}
			}
		}
		System.out.print(c);
		for (int i = 0; i < qCount; i++) {
			System.out.print(0);
		}
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * User: ������
 * Date: 12.06.2013
 * Time: 16:17:08
 */
public class ABBYY_3_A {
    Scanner scanner = new Scanner(System.in);
    BufferedReader buffered = new BufferedReader(new InputStreamReader(System.in));
    StreamTokenizer in = new StreamTokenizer(buffered);

    PrintWriter out = new PrintWriter(System.out);

    int nextInt() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    boolean isLetter(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J';
    }

    void main() throws Exception {
        String s = buffered.readLine();
        long ans = 1;
        boolean firstLetter = false;
        Set<Character> chars = new HashSet<Character>();
        if (s.charAt(0) == '?') ans *= 9;
        if (isLetter(s.charAt(0))) {
            firstLetter = true;
            chars.add(s.charAt(0));
        }

        int k0 = 0;
        for (int i=1; i<s.length(); i++) {
            char c = s.charAt(i);
            if (c == '?') k0++;
            if (isLetter(c)) chars.add(c);
        }

        for (int i=0; i<chars.size(); i++) {
            if (i==0 && firstLetter) ans *= 9;
            else ans *= 10-i;
        }

        System.out.print(ans);
        for (int i=0; i<k0; i++)
            System.out.print(0);
        System.out.println();
        System.out.flush();
    }

    public static void main(String[] args) throws Exception {
        new ABBYY_3_A().main();
    }
}

import java.io.*;
import java.util.*;

public class Main {

    StreamTokenizer in;
    PrintWriter out;
    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
    }

    int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    String nextStr() throws IOException {
        in.nextToken();
        return (String) in.sval;
    }

    void solve() throws IOException {
        String str = scanner.nextLine();
        int l = str.length();
        Character letter;
        String temp = "";
        int count = 1;
        ArrayList<Character> tempo = new ArrayList<Character>();

        for (int i = 0; i < l; i++) {
            int u = 1;
            letter = str.charAt(i);

            if ('0' <= letter && letter <= '9') {
                u = 1;
            } else if (letter == '?') {
                if (i == 0) {
                    u = 9;
                } else {
                    u = 10;
                }
            } else {
                if (tempo.contains(letter)) {
                    u = 1;
                } else {
                    if (i == 0) {
                        u = 9 - tempo.size();
                    } else {
                        u = 10 - tempo.size();
                    }
                    tempo.add(letter);
                }
            }

            count *= u;
        }

        out.print(count);
    }
}

import java.util.Scanner;

public class Prob316A {
	public static void main(String[] Args) {
		Scanner scan = new Scanner(System.in);
		char[] s = scan.next().toCharArray();
		long ans = 1;
		int count = 0;
		int append = 0;
		boolean[] temp = new boolean[(int) ('J' - 'A' + 1)];

		if (s[0] == '?')
			ans = 9;
		else if (s[0] >= 'A' && s[0] <= 'J') {
			temp[s[0] - 'A'] = true;
			ans = 9;
			count++;
		}

		for (int i = 1; i < s.length; i++) {
			if (s[i] == '?')
				append++;
			else if (s[i] >= 'A' && s[i] <= 'J') {
				if (!temp[s[i] - 'A']) {
					temp[s[i] - 'A'] = true;
					ans *= (10 - count);
					count++;
				}
			}
		}

		StringBuffer sb = new StringBuffer(""+ans);
		for (int i = 0; i < append; i++)
			sb.append("0");
		System.out.println(sb.toString());
	}
}

import java.math.*;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        boolean[] vis = new boolean[10];
        Scanner cin  = new Scanner(System.in);
        char[] s = cin.nextLine().toCharArray();
        BigInteger a  =BigInteger.valueOf(1);
        int qnum =0 ;
        for(int i=0;i<s.length;i++){
            if(s[i] == '?')
                qnum++;
            if(s[i]>='A'&&s[i]<='J')
                vis[s[i]-'A'] = true;
        }
        if(s[0]=='?'){
            qnum--;
            a = a.multiply(BigInteger.valueOf(9));
        }
        int cnt=10;
        for(int i=0;i<10;i++){
            if(vis[i]){
                if(s[0]<='J'&&s[0]>='A'&&cnt==10)
                    a = a.multiply(BigInteger.valueOf(9));
                else
                    a = a.multiply(BigInteger.valueOf(cnt));
                cnt--;
            }
        }
        System.out.print(a);
        for(int i=0;i<qnum;i++)System.out.print("0");
    }
}

import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main
{
    static StringTokenizer st=new StringTokenizer("");
    static BufferedReader br;
    ///////////////////////////////////////////////////////////////////////////////////

    public static void main(String args[]) throws FileNotFoundException, IOException, Exception
    {
        //Scanner in =new Scanner(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        //Scanner in=new Scanner(System.in);
        br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //StringTokenizer st;//=new StringTokenizer(br.readLine());
        //////////////////////////////////////////////////////////////////////////////////////

        String s=ns();
        long ans=1;
        long ch=10;
        boolean arr[]=new boolean[10];
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)=='?'){
                if(i==0)ans*=9l;
                else ans*=10;
            }
            else if(s.charAt(i)>='A' && s.charAt(i)<='J')
            {
                if(!arr[s.charAt(i)-'A'])
                {
                    arr[s.charAt(i)-'A']=true;
                    if(i==0)
                    {
                        ans*=9l;
                        ch--;
                    }
                    else {
                        ans*=ch;
                        ch--;
                    }
                }
            }
        }
        out.print(ans);
        //////////////////////////////////////////////////////////////////////////////////////
	out.close();
    }

    ///////////////////////////////////////////////////////////////////////////////
    static public class pair implements Comparable<pair>
    {
        int ind,cap;
        pair(){ind=0;cap=0;}
        pair(int first,int second){ind=first;cap=second;}
        public int compareTo(pair o) {
            return cap-o.cap;
        }
    }
    static public class triple implements Comparable<triple>
    {
        int ind,price,cap;
        triple(){ind=0;cap=0;price=0;}
        triple(int f,int s,int t){ind=f;cap=s;price=t;}
        public int compareTo(triple o) {
            return o.price-price;
        }

    }
    public static Integer ni() throws Exception
    {
        if(!st.hasMoreTokens())
            st=new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }
    public static BigInteger nb()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return BigInteger.valueOf(Long.parseLong(st.nextToken()));
    }
    public static Long nl() throws Exception
    {
        if(!st.hasMoreTokens())
            st=new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }
    public static Double nd()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return Double.parseDouble(st.nextToken());
    }
    public static String ns()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 *
 * @author sukhdeep
 */
public class Code {
    public static void main(String arg[]) throws IOException
    {
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

        StringBuilder str=new StringBuilder(r.readLine());
        BigInteger x=new BigInteger("1");
        int a[]=new int[10];
        int count=10;
           if(str.charAt(0)=='?')
               x=x.multiply(new BigInteger("9"));
           if(str.charAt(0)>=65&&str.charAt(0)<=74)
           {
               x=x.multiply(new BigInteger("9"));
               a[str.charAt(0)-65 ]=1;
               count--;
           }long ten=0;
           for(int i=1;i<str.length();i++)
           {
               if(str.charAt(i)=='?')
               {ten++;

               }
               else if((str.charAt(i)>=65&&str.charAt(i)<=74)&&a[str.charAt(i)-65]==0)
               {a[str.charAt(i)-65]=1;
               x=x.multiply(BigInteger.valueOf(count));
                   count--;
               }
           }
         System.out.print(x);
         for(int i=0;i<ten;i++)
   System.out.print("0");
         System.out.println();

}
}

import java.util.*;
import java.math.*;

public class a
{
    public static void main(String argv[])throws Exception
    {
        BigInteger []table = new BigInteger[11];
        for(int i = 0; i < 11; i++)
            table[i] = BigInteger.valueOf(i);

        String input = new Scanner(System.in).nextLine();
        boolean pass[] = new boolean[26];
        BigInteger ans = BigInteger.ONE;
        boolean check = false;
        int comma = 0;
        for(int i = 0; i < input.length(); i++)
        {
            char c = input.charAt(i);
            if(c == '?')
            {
                if(i != 0)
                    comma++;
                else
                    ans = table[9];
            }
            else if('A' <= c && c <= 'J')
            {
                pass[c - 'A'] = true;
                if(i == 0)
                    check = true;
            }
        }

        for(int i = 0, k = 0; i < 26; i++)
            if(pass[i])
            {
                ans = ans.multiply(table[((check && k == 0)? 9: (10 - k))]);
                k++;
            }
        System.out.print(ans);
        for(int i = 0; i < comma; i++)
            System.out.print("0");
        System.out.println("");
    }
}

import java.util.*;
public class SpecialTask_2{
    public static void main(String[]args){
        Scanner input = new Scanner(System.in);
        //while(true){
        String s = input.next();
        int an=1,x=0,a9=0,a10=0;
        boolean a[]=new boolean[10];
        for(int i=0; i<s.length(); i++){
            if(i==0&&(s.charAt(0)<'1'||s.charAt(0)>'9')){
                //System.out.println(i==0);
                a9++;
                if('A'<=s.charAt(0)&&s.charAt(0)<='J'){
                    a[s.charAt(0)-'A'] = true;x++;
                }
            }
            else if(s.charAt(i)=='?')
                a10++;
            else if('A'<=s.charAt(i)&&s.charAt(i)<='J'&& !a[s.charAt(i)-'A']){
                a[s.charAt(i)-'A'] = true;
                an *=(10-x);
                x++;
            }
        }
        //System.out.println(an+"*10^"+a10+"*9^"+a9);
            System.out.print(an*(int)Math.pow(9,a9));
            for(int i=0; i<a10; i++)System.out.print(0);
            System.out.println();
        //}
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class A {

    static StringTokenizer st;
    static BufferedReader in;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        String s = next();
        BigInteger ans = BigInteger.ONE;
        int cnt = 0;
        boolean[]used = new boolean[256];
        for (int i = 0; i < s.length(); i++) {
            char w = s.charAt(i);
            if (Character.isDigit(w))
                continue;
            if (w=='?') {
                if (i==0)
                    ans = ans.multiply(BigInteger.valueOf(9));
                else
                    ans = ans.multiply(BigInteger.valueOf(10));
            }
            else {
                used[w] = true;
            }
        }
        for (int i = 0; i < 256; i++) {
            if (used[i])
                cnt++;
        }
        int q = 10;
        if (Character.isLetter(s.charAt(0))) {
            ans = ans.multiply(BigInteger.valueOf(9));
            q--;
            cnt--;
        }
        for (int i = cnt; i >= 1; i--) {
            ans = ans.multiply(BigInteger.valueOf(q));
            q--;
        }
        System.out.println(ans);
        pw.close();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}

import java.io.StreamTokenizer;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		TokenizerReader in = new TokenizerReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA1 solver = new TaskA1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA1 {
    public void solve(@SuppressWarnings("UnusedParameters") int testNumber, TokenizerReader in, PrintWriter out) {
        char[] s = in.nextString().toCharArray();
        final int n = s.length;
        Set<Character> chars = new HashSet<Character>();
        int cntQuestions = 0;
        for (char c : s) {
            if (c == '?')
                ++cntQuestions;
            else if (c >= 'A' && c <= 'J')
                chars.add(c);
        }
        int cnt = chars.size();
        long res = 1;
        for (int i = 10, j = 0; j < cnt; --i, ++j)
            res *= i;
        if (s[0] >= 'A' && s[0] <= 'J') {
            long sub = 1;
            for (int i = 9, j = 0; j < cnt-1; --i, ++j)
                sub *= i;
            res -= sub;
        }
        if (s[0] == '?') {
            res *= 9;
            --cntQuestions;
        }

        out.print(res);
        for (int i = 0; i < cntQuestions; ++i)
            out.print('0');
        out.println();
    }
}

class TokenizerReader extends StreamTokenizer {
    public TokenizerReader(InputStream in) {
        super(new BufferedReader(new InputStreamReader(in)));
        defaultConfig();
    }

    public String nextString() {
        try {
            nextToken();
        } catch (IOException e) {
            throw new RuntimeException("nextString: exception in line " + lineno(), e);
        }
        return sval;
    }

    public void defaultConfig() {
        resetSyntax();
        wordChars(33, 126);
        whitespaceChars(0, ' ');
    }

    }

import java.io.*;
import java.util.*;

public class temp {
   public static void main (String [] args) throws Exception {
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintStream out = System.out;
      String n = f.readLine();
      long pos = 1;
      int[] ar = new int[26];
      boolean first = true;
      for(char c:n.toCharArray()){
         if(c>='0' && c<='9'){
         }
         else if(c>='A' && c<='Z'){
          ar[c-'A']++;
          }
         else if(c=='?'){
            if(first) pos*=9;
            else
            pos*=10;
          }
          first = false;
      }
      int count = 10;
      for(int a:ar){
         if(a>0){
            if(count == 10 && n.charAt(0)>='A' && n.charAt(0)<='Z')
            pos*=9;
            else
            pos*=count;
            count --;
         }
      }
      out.println(pos);
   }
}

import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		boolean firstLetter = false;
		boolean used[] = new boolean[11];
		int diffLetters = 0;
		for (int i = 0; i < 11; i++)
			used[i] = false;

		String s;
		s = in.next();
		int len = s.length();
		BigInteger ans = BigInteger.ONE;

		if (s.charAt(0) == '?')
			ans = BigInteger.valueOf(9);
		else
		{
			for (int i = 0; i < 10; i++)
				if (s.charAt(0) - 'A' == i)
				{
					firstLetter = true;
					used[i] = true;
				}
		}
		for (int i = 1; i < len; i++)
		{
			if (s.charAt(i) == '?')
			{
				ans = ans.multiply(BigInteger.TEN);
			}
			else
			{
				for (int j = 0; j < 10; j++)
					if (s.charAt(i) - 'A' == j)
					{
						if (used[j] == true)
							continue;
						diffLetters++;
						used[j] = true;
					}
			}
		}
		int rem = 10;
		if (firstLetter)
		{
			rem--;
			ans = ans.multiply(BigInteger.valueOf(9) );
		}
		for (int i = 0; i < diffLetters; i++)
		{
			ans = ans.multiply(BigInteger.valueOf(rem) );
			rem--;
		}
		out.println(ans);
		out.flush();

	}

}

import java.util.*;
import java.io.*;
import java.math.*;

public class A2 {
    public static Scanner scan = new Scanner(System.in);
    public static boolean bg = false;

    public static void main(String[] args) throws Exception {
        char[] l1 = scan.next().toCharArray();
        long fin = 1;
        int zero = 0;
        HashSet<Character> s1 = new HashSet();
        int t1 = 10;
        for (int i=0;i<l1.length;i++){
            char cur = l1[i];
            if (i==0){
                if (cur=='?'){
                    fin*=9;
                }
                if (Character.isAlphabetic(cur) ){
                    if (!s1.contains(cur)){
                        fin*=9;
                        t1=9;
                        s1.add(cur);
                    }
                }
            }
            else {
                if (cur=='?'){
                    zero++;
                }
                if (Character.isAlphabetic(cur) ){
                    if (!s1.contains(cur)){
                        fin*=t1;
                        t1--;
                        if (t1<1)t1=1;
                        s1.add(cur);
                    }
                }
            }
        }
        if (bg) System.out.println(fin);
        if (bg) System.out.println(zero);
        StringBuilder fin1 = new StringBuilder();
        fin1.append(fin+"");
        for (int i=0;i<zero;i++){
            fin1.append('0');
        }
        System.out.println(fin1);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class SpecialTask2 {
    static class A {

        public void runit(String in) {
            boolean isAskFirst = false, isLetterFirst = false;
            if (in.charAt(0)>='A') isLetterFirst = true;
            else if (in.charAt(0)=='?') isAskFirst = true;
            boolean[] used = new boolean[10];
            int nLett = 0;
            int nAsk = 0;
            for (int i = 0; i < in.length(); i++) {
                char c = in.charAt(i);
                if (c >= 'A') {
                    if (!used[c - 'A']) {
                        used[c - 'A'] = true;
                        ++nLett;
                    }
                } else if (c=='?') ++nAsk;
            }
            long pre = 1;
            if (isAskFirst) {
                pre *= 9;
                --nAsk;
            }
            for (int i = 10; i > 10 - nLett; --i) pre *= i;
            if (isLetterFirst) pre = (pre * 9) / 10;
            System.out.print(pre);
            for (int i = 0; i < nAsk; i++) {
                System.out.print('0');
            }
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        A a = new A();
        a.runit(in.readLine());
    }
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	static	Scanner in;
	static PrintWriter out;

	public void run() {
		String s = in.next();
		BigInteger ans = BigInteger.valueOf(1);
		int n = s.length();
		boolean[] c = new boolean[10];
		int cnt = 10;
		int k9 = 0;
		int k10 = 0;
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == '?') {
				if (i == 0) {
					++k9;
				} else {
					++k10;
				}
			}
			if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J') {
				int k = s.charAt(i) - 65;
				if (!c[k]) {
					c[k] = true;
					if (i == 0)
						++k9;
					else
						ans = ans.multiply(BigInteger.valueOf(cnt));
					--cnt;
				}
			}
		}
		out.print(ans.multiply(BigInteger.valueOf(9).pow(k9)));
		for (int i = 0; i < k10; ++i) {
			out.print('0');
		}
	}

	public static void main(String[] arg) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		new Main().run();
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    StreamTokenizer ST;
    PrintWriter out;
    BufferedReader br;
    Scanner in;

    public static void main(String[] args) throws IOException {
        new Thread(new Main()).start();
    }

    @Override
    public void run() {
        try {
            //out = new PrintWriter(new BufferedOutputStream(new FileOutputStream("E:\\NetBeansProjects\\TopCoder\\src\\output.out")));
            out = new PrintWriter(System.out);
            in = new Scanner(System.in);
            //in = new Scanner(new FileReader("E:\\NetBeansProjects\\TopCoder\\src\\input.in"));
            //br = new BufferedReader(new FileReader("E:\\NetBeansProjects\\TopCoder\\src\\input.in"));
            br = new BufferedReader(new InputStreamReader(System.in));
            ST = new StreamTokenizer(br);
            solve();
            out.close();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }

    private int readInt() throws IOException {
        ST.nextToken();
        return (int) ST.nval;
    }

    private double readDouble() throws IOException {
        ST.nextToken();
        return ST.nval;
    }

    private String readString() throws IOException {
        ST.nextToken();
        return ST.sval;
    }
    boolean[] used;
    ArrayList<ArrayList<Integer>> ans = new ArrayList<ArrayList<Integer>>();
    ArrayList<ArrayList<Integer>> graph = new ArrayList<ArrayList<Integer>>();

    public void dfs(int v, ArrayList<Integer> comp) {
        used[v] = true;
        comp.add(v);
        for (int i = 0; i < graph.get(v).size(); ++i) {
            int to = graph.get(v).get(i);
            if (!used[to]) {
                dfs(to, comp);
            }
        }
    }

    public void findComponents() {
        for (int i = 0; i < used.length; ++i) {
            used[i] = false;
        }
        for (int i = 0; i < used.length; ++i) {
            if (!used[i]) {
                ArrayList<Integer> comp = new ArrayList<Integer>();

                dfs(i, comp);
                // work with component
                ans.add(comp);
            }
        }
    }

    public void solve() throws IOException {
//        int n = readInt();
//        int x = readInt();
//        int[] g = new int[n];
//        used = new boolean[n];
//        for (int i = 0; i < n; ++i) {
//            g[i] = readInt();
//            ArrayList<Integer> tmp = new ArrayList<Integer>();
//            if (g[i] != 0) {
//                tmp.add(g[i] - 1);
//            }
//            graph.add(tmp);
//        }
//        findComponents();
//
//        for (int i = 0; i < ans.size(); ++i) {
//            System.err.println(ans.get(i));
//        }

        char[] s = in.nextLine().toCharArray();
        BigInteger ret = new BigInteger("1");
        Set<Character> chars = new HashSet<Character>();
        HashMap<Character, Integer> map = new HashMap<Character, Integer>();
        boolean[] digits = new boolean[10];
        int[] ans = new int[11];
        Arrays.fill(digits, true);
        for (int i = 0; i < s.length; ++i) {
            if (s[i] == '?') {
                if (i == 0) {
                    ans[9]++;
                    //ret = ret.multiply(new BigInteger("9"));
                } else {
                    ans[10]++;
                    //ret = ret.multiply(BigInteger.TEN);
                }
            } else if (Character.isLetter(s[i])) {
                int cnt = 0;
                for (int j = 0; j < digits.length; ++j) {
                    if (digits[j]) {
                        ++cnt;
                    }
                }
                if (i == 0) {
                    cnt = 9;
                }
                if (!digits[s[i] - 'A']) {
                    cnt = 1;
                }
                digits[s[i] - 'A'] = false;
                ans[cnt]++;
                //ret = ret.multiply(new BigInteger(String.valueOf(cnt)));
            }
        }
        for (int i = 0; i < ans.length - 1; ++i) {

            if (ans[i] != 0) {
                BigInteger tmp = new BigInteger(String.valueOf(i));
                tmp = tmp.pow(ans[i]);
                ret = ret.multiply(tmp);
            }
        }
        out.print(ret.toString());
        for (int i = 0; i < ans[10]; ++i) {
            out.print("0");
        }
        out.println();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    StreamTokenizer ST;
    PrintWriter out;
    BufferedReader br;
    Scanner in;

    public static void main(String[] args) throws IOException {
        new Thread(new Main()).start();
    }

    @Override
    public void run() {
        try {
            //out = new PrintWriter(new BufferedOutputStream(new FileOutputStream("E:\\NetBeansProjects\\TopCoder\\src\\output.out")));
            out = new PrintWriter(System.out);
            in = new Scanner(System.in);
            //in = new Scanner(new FileReader("E:\\NetBeansProjects\\TopCoder\\src\\input.in"));
            //br = new BufferedReader(new FileReader("E:\\NetBeansProjects\\TopCoder\\src\\input.in"));
            br = new BufferedReader(new InputStreamReader(System.in));
            ST = new StreamTokenizer(br);
            solve();
            out.close();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }

    private int readInt() throws IOException {
        ST.nextToken();
        return (int) ST.nval;
    }

    private double readDouble() throws IOException {
        ST.nextToken();
        return ST.nval;
    }

    private String readString() throws IOException {
        ST.nextToken();
        return ST.sval;
    }

    public void solve() {
        char[] s = in.nextLine().toCharArray();
        BigInteger ret = new BigInteger("1");
        Set<Character> chars = new HashSet<Character>();
        HashMap<Character, Integer> map = new HashMap<Character, Integer>();
        boolean[] digits = new boolean[10];
        Arrays.fill(digits, true);
        for (int i = 0; i < s.length; ++i) {
            if (s[i] == '?') {
                if (i == 0) {
                    ret = ret.multiply(new BigInteger("9"));
                } else {
                    ret = ret.multiply(BigInteger.TEN);
                }
            } else if (Character.isLetter(s[i])) {
                int cnt = 0;
                for (int j = 0; j < digits.length; ++j) {
                    if (digits[j]) {
                        ++cnt;
                    }
                }
                if (i == 0) {
                    cnt = 9;
                }
                if (!digits[s[i] - 'A']) {
                    cnt = 1;
                }
                digits[s[i] - 'A'] = false;
                ret = ret.multiply(new BigInteger(String.valueOf(cnt)));
            }
        }
        out.println(ret.toString());
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * User: ������
 * Date: 12.06.2013
 * Time: 16:17:08
 */
public class ABBYY_3_A {
    Scanner scanner = new Scanner(System.in);
    BufferedReader buffered = new BufferedReader(new InputStreamReader(System.in));
    StreamTokenizer in = new StreamTokenizer(buffered);

    PrintWriter out = new PrintWriter(System.out);

    int nextInt() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    boolean isLetter(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J';
    }

    void main() throws Exception {
        String s = buffered.readLine();
        long ans = 1;
        boolean firstLetter = false;
        Set<Character> chars = new HashSet<Character>();
        if (s.charAt(0) == '?') ans *= 9;
        if (isLetter(s.charAt(0))) {
            firstLetter = true;
            chars.add(s.charAt(0));
        }

        int k0 = 0;
        for (int i=1; i<s.length(); i++) {
            char c = s.charAt(i);
            if (c == '?') k0++;
            if (isLetter(c)) chars.add(c);
        }

        for (int i=0; i<chars.size(); i++) {
            if (i==0 && firstLetter) ans *= 9;
            else ans *= 10-i;
        }

        System.out.print(ans);
        for (int i=0; i<k0; i++)
            System.out.print(0);
        System.out.println();
        System.out.flush();
    }

    public static void main(String[] args) throws Exception {
        new ABBYY_3_A().main();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        long ans = 1;
        HashSet<Character> H = new HashSet<Character>();
        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) == '?')
                if (i == 0)
                    ans *= 9;
                else
                    ans *= 10;
            else if (Character.isLetter(s.charAt(i)))
                H.add(s.charAt(i));
        if (H.size() > 10)
            System.out.println(0);
        else {
            if (H.size() > 0) {
                if (Character.isLetter(s.charAt(0)))
                    ans *= 9;
                else
                    ans *= 10;
                for (int i = 1; i < H.size(); i++)
                    ans *= 10 - i;
            }
            System.out.println(ans);
        }
    }
}

import java.util.*;

public class test{

	void begin(){
		Scanner read = new Scanner(System.in);
		int idx,alpa,len,kss,pos,k,i;
		String st;
		st = read.next();
		len = st.length();

		if (len<=5){
		kss=1; idx=0; pos=1; alpa=10;
		while (idx<len){

			switch (st.charAt(idx)){
				case '?' :	if(kss==1){ pos *= 9;}
							else pos *= 10;
							break;
				case '0': break;
				case '1': break;
				case '2': break;
				case '3': break;
				case '4': break;
				case '5': break;
				case '6': break;
				case '7': break;
				case '8': break;
				case '9': break;
				default :	if (kss==1){ pos *=9; alpa--;}
							else { pos *=alpa; alpa--;}
							st = st.replace(st.charAt(idx),'1');
							break;
			}

			idx++; kss++;
		}
		System.out.println(pos);
		} else
		{
			kss=1; idx=0; pos=1; alpa=10; k=0;
			while (idx<len){

				switch (st.charAt(idx)){
					case '?' :	if(kss==1){ pos *= 9;}
								else {k++;};
								break;
					case '0': break;
					case '1': break;
					case '2': break;
					case '3': break;
					case '4': break;
					case '5': break;
					case '6': break;
					case '7': break;
					case '8': break;
					case '9': break;
					default :	if (kss==1){ pos *=9; alpa--;}
								else { pos *=alpa; alpa--;}
								st = st.replace(st.charAt(idx),'1');
								break;
				}
				idx++; kss++;
			}
			System.out.print(pos);
			for (i=0;i<k;i++)
				System.out.print("0");
			System.out.println();
		}
	}

	public static void main(String[] args){
		test mulai = new test();
		mulai.begin();
	}
}

import java.io.IOException;

public class CFA {

	private static final int IN_BUFFER_SIZE = 1 << 16;
	private static final int OUT_BUFFER_SIZE = 1 << 16;
	private byte[] input = new byte[IN_BUFFER_SIZE];
	private int ix = IN_BUFFER_SIZE;
	private int bytesRead = ix;
	private byte[] output = new byte[OUT_BUFFER_SIZE];
	private int ox = 0;

	private void readMore() {
		try {
			bytesRead = System.in.read(input, 0, IN_BUFFER_SIZE);
			if (bytesRead <= 0)
				throw new RuntimeException();
			ix = 0;
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

	private void flushOut() {
		System.out.write(output, 0, ox);
		ox = 0;
	}

	private void append(char c) {
		if (ox == OUT_BUFFER_SIZE)
			flushOut();
		output[ox++] = (byte) c;
	}

	private int charArrayLength;

	private void nextCharArray(char[] ca) {
		skipSpaces();
		if (ix == bytesRead) {
			readMore();
		}
		charArrayLength = 0;
		ca[charArrayLength++] = (char) input[ix++];
		while (true) {
			if (ix == bytesRead) {
				try {
					readMore();
				} catch (RuntimeException e) {
					return;
				}
			}
			char c = (char) input[ix++];
			if (c < '0')
				break;
			ca[charArrayLength++] = c;
		}
	}

	int cntSize;

	private void skipSpaces() {
		while (true) {
			if (ix == bytesRead) {
				readMore();
			}
			if (input[ix] > ' ')
				break;
			ix++;
		}
	}

	private char[] nn = new char[32];

	private void printLong(long n) {
		if (n == 0) {
			append('0');
		} else {
			if (n < 0) {
				append('-');
				n = -n;
			}
			int kk = 0;
			while (n > 0) {
				nn[kk++] = (char) (n % 10 + '0');
				n /= 10;
			}
			for (int i = kk - 1; i >= 0; i--) {
				append(nn[i]);
			}
		}
	}

	public static void main(String[] args) throws IOException {
		new CFA().work();
	}

	private void work() {

		char[] s = new char[100010];
		nextCharArray(s);
		int n = charArrayLength;
		boolean[] a = new boolean[256];
		int q = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == '?')
				q++;
			else
				a[s[i]] = true;
		}
		int letters = 0;
		for (int i = 'A'; i <= 'J'; i++) {
			if (a[i])
				letters++;
		}
		long res = 1;
		int k = 10;
		if (s[0] == '?') {
			res = 9;
			q--;
		} else if ('A' <= s[0] && s[0] <= 'J') {
			res = 9;
			letters--;
			k--;
		}
		while (letters-- > 0)
			res *= k--;
		printLong(res);
		while (q-- > 0)
			append('0');
		append('\n');

		if (ox > 0)
			flushOut();
		System.out.close();
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CF_316A1 solver = new CF_316A1();
        solver.solve(1, in, out);
        out.close();
    }

    static class CF_316A1 {
        public void solve(int testNumber, Scanner input, PrintWriter out) {
            ShortScanner in = new ShortScanner(input);
            char[] a = in.c();

            int cnt = 0;
            int[] f = new int[11];
            boolean[] visit = new boolean[26];
            for (int i = 0; i < a.length; ++i) {
                if (a[i] == '?')
                    f[(i == 0) ? 9 : 10]++;
                else if (Character.isLetter(a[i]) && !visit[a[i] - 'A']) {
                    f[(i == 0) ? 9 - cnt : 10 - cnt]++;
                    cnt++;
                    visit[a[i] - 'A'] = true;
                }
            }

            BigInteger ans = BigInteger.ONE;
            for (int i = 1; i <= 10; ++i) {
                ans = ans.multiply(BigInteger.valueOf(i).pow(f[i]));
            }

            out.println(ans);
        }

        class ShortScanner {
            Scanner in;

            ShortScanner(Scanner in) {
                this.in = in;
            }

            char[] c() {
                return in.next().toCharArray();
            }

        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;

import java.io.InputStreamReader;

public class Main{
    public static int permQ1(int x){
        int r=9;
        for(int i=1;i<x;i++){
            r*=10;
        }
        return r;
    }
    public static int perm1(int x){
        int r=9;
        for(int i=1;i<x;i++){
            r*=10-i;
        }
        return r;
    }

    public static int perm(int x){
        int r=1;
        for(int i=0;i<x;i++){
            r*=10-i;
        }
        return r;
    }
    public static int permQ(int x){
        int r=1;
        for(int i=0;i<x;i++){
            r*=10;
        }
        return r;
    }
    public static void main(String[] args)throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        boolean []x=new boolean[10];
        int countL=0;
        int countQ=0;
        int flag=0;
        for(int i=0;i<s.length();i++){
            if(i==0){
                if((int)s.charAt(i)>='A' && (int)s.charAt(i)<='J')
                    flag=1;
                else if(s.charAt(i)=='?')
                    flag=2;
            }
            if(s.charAt(i)=='?')
                countQ++;
            else if((int)s.charAt(i)>=(int)'A' && (int)s.charAt(i)<=(int)'J' && x[(int)s.charAt(i)-65]==false){
                countL++;
                x[(int)s.charAt(i)-65]=true;
            }
        }
        if(flag==0)
            System.out.print(perm(countL)*permQ(countQ));
        else if(flag==1)
            System.out.print(perm1(countL)*permQ(countQ));
        else
            System.out.print(perm(countL)*permQ1(countQ));

    }}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author vadimmm
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA1 solver = new TaskA1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA1 {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        char[] string = in.next().toCharArray();
        Set<Character> set = new HashSet<Character>(10);
        int counter = 0;
        for (int i = 0; i < string.length; ++i) {
            if (string[i] == '?')
                ++counter;
            else if (string[i] >= 'A' && string[i] <= 'J')
                set.add(string[i]);
        }
        long answer;
        if (string[0] >= 'A' && string[0] <= 'J')
            answer = 9 * factorial(9) / factorial(10 - set.size());
        else
            answer = factorial(10) / factorial(10 - set.size());
        if (string[0] == '?') {
            counter--;
            answer *= 9;
        }
        out.print(answer);
        for (int i = 0; i < counter; ++i)
            out.print(0);
    }
    private long factorial(long n) {
        if (n == 0) return 1;
        return n * factorial(n - 1);
    }
}

class InputReader {

    private static BufferedReader bufferedReader;
    private static StringTokenizer stringTokenizer;

    public InputReader(InputStream inputStream) {
        bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        stringTokenizer = null;
    }

    public String next() {
        while(stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            try {
                stringTokenizer = new StringTokenizer(bufferedReader.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return stringTokenizer.nextToken();
    }

    }

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA1 solver = new TaskA1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA1 {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String str = in.next();
        int size = str.length();
        int ans = 1;
        int cnt = 10;
        int[] let = new int[26];
        Arrays.fill(let, 1);
        char tmp = str.charAt(0);
        if (tmp == '?')  {
            ans *= 9;
        } else if (tmp >= 'A' && tmp <= 'Z') {
            --cnt;
            let[(int) tmp - 'A'] = cnt;
        }
        for (int i = 1; i < size; ++i) {
            tmp = str.charAt(i);
            if (tmp == '?')  {
                ans *= 10;
            } else if (tmp >= 'A' && tmp <= 'Z') {
                if (let[(int) tmp - 'A'] == 1) {
                    let[(int) tmp - 'A'] = cnt;
                    --cnt;
                }
            }
        }
        for (int i = 0; i < 26; ++i)
            ans *= let[i];
        out.println(ans);
    }
}

class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream stream) {
        in = new BufferedReader(new InputStreamReader(stream));
        eat("");
    }

    public String next() {
        while (!st.hasMoreTokens())
            eat(nextLine());
        return st.nextToken();
    }

    public String nextLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public void eat(String str) {
        if (str == null) throw new InputMismatchException();
        st = new StringTokenizer(str);
    }
}

import java.util.*;
import java.math.*;

public class A {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    BigInteger ans = BigInteger.ONE;
    String foo = in.next();
    HashSet<Character> seen = new HashSet<Character>();
    boolean first = true;
    for(char c : foo.toCharArray()) {
      if (c == '?') {
        if (first) {
          ans = ans.multiply(BigInteger.valueOf(9));
        } else {
          ans = ans.multiply(BigInteger.valueOf(10));
        }
      } else if (c >= 'A' && c <= 'J') {
        if (first) {
          ans = ans.multiply(BigInteger.valueOf(9));
          seen.add(c);
        } else {
          if (!seen.contains(c)) {
            ans = ans.multiply(BigInteger.valueOf(10-seen.size()));
            seen.add(c);
          }
        }
      }
      first = false;
    }
    System.out.println(ans);
  }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author OmarYasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA2 solver = new TaskA2();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA2 {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            char[] a = sc.next().toCharArray();
            long res = 1;
            int chooseFrom = 10;
            boolean zeroDone = false;
            int n = a.length;
            boolean[] done = new boolean[26];
            int tens = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] == '?') {
                    if (zeroDone) tens++;
                    else res *= 9;
                    zeroDone = true;
                } else if (a[i] >= 'A' && a[i] <= 'J') {
                    if (done[a[i] - 'A']) continue;
                    done[a[i] - 'A'] = true;
                    if (zeroDone) {
                        res *= (chooseFrom--);
                    } else {
                        res *= 9;
                        chooseFrom = 9;
                    }
                    zeroDone = true;
                } else zeroDone = true;
            }
            StringBuilder ress = new StringBuilder(res + "");
            while (tens-- > 0) ress.append("0");
            out.println(ress);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

    }
}

import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
    static Scanner in = new Scanner(System.in);
    static String cad = in.next();
    static int l = cad.length();
    static BigInteger res = new BigInteger("1");
    static int arr[] = new int[10];
    static int cont = 0;
    static int start = 10;
    static int dec = 0;
    public static void main(String[] args) {
        for(int i = 1; i < l; i++){
            if(cad.charAt(i) == '?')
                dec++;
            else{
                if(cad.charAt(i) > '9')
                    arr[cad.charAt(i) - 'A']++;
            }
        }
        if(cad.charAt(0) >= 'A' && cad.charAt(0) <= 'J')
            arr[cad.charAt(0) - 'A']++;
        for(int i = 0; i < 10; i++)
            if(arr[i] > 0) cont++;
        int other = 1;
        if(cad.charAt(0) == '?'){
            other *= 9;
        }
        else{
            if(cad.charAt(0) >= 'A'){
                start--;
                cont--;
                other *= 9;
            }
        }
        while(cont > 0){
            other *= start;
            start--;
            cont--;
        }
        System.out.print(other);
        while(dec-- > 0) System.out.print(0);
    }
}

import java.io.*;
import java.util.*;

public class Main {
//	static Scanner in;
	static PrintWriter out;
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
	static BufferedReader in;

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
//		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		in = new BufferedReader(new InputStreamReader(System.in));

		char[] c = in.readLine().toCharArray();
		int n = c.length;

		int[] kol = new int[27];
		for (char cc : c) {
			if (cc == '?') kol[26]++;
			if ('A' <= cc && cc <= 'J') kol[cc - 'A']++;
		}

		boolean startletter = 'A' <= c[0] && c[0] <= 'J';
		boolean starteq = c[0] == '?';
		if (starteq) kol[26]--;

		int x = 0;
		for (int i = 0; i < 10; i++) if (kol[i] != 0) x++;

		long ans = 1;

		for (int i = 0; i < x; i++) {
			if (startletter && i == 0) ans *= 9;
			else ans *= (10 - i);
		}
		if (starteq) ans *= 9;

		out.print(ans);
		for (int i = 0; i < kol[26]; i++) out.print("0");
		out.println();
		out.close();
	}
}

/*
ID: BryatnMark
LANG: JAVA
TASK: AC
 */
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;
public class Main {
    public static void main(String args[]) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.main(in, out);
        out.close();
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    String next() {
        if (!hasNext())
            throw new RuntimeException();
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e) {
                return false;
            }
        return true;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
    BigDecimal nextBigDecimal()
    {
        return new BigDecimal(next());
    }
}

class Task {
    final int maxn = 111111;
    BigInteger ans;
    char[] s=new char[maxn];
    String ss;
    BigInteger one=BigInteger.ONE;
    BigInteger ten=BigInteger.TEN;
    BigInteger pow(BigInteger a,int b)
    {
        BigInteger t=a,res=BigInteger.ONE;
        while(b>0)
        {
            if((b&1)>0)
                res=res.multiply(t);
            t=t.multiply(t);
            b>>=1;
        }
        return res;
    }
    void main(InputReader in, PrintWriter out) throws Exception {
        ss=in.next();
        s=ss.toCharArray();
        int len=ss.length();
        int k,i,cnt=0;
        int[] c=new int [28];
        if(s[0]=='0')
        {
            out.println(0);
            return;
        }
        if(s[0]>='0'&&s[0]<='9')
            k=1;
        else if(s[0]=='?')
            k=2;
        else
            k=3;
        for(i=0;i<len;++i)
        {
            if(s[i]=='?')
                cnt++;
            else if(s[i]>='A'&&s[i]<='Z')
                c[s[i]-'A']=1;
        }
        int t=0;
        for(i=0;i<26;++i)
            t+=c[i];

        BigInteger ans=BigInteger.ONE;

        //out.println(cnt + " " +t+ " "+ k);
        if(k==1)
        {
            for(i=10;i>10-t;--i)
                ans=ans.multiply(BigInteger.valueOf(i));
            ans=ans.multiply(pow(ten,cnt));
        }
        else if(k==2)
        {
            for(i=10;i>10-t;--i)
                ans=ans.multiply(BigInteger.valueOf(i));
            if(cnt>0)
            {
                ans=ans.multiply(BigInteger.valueOf(9));
                ans=ans.multiply(pow(ten,cnt-1));
            }
        }
        else
        {
            ans=BigInteger.valueOf(9);
            for(i=9;i>10-t;--i)
                ans=ans.multiply(BigInteger.valueOf(i));
            ans=ans.multiply(pow(ten,cnt));
        }
        out.println(ans);

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashSet;

/**
 * @author gark87 <arkady.galyash@gmail.com>
 */
public class B {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String string = reader.readLine();
//    String string = "AJ";
    BigInteger result = BigInteger.ONE;
    char first = string.charAt(0);
    HashSet<Character> all = new HashSet<Character>();
    for (int i = 1; i < string.length(); i++) {
      char c = string.charAt(i);
      switch (c) {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
          break;
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
        case 'G':
        case 'H':
        case 'I':
        case 'J':
          all.add(c);
          break;
        case '?':
          result = result.multiply(BigInteger.valueOf(10));
          break;
      }
    }
    int start = 10;
    if (first >= 'A' && first <= 'Z') {
      all.remove(first);
      start = 9;
    }
    if (first < '0' || first > '9')
      result = result.multiply(BigInteger.valueOf(9));
    int size = all.size();
    for (int i = 0; i < size; i++) {
      result = result.multiply(BigInteger.valueOf(start - i));
    }

    System.out.println(result);
  }
}

import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void solve() {

		long ans = 1;
		int zeros = 0;

		char[] cs = sc.next().toCharArray();
		if (cs[0] == '?') {
			ans *= 9;
		}
		for (int i = 1; i < cs.length; i++) { if (cs[i] == '?') ++zeros; }

		boolean used[] = new boolean[255];
		for (int i = 0; i < cs.length; i++) if ('A' <= cs[i] && cs[i] <= 'J') {
			used[cs[i]] = true;
		}

		int count = 0;
		for (int i = 0; i < used.length; i++) if (used[i]) ++count;

		for (int i = 0; i < count; i++) {
			ans *= (10 - i);
		}
		if ('A' <= cs[0] && cs[0] <= 'J') {
			ans /= 10;
			ans *= 9;
		}
		out.print(ans);
		for (int i = 0; i < zeros; i++) out.print(0);
		out.println();

	}

	public static void main(String[] args) throws Exception {
		Class<?> here = new Object(){}.getClass().getEnclosingClass();
		try {
			String packageName = here.getPackage().getName();
			packageName = "src/" + packageName.replaceAll("\\.", "/") + "/";
			System.setIn(new FileInputStream(packageName + "input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream(packageName + "output.txt")));
		} catch (FileNotFoundException e) {
		} catch (NullPointerException e) {
		}

		Object o = Class.forName(here.getName()).newInstance();
		o.getClass().getMethod("run").invoke(o);
	}

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class A {

	private void solve() throws IOException {
		char[] s = nextToken().toCharArray();
		int any = 0;
		Set<Character> chars = new TreeSet<Character>();

		for (char c: s) {
			if (c == '?') {
				any++;
			} else if (c >= 'A' && c <= 'J') {
				chars.add(c);
			}
		}

		BigInteger res = BigInteger.ONE;
		int x = 10;
		if (s[0] == '?') {
			any--;
			res = BigInteger.valueOf(9);
		} else if (s[0] >= 'A' && s[0] <= 'J') {
			chars.remove(s[0]);
			res = BigInteger.valueOf(9);
			x = 9;
		}

		for (char c: chars) {
			res = res.multiply(BigInteger.valueOf(x));
			x--;
		}
		print(res);
		for (int i = 0; i < any; i++) {
			print("0");
		}
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	private double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new A().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	final static double EPS = 1e-7;
	final static int MOD = 1000000007;

	static void solve() throws Exception {
		String s = next();
		int n = 0;
		Set<Character> used = new HashSet<Character>();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				n++;
			} else if (Character.isLetter(s.charAt(i))) {
				used.add(s.charAt(i));
			}
		}
		long res = 1;
		for (int i = 0; i < used.size(); i++) {
			if (i == 0 && Character.isLetter(s.charAt(0))) {
				res *= 9;
			} else {
				res *= 10-i;
			}
		}
		if (s.charAt(0) == '?') {
			res *= 9;
		}
		out.print(res);
		for (int i = 0; i < n; i++) {
			out.print("0");
		}
		out.println();
	}

	static int sqr(int x) {
		return x*x;
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static BigInteger nextBigInteger() throws IOException {
		return new BigInteger(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static String nextLine() throws IOException {
		tok = new StringTokenizer("");
		return in.readLine();
	}

	static boolean hasNext() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null) {
				return false;
			}
			tok = new StringTokenizer(s);
		}
		return true;
	}

	public static void main(String args[]) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			//in = new BufferedReader(new FileReader("input.in"));
			//out = new PrintWriter(new FileWriter("output.out"));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			java.lang.System.exit(1);
		}
	}
}

import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class A316 {
	static final double EPS = 1e-10;
	static final double INF = 1 << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		input = br.readLine();
		int ans =1;
		int[] count = new int [10];

		int zeros=0;
		for (int i=0; i<input.length(); i++){
			char c =input.charAt(i);
			if (c=='?') zeros++;
			else if ('A'<=c && c<='J') count[c-'A']=1;
		}
		int s=0;
		for (int i=0; i<10; i++)
			if (count[i]==1) s++;
		if ('A'<=input.charAt(0) && 'J'>=input.charAt(0)) {
			ans =9;
			for (int i=1; i<s; i++) ans*=10-i;
			if (input.length()==1) ans++;
		}else {
			for (int i=1; i<=s; i++) ans*=11-i;
		}
		if (input.charAt(0)=='?' && input.length()>1){
			ans*=9;
			zeros--;
		}
		sb.append(ans);
		for (int i=0; i<zeros; i++) sb.append(0);
		if ('?'==input.charAt(0) && input.length()==1) ln(9);
		else ln(sb);/*
		if (!input.equals("AJ") && !input.equals("1?AA")){
			if ('0'<=input.charAt(0) && '9'>=input.charAt(0) ln(count[ans+10]);
			else if (input.charAt(0)=='?'){
				while(ans>0){
					ans++;
				}
			}else if ('A'<=input.charAt(0) && 'J'>=input.charAt(0)){
//				HashSet<String> s = new HashSet<String>();
				for (int i=0; i<1000; i++){
					input=input.concat(input);
				}
			}
		}*/
	}

	public static void main(String[] args) throws IOException {
		new A316().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;

public class ABBYYCupTemp {

    public static void main(String args[]) throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        ArrayList<Long> tempArray = new ArrayList<>();

        String stringMain = bf.readLine();

        int numberWhat = 0;
        int numberCombinationLetter = 1;

        ArrayList<String> arrayLetter = new ArrayList<>();

        for(int i=0; i<stringMain.length(); i++){

            if(!Character.isDigit(stringMain.charAt(i))){

                if(arrayLetter.size()==10){
                    for(; i<stringMain.length(); i++)
                        if(Character.toString(stringMain.charAt(i)).equals("?")){

                            numberWhat++;
                            if(numberWhat==10){
                                tempArray.add((long)10);
                                numberWhat=0;
                            }

                        }
                    break;
                }
                else {
                    if(Character.toString(stringMain.charAt(i)).equals("?")){

                        numberWhat++;
                        if(numberWhat==10){
                            tempArray.add((long)10);
                            numberWhat=0;
                        }

                    }
                    else
                        if(!arrayLetter.contains(Character.toString(stringMain.charAt(i))))
                            arrayLetter.add(Character.toString(stringMain.charAt(i)));
                }

            }

        }

        if(numberWhat!=0){
            tempArray.add((long)numberWhat);
            numberWhat=0;
        }

        if(Character.toString(stringMain.charAt(0)).equals("?")){

            tempArray.set(0, (long)Math.pow(10, tempArray.get(0)-1)*9);

            for(int y=1; y<tempArray.size(); y++)
                tempArray.set(y, (long)Math.pow(10, tempArray.get(y)));

        }
        else
            for(int y=0; y<tempArray.size(); y++)
                tempArray.set(y, (long)Math.pow(10, tempArray.get(y)));

        if(!Character.isDigit(stringMain.charAt(0))){

            if(!Character.toString(stringMain.charAt(0)).equals("?")){

                for(int j=0, tempBase=9; j<(arrayLetter.size()-1); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

                numberCombinationLetter=numberCombinationLetter*9;

                //BigInteger bIntNumberCombinationLetter = BigInteger.valueOf(numberCombinationLetter);
                BigInteger bIntDegree;
                if(tempArray.size()>0)
                    bIntDegree=BigInteger.valueOf(tempArray.get(0));
                else
                    bIntDegree=BigInteger.valueOf(1);

                for(int y=1; y<tempArray.size(); y++)
                    bIntDegree = bIntDegree.multiply(BigInteger.valueOf(tempArray.get(y)));

                System.out.print(BigInteger.valueOf(numberCombinationLetter).multiply(bIntDegree));

            }
            else {
                for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

                //BigInteger bIntNumberCombinationLetter = BigInteger.valueOf(numberCombinationLetter);

                BigInteger bIntDegree;
                if(tempArray.size()>0)
                    bIntDegree=BigInteger.valueOf(tempArray.get(0));
                else
                    bIntDegree=BigInteger.valueOf(1);

                for(int y=1; y<tempArray.size()-1; y++)
                    bIntDegree = bIntDegree.multiply(BigInteger.valueOf(tempArray.get(y)));

                System.out.print(BigInteger.valueOf(numberCombinationLetter).multiply(bIntDegree));

            }

        }
        else{

            for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                numberCombinationLetter = numberCombinationLetter*tempBase;

            //BigInteger bIntNumberCombinationLetter = BigInteger.valueOf(numberCombinationLetter);

            BigInteger bIntDegree;
            if(tempArray.size()>0)
                bIntDegree=BigInteger.valueOf(tempArray.get(0));
            else
                bIntDegree=BigInteger.valueOf(1);

            for(int y=1; y<tempArray.size(); y++)
                bIntDegree = bIntDegree.multiply(BigInteger.valueOf(tempArray.get(y)));

            System.out.print(BigInteger.valueOf(numberCombinationLetter).multiply(bIntDegree));

        }

    }

}

import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class A316 {
	static final double EPS = 1e-10;
	static final double INF = 1 << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		input = br.readLine();
		int ans =1;
		int[] count = new int [26];
		//if (input.charAt(0)=='0')
		int zeros=0;
		for (int i=0; i<input.length(); i++){
			char c =input.charAt(i);
			if (c=='?') zeros++;
			else if ('A'<=c && c<='Z') count[c-'A']=1;
		}
		int s=0;
		for (int i=0; i<26; i++)
			if (count[i]==1) s++;
		if ('A'<=input.charAt(0) && 'Z'>=input.charAt(0)) {
			ans =9;
			for (int i=1; i<s; i++) ans*=10-i;
			if (input.length()==1) ans++;
		}else {
			for (int i=1; i<=s; i++) ans*=11-i;
		}
		if (input.charAt(0)=='?' && input.length()>1){
			ans*=9;
			zeros--;
		}
		sb.append(ans);
		for (int i=0; i<zeros; i++) sb.append('0');
		ln(sb);
	}

	public static void main(String[] args) throws IOException {
		new A316().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
}

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Task316A2 {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Solution {

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner sc = new Scanner(is);

			String inp = sc.next();

			StringBuilder sb = new StringBuilder();

			for (int i = 0; i < inp.length(); i++) {
				if (inp.charAt(i) == '?') {
					sb.append("1");
				}
				if (inp.charAt(i) <= '9' && inp.charAt(i) >= '0') {
					sb.append(String.valueOf(inp.charAt(i)));
				}
				if (inp.charAt(i) >= 'A' && inp.charAt(i) <= 'J') {
					sb.append(String.valueOf((char) ('0' + inp.charAt(i) - 'A')));
				}
			}

			pw.println(sb.toString());
			pw.flush();
			sc.close();
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * User: bpk
 * Date: 13.06.13
 * Time: 21:27
 */
public class SpecialTaskA2 {

    public static int numberOfCodes(String string) {

        List<Character> characters = new LinkedList<Character>();
        int numberOfQuestionMarks = 0;

        if (string.isEmpty()) {
            return 0;
        }

        for (int i = 0; i < string.length(); i++) {
            char c = string.charAt(i);
            if (!characters.contains(c)) {
                if (addToMap(c)) {
                    if (c == '?') {
                        numberOfQuestionMarks++;
                    } else {
                        characters.add(c);
                    }
                }
            }
        }

        int result = 1;
        if (numberOfQuestionMarks > 0) {
            result = result * numberOfQuestionMarks * 10;
        }

        int numberOfLetters = characters.size();
        result = (int) (result * Math.pow((10 - numberOfLetters + 1), numberOfLetters));

        if (string.length() == 1 && addToMap(string.charAt(0))) {
            result--;
        }

        return result;
    }

    private static boolean addToMap(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == '?';
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String inputString = in.readLine();
        in.close();
        System.out.println(SpecialTaskA2.numberOfCodes(inputString));
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashSet;

/**
 * @author gark87 <arkady.galyash@gmail.com>
 */
public class A {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String string = reader.readLine();
//    String string = "AJ";
    BigInteger result = BigInteger.ONE;
    char first = string.charAt(0);
    HashSet<Character> all = new HashSet<Character>();
    for (int i = 1; i < string.length(); i++) {
      char c = string.charAt(i);
      switch (c) {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
          break;
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
        case 'H':
        case 'I':
        case 'J':
          all.add(c);
          break;
        case '?':
          result = result.multiply(BigInteger.valueOf(10));
          break;
      }
    }
    int start = 10;
    if (first >= 'A' && first <= 'Z') {
      all.remove(first);
      start = 9;
    }
    if (first < '0' || first > '9')
      result = result.multiply(BigInteger.valueOf(9));
    int size = all.size();
    for (int i = 0; i < size; i++) {
      result = result.multiply(BigInteger.valueOf(start - i));
    }

    System.out.println(result);
  }
}

import java.util.Scanner;

public class SpecialTask {
	public static void main(String[] args) {
		Scanner k = new Scanner(System.in);
		int counter=1;
		char[] s=k.next().toCharArray();
		int f=0,ten=10;
		if(!(s[0]<58&&s[0]>47)) {
			if(s[0]>64&&s[0]<75) ten=9;
			counter=9;
		}

		for (int i = 1; i < s.length; i++) {
			if(s[i]>64&&s[i]<75){

				for (int j = 0; j <= i; j++) {
					if(s[i]==s[j]) {
						f++;
						if(f>2) break;
					}
				}

				if(f==1) {
					counter*=ten;
					ten--;

				}
				f=0;

			}else if(s[i]=='?'){

					counter*=10;

			}
//			}else if(s[i]>47&&s[i]<58){
//				if(i==0) {
//					counter*=9;
//				}
//				else {
//					for(int j = 0; j <= i; j++) {
//						if(s[i]==s[j]) f2++;
//					}
//
//					if(f2==1) {
//						counter*=10;
//
//					}
//					f2=0;
//				}
//			}
		}
		System.out.println(counter);
	}
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Codeforces {
	FastScanner in;
	PrintWriter out;

	long fact(long count) {
		if (count == 0) return 1;
		else return fact(count - 1) * count;
	}

	public void solve() throws IOException {
		char[] c = in.next().toCharArray();
		BigInteger ans = BigInteger.ONE;
		if (c.length == 1) {
			if (c[0] >= '0' && c[0] <= '9') out.println(1);
			else out.println(10);
			return;
		}
		boolean[] was = new boolean[1000];
		boolean first = false;
		int count = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] == '?') {
				if (i != 0) ans = ans.multiply(BigInteger.valueOf(10));
				else {
					ans = ans.multiply(BigInteger.valueOf(9));
				}
			}
			if (c[i] >= 'A' && c[i] <= 'Z') {
				if (i == 0) first = true;
				if (!was[c[i]]) {
					count++;
				}
				was[c[i]] = true;
			}
		}

		int dif = 10;
		if (first) {
			dif--;
			count--;
			ans = ans.multiply(BigInteger.valueOf(9));
		}
		long[][] C = new long[100][100];
		for (int i = 0; i < 100; i++) {
			C[i][0] = 1;
		}
		for (int i = 1; i < 100; i++) {
			for (int j = 1; j < 100; j++) {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
		ans = ans.multiply(BigInteger.valueOf(C[dif][count] * fact(count)));

		out.println(ans);
	}

	public void run() {
		try {
			in = new FastScanner();
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		boolean hasNext() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String s = br.readLine();
					if (s == null) {
						return false;
					}
					st = new StringTokenizer(s);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return true;
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new Codeforces().run();
	}
}

import java.util.Scanner;

public class SpecialTask {
	public static void main(String[] args) {
		Scanner k = new Scanner(System.in);
		int counter=1;
		char[] s=k.next().toCharArray();
		int f=0,ten=10;
		if(!(s[0]<58&&s[0]>47)) {
			if(s[0]>64&&s[0]<75) ten=9;
			counter=9;
		}

		for (int i = 1; i < s.length; i++) {
			if(s[i]>64&&s[i]<75){

				for (int j = 0; j <= i; j++) {
					if(s[i]==s[j]) {
						f++;
						if(f>1) break;
					}
				}

				if(f==1) {
					counter*=ten;
					ten--;

				}
				f=0;

			}else if(s[i]=='?'){

					counter*=10;

			}
//			}else if(s[i]>47&&s[i]<58){
//				if(i==0) {
//					counter*=9;
//				}
//				else {
//					for(int j = 0; j <= i; j++) {
//						if(s[i]==s[j]) f2++;
//					}
//
//					if(f2==1) {
//						counter*=10;
//
//					}
//					f2=0;
//				}
//			}
		}
		System.out.println(counter);
	}
}

import java.io.*;
import java.util.*;

public class Main {

    // system
    public static String charset = "UTF-8";
    public static Locale locale = new Locale("en", "US");
    public static PrintWriter stdOut, fileOut;
    public static Scanner stdIn, fileIn;

    // A
    public static void main(String[] args) {
        setIO(null, null);
        Scanner input = stdIn;
        PrintWriter output = stdOut;

        String s = input.next();
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        for (char c = 'A'; c <= 'J'; c++) {
            map.put(c, 0);
        }
        int q = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '?') q++;
            else if (c >= 'A' && c <= 'J') {
                map.put(c, map.get(c) + 1);
            }
        }
        char first = s.charAt(0);
        int total = 1;
        if (first == '?') {
            total *= 9;
            q--;
        }
        if (q != 0) {
            total *= Math.pow(10, q);
        }
        int count = 10;
        if (first >= 'A' && first <= 'J') {
            total *= 9;
            count = 9;
            map.put(first, 0);
        }
        for (char c = 'A'; c <= 'J'; c++) {
            if (map.get(c) > 0) {
                total *= count;
                count--;
            }
        }

        output.println(total);

        input.close();
        output.close();
    }

    // system
    public static void setIO(String fileInName, String fileOutName) {
        // Standard input
        stdIn = new Scanner(new BufferedInputStream(System.in), charset);
        stdIn.useLocale(locale);

        // Standard output
        try {
            stdOut = new PrintWriter(new OutputStreamWriter(System.out, charset), true);
        }
        catch (UnsupportedEncodingException e) {
            System.err.println(e);
        }

        // File input
        if (fileInName != null) {
            try {
                File file = new File(fileInName);
                if (file.exists()) {
                    fileIn = new Scanner(file, charset);
                    fileIn.useLocale(locale);
                }
            }
            catch (IOException ioe) {
                System.err.println("Could not open " + fileInName);
            }
        }

        // File output
        if (fileOutName != null) {
            try {
                OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(fileOutName), charset);
                fileOut = new PrintWriter(osw, true);
            }
            catch (IOException e) {
                System.err.println(e);
            }
        }
    }
}

import java.util.Scanner;

public class SpecialTask
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		boolean[] flag = new boolean[10];
		for (int i = 0; i < 10; ++i)
		{
			flag[i] = false;
		}
		for (int i = 0; i < s.length(); ++i)
		{
			if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J')
			{
				flag[s.charAt(i) - 'A'] = true;
			}
		}
		int num = 0;
		for (int i = 0; i < 10; ++i)
		{
			if (flag[i])
			{
				++num;
			}
		}
		int res = 1;
		if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J')
		{
			res = 9;
		}
		int temp = 9;
		for (int i = 0; i < num - 1; ++i)
		{
			res *= temp;
			--temp;
		}
		if (s.charAt(0) == '?')
		{
			res *= 9;
		}
		for (int i = 1; i < s.length(); ++i)
		{
			if (s.charAt(i) == '?')
			{
				res *= 10;
			}
		}
		System.out.println(res);
	}
}

import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * <a href="http://codeforces.ru/problemset/problem/316/A1"/>
 *
 * @author pvasilyev
 * @since 16 Jan 2014
 */
public class Problem097 {

    public static void main(String[] args) {
        final Scanner reader = new Scanner(System.in);
        final PrintWriter writer = new PrintWriter(System.out);

        solve(reader, writer);

        reader.close();
        writer.close();
    }

    private static void solve(final Scanner reader, final PrintWriter writer) {
        final char[] string = reader.next().toCharArray();
        int[] occurrences = new int[10];
        final HashSet<Character> characters = new HashSet<>();
        int marks = 0;
        for (int i = 0; i < string.length; i++) {
            char c = string[i];
            if (c - '0' < 10) {

            } else if (c == '?') {
                marks++;
            } else {
                occurrences[c - 'A']++;
                characters.add(c);
            }
        }
        long result = 1;
        if (string[0] == '?') {
            result = 9;
            marks--;
            for (int i = 0; i < characters.size(); ++i) {
                result *= (10 - characters.size() + 1);
            }
        } else {
            if (string[0] - '0' > 9 && !characters.isEmpty()) {
                result = 10 - characters.size();
            } else if (!characters.isEmpty()) {
                result = 10 - characters.size() + 1;
            }
            for (int i = 0; i < characters.size() - 1; ++i) {
                result *= (10 - characters.size() + 1);
            }
        }

        final StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(result);
        for (int i = 0; i < marks; ++i) {
            stringBuilder.append('0');
        }
        writer.println(stringBuilder);
    }

}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA1 solver = new TaskA1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA1 {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String str = in.next();
        int size = str.length();
        int ans = 1;
        int cnt = 10;
        int cnt2 = 0;
        int[] let = new int[26];
        Arrays.fill(let, 1);
        char tmp = str.charAt(0);
        if (tmp == '?')  {
            ans *= 9;
        } else if (tmp >= 'A' && tmp <= 'Z') {
            --cnt;
            let[(int) tmp - 'A'] = cnt;
        }
        for (int i = 1; i < size; ++i) {
            tmp = str.charAt(i);
            if (tmp == '?')  {
                ++cnt2;
            } else if (tmp >= 'A' && tmp <= 'Z') {
                if (let[(int) tmp - 'A'] == 1) {
                    let[(int) tmp - 'A'] = cnt;
                    --cnt;
                }
            }
        }
        for (int i = 0; i < 26; ++i)
            ans *= let[i];
        out.print(ans);
        for (int i = 0; i < cnt2; ++i)
            out.print("0");
        out.println();
    }
}

class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream stream) {
        in = new BufferedReader(new InputStreamReader(stream));
        eat("");
    }

    public String next() {
        while (!st.hasMoreTokens())
            eat(nextLine());
        return st.nextToken();
    }

    public String nextLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public void eat(String str) {
        if (str == null) throw new InputMismatchException();
        st = new StringTokenizer(str);
    }
}

import java.io.BufferedReader;
import java.io.IOException;

import java.io.InputStreamReader;

public class Main{
    public static int perm(int x){
        int r=1;

        for(int i=0;i<x;i++){
            r*=10-i;
        }
        return r;
    }
     public static int perm1(int x){
        int r=9;

        for(int i=1;i<x;i++){
            r*=10-i;
        }
        return r;
    }

    public static void main(String[] args)throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int result=0;
        int count=0;
       int counta=0;
        int countb=0;
        int countc=0;
        int countd=0;
        int counte=0;
        int countf=0;
        int countg=0;
        int counth=0;
        int counti=0;
        int countj=0;
       int countQ=0;
        boolean flag=true;;
        for(int i=0;i<s.length();i++){
            if(i==0){
                switch(s.charAt(0)){
                    case '1':;
                    case '2':;
                    case '3':;
                    case '4':;
                    case '5':;
                    case '6':;
                    case '7':;
                    case '8':;
                    case '9':flag=false;
                }
            }
           if(s.charAt(i)=='?')
           countQ++;
           else{
               switch(s.charAt(i)){
                   case 'A':counta=1;break;
                   case 'B':countb=1;break;
                   case 'C':countc=1;break;
                   case 'D':countd=1;break;
                   case 'E':counte=1;break;
                   case 'F':countf=1;break;
                   case 'G':countg=1;break;
                   case 'H':counth=1;break;
                   case 'I':counti=1;break;
                   case 'J':countj=1;break;
                   default: count++;
               }
           }
        }
        if(countQ!=0){
        if(flag==false){
            result=countQ*10*perm(counta+countb+countc+countd+counte+countf+countg+counth+countj+counti);
        }
        else{
            result=countQ*10*perm1(counta+countb+countc+countd+counte+countf+countg+counth+countj+counti);
        }
        }
        else{
            if(flag==false){
            result=perm(counta+countb+countc+countd+counte+countf+countg+counth+countj+counti);
        }
        else{
            result=perm1(counta+countb+countc+countd+counte+countf+countg+counth+countj+counti);
        }
        }
        System.out.print(result);
    }}

import java.util.Scanner;

public class S {
public static void main(String[] args) {
    Scanner in =new Scanner (System.in);
    //System.out.println((int)'Z');
    String a=in.next();
    int sum=1;
    int m=10;
    char[] ar=new char[100];

    for(int i=0;i<a.length();i++){

        if((int)a.charAt(i)>=48&&(int)a.charAt(i)<=57)
            sum*=1;
        if(a.charAt(i)=='?')
            sum*=10;
        if((int)a.charAt(i)>=65&&(int)a.charAt(i)<=90&&ar[(int)a.charAt(i)]==0){
            if(i==0){
                sum*=9;
                m--;
                ar[(int)a.charAt(i)]=1;
            }
            else{
                sum*=m;
                ar[(int)a.charAt(i)]=1;
                m--;
            }
        }
    }

    System.out.println(sum);
}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created with IntelliJ IDEA.
 * User: shiwangi
 * Date: 6/12/13
 * Time: 7:48 PM
 * To change this template use File | Settings | File Templates.
 */
public class Abby1 {
    public static void main(String[] args) throws IOException {

        InputStreamReader input = new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(input);
        String s=br.readLine();  int ans=1; int p=10;
        int l=s.length();  int count[]=new int[10];
        if(s.charAt(0)=='?')
         ans*=9;
        else if(64<s.charAt(0) && s.charAt(0)<75) {
            ans*=9; p=9;}
        for(int i=0;i<l;i++)
        {
            if(64<s.charAt(i) && s.charAt(i)<75)
            {
                count[s.charAt((i))-65] ++;
            }
            else if(s.charAt(i)=='?')
                ans*=10;

        }
        if(p==9)
        count[s.charAt((0))-65] =0;
        for(int i=0;i<10;i++)
        {
              if(count[i]!=0)
              {    ans*=p;
                  p--;
              }
        }
    System.out.println(ans);
    }

}

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        String [] sp;
        String s = br.readLine();
        int a = 0;
        boolean f = false;
        int c = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '?'){
                c++;
            }else if(s.charAt(i) - 'A' >=0 && s.charAt(i) - 'A' < 26){
                a++;
                if(i == 0)
                    f = true;
            }
        }
        BigInteger ans = new BigInteger(10 + "");
        ans = ans.pow(c);
        int r = 1;
        if(f){
            for (int i = 0; i < a -1 ; i++) {
                r *= (9 - i);
            }
            r *= 9;

        }else{
            for (int i = 0; i < a; i++) {
                r *= (10 - i);
            }

        }
        ans = ans.multiply(new BigInteger(r + ""));
        System.out.println(ans);
    }

}

import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.*;
public class SpecialTask
{
    static final int INF = Integer.MAX_VALUE;
    static final int NINF = Integer.MIN_VALUE;

    public static void main(String[]args)throws IOException
    {
        Input in = new Input();
        int [] counts = new int['j'-'a'+2];
        Arrays.fill(counts, -1);
        char [] str = in.next().toCharArray();
        int choices = 10;
        for(int i = 0; i < str.length; i++)
        {
            if(str[i] >= '0' && str[i] <= '9')
                continue;

            if(str[i] == '?')
            {
                if(i == 0)
                    counts[counts.length-1] = 9;
                else
                    counts[counts.length-1] = 10;
            }else if(counts[str[i]-'A'] == -1)
            {
                if(i == 0)
                    counts[str[i]-'A'] = 9;
                else
                    counts[str[i]-'A'] = choices;
                choices = Math.max(0, --choices);
            }
        }
        //System.out.println(Arrays.toString(counts));
        long res = 1;
        for(int i = 0; i < counts.length; i++)
        {
            if(counts[i] >= 0)
                res *= counts[i];
        }
        System.out.println(res);
    }

    public static void exit()
    {
        System.exit(0);
    }
}

class Input
{
    BufferedReader br;
    StringTokenizer st;

    public Input()
    {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String nextLine()throws IOException
    {
       return br.readLine();
    }

    public int nextInt()throws IOException
    {
        return Integer.parseInt(next());
    }

    public long nextLong()throws IOException
    {
        return Long.parseLong(next());
    }

    public float nextFloat()throws IOException
    {
        return Float.parseFloat(next());
    }

    public double nextDouble()throws IOException
    {
        return Double.parseDouble(next());
    }

    public String next()throws IOException
    {
        if(st == null || !st.hasMoreTokens())
          st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Z {
    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        String s;
        int sum = 0;
        s = "";
        try {
            s = bi.readLine();
        }
        catch (Exception t) {

        }
        int cntQ = 0;
        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) == '?')
                cntQ++;
        boolean[] use = new boolean[26];
        boolean flagFirst = false;
        if (s.charAt(0) == '?' || ('A' <= s.charAt(0) && s.charAt(0) <= 'Z'))
            flagFirst = true;

        for (int i = 0; i < 26; i++)
            use[i] = false;

        for (int i = 0; i < s.length(); i++)
            if ('A' <= s.charAt(i) && s.charAt(i) <= 'Z') {
                int pos = s.charAt(i) - 'A';
                use[pos] = true;
            }
        int cntL = 0;
        for (int i = 0; i < 26; i++)
            if (use[i])
                cntL++;

        BigInteger ans = new BigInteger("1");
        out.println(cntQ);
        for (int i = 0; i < cntQ; i++) {
            if (flagFirst) {
                //out.println("sjdflasdfasdf\n");
                //out.println(ans.toString());
                ans = ans.multiply(new BigInteger("9"));
                //out.println(ans.toString());
                flagFirst = false;
            }
            else {
                ans = ans.multiply(new BigInteger("10"));
            }
        }

        for (int i = 0; i < cntL; i++) {
            Integer tmp;
            if (i == 0 && flagFirst) {
                tmp = new Integer(9);
                flagFirst = false;
            }
            else {
                tmp = new Integer(10 - i);
            }
            ans = ans.multiply(new BigInteger(tmp.toString()));
        }
        out.println(ans.toString());

    }

    public void run() {
        try {
            //in = new FastScanner(new File(".in"));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg) {
        new Z().run();
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author Lotus
 */
public class A3161 {
    public static void main(String[]args)
    {
        Scanner input = new Scanner(System.in);
        String str = input.next();
        int counter=1;
        int count1=0;
        int count2=0;
        int[]let= new int[10];

        for(int i=0; i<str.length();i++)
        {
            if(str.charAt(i)=='?')
            {
                count1++;
            }
           else  if(str.codePointAt(i)>=65)
           {
            let[str.codePointAt(i)-65] ++;
           }

        }

        for(int j=0 ;j<let.length;j++)
        {
            if(let[j]!=0)
            {
                count2 ++;
            }
        }
        counter=(int) Math.pow(10, count1);
        int counter2=1;
        int k;
        if(str.codePointAt(0)>=65)
        {
            k=9;
            counter2=k;
        }
        else
        {
            k=10;

        }

        for( int j=k ; j>10-count2; j--)
        {

            counter2*=j;
        }

      System.out.println(counter*counter2);

    }

}

import java.util.*;
import java.lang.*;
import java.math.*;
import java.util.regex.*;
import java.io.*;

public class Special_Task {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int ans = 1;
		String arr[] = in.nextLine().split("");
		ArrayList<String> done = new ArrayList<String>();
		for(int i = 0; i <arr.length; i++) {
			if(i == 0 && arr[i].matches("[A-J]")) {
				ans *= 9;
				done.add(arr[i]);
			}else if(done.contains(arr[i]) == false && arr[i].matches("[A-J]")) {
				ans *= 10 - done.size();
				done.add(arr[i]);
			}else if(arr[i].equals("?")) {
				ans *= 10;
			}
		}
		System.out.println(ans);
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class A {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	void solve() throws Exception {
		String s = next();
		int cnt[] = new int[10];
		int zc = 0;
		// BigInteger ans = BigInteger.ONE;

		for (int i = 0; i < s.length(); i++) {
			if (Character.isAlphabetic(s.charAt(i)))
				cnt[s.charAt(i) - 'A']++;
			if (s.charAt(i) == '?')
				zc++;
		}

		int dc = 0;
		for (int i = 0; i < 10; i++) {
			if (cnt[i] > 0)
				dc++;
		}

		int ans = 10;
		if (Character.isAlphabetic(s.charAt(0)))
			ans--;
		for (int i = 1; i < dc; i++)
			ans *= 10 - i;
		out.print(ans);
		for (int i = 0; i < zc; i++)
			out.print(0);
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new A().run();
	}

}

import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Problem4 {

	private static Set<Character> lettersused = new HashSet<Character>();
	private static long questionMarksUsed=0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner in = new Scanner(System.in);

		while (in.hasNextLine()) {
			   String line = in.nextLine();
			   getCombinations(line);
		}

	}

	private static void getCombinations(String safe) {

        if(safe==null || safe.isEmpty()) {
            System.out.println(0);
        }
        for(int i=0; i<safe.length(); i++) {
            treatCharacter(safe.charAt(i));
        }

        long aux=1;
        if(Character.isDigit(safe.charAt(0))) {
        	for(int i=0 ; i<lettersused.size();i++) {
            	aux*=10-i;
            }
        }
        else {
	       	if (safe.charAt(0)=='?') {
	        	aux=9;
	        	questionMarksUsed--;
	        	for(int i=0 ; i<lettersused.size();i++) {
	            	aux*=9-i;
	            }
	        }
	        else {
	        	aux=9;
	        	for(int i=0 ; i<lettersused.size()-1;i++) {
	            	aux*=9-i;
	            }
	        }
        }

        BigInteger res = new BigInteger(Long.toString(aux));
        if(questionMarksUsed>0) {
        	res = res.multiply(new BigInteger(Long.toString(questionMarksUsed*10)));
        }

        System.out.println(res);

        lettersused.clear();
    }

    private static void treatCharacter(char c) {
        // TODO Auto-generated method stub
        if(c=='?') {
            questionMarksUsed++;
        }

        else if(!Character.isDigit(c)) {
        	checkLetter(c);
        }

    }

    private static void checkLetter(Character c) {

    	if(lettersused.size()<10 && !lettersused.contains(c)) {
    		lettersused.add(c);
    	}
    }

}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	static final long MOD = 1000000007;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int qq = 1;
		//int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			String str = nextToken();
			BigInteger ret = BigInteger.ONE;
			TreeSet<Character> set = new TreeSet<Character>();
			for(int i = 0; i < str.length(); i++)	{
				int cand = i == 0 ? 9 : 10;
				if(str.charAt(i) == '?')	{
					ret = ret.multiply(BigInteger.valueOf(cand));
				}
				else if(Character.isLetter(str.charAt(i)) && set.add(str.charAt(i)))	{
					ret = ret.multiply(BigInteger.valueOf(cand));
				}
			}
			pw.println(ret);
		}
		pw.close();
	}

	static class Vertex	implements Comparable<Vertex> {
		public int x,y,w;

		public Vertex(int x, int y, int w) {
			super();
			this.x = x;
			this.y = y;
			this.w = w;
		}

		public int compareTo(Vertex curr)	{
			return w - curr.w;
		}
	}

	static class State	{
		public int x,y;

		public State(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

	}

	private static void exitImmediately()	{
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}

	private static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out, true);

		String s = in.readLine();
		BigInteger res = BigInteger.ONE;
		boolean used[] = new boolean[10];
		int ans = 1;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (!Character.isDigit(c) && c != '?') {
				int code = (int)c;
				int index = c - 65;
				used[index] = true;
			}
		}

		int nUsed = 0;
		for (int i = 0; i < 10; i++) {
			if (used[i]) {
				ans *= 10 - nUsed;
				nUsed++;
			}
		}
		if (s.charAt(0) == '?')
			ans *= 9;
		System.out.print(ans);
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == '?')
				System.out.print(0);
		}

		System.out.println();
	}
}

import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Problem4 {

	private static Set<Character> lettersused = new HashSet<Character>();
	private static long questionMarksUsed=0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner in = new Scanner(System.in);

		while (in.hasNextLine()) {
			   String line = in.nextLine();
			   getCombinations(line);
		}

	}

	private static void getCombinations(String safe) {

        if(safe==null || safe.isEmpty()) {
            System.out.println(0);
        }
        for(int i=0; i<safe.length(); i++) {
            treatCharacter(safe.charAt(i));
        }

        long aux=1;
        if(Character.isDigit(safe.charAt(0))) {
        	for(int i=0 ; i<lettersused.size();i++) {
            	aux*=10-i;
            }
        }
        else {
	       	if (safe.charAt(0)=='?') {
	        	aux=9;
	        	questionMarksUsed--;
	        	for(int i=0 ; i<lettersused.size();i++) {
	            	aux*=10-i;
	            }
	        }
	        else {
	        	aux=9;
	        	for(int i=0 ; i<lettersused.size()-1;i++) {
	            	aux*=9-i;
	            }
	        }
        }
        BigInteger res = new BigInteger(Long.toString(aux));
        aux=1;
        for(int i=0;i<questionMarksUsed; i++) {
        		aux*=10;
        }
        res = res.multiply(new BigInteger(Long.toString(aux)));

        System.out.println(res);

        lettersused.clear();
    }

    private static void treatCharacter(char c) {
        // TODO Auto-generated method stub
        if(c=='?') {
            questionMarksUsed++;
        }

        else if(!Character.isDigit(c)) {
        	checkLetter(c);
        }

    }

    private static void checkLetter(Character c) {

    	if(lettersused.size()<10 && !lettersused.contains(c)) {
    		lettersused.add(c);
    	}
    }

}

import java.util.Scanner;

public class SpecialTask {
    public static void main(String[] args) {
        Scanner k = new Scanner(System.in);
        int counter=1;
        char[] s=k.next().toCharArray();
        int f=0,ten=10,ten2=10,f2=0;
        for (int i = 0; i < s.length; i++) {
            if(s[i]>64&&s[i]<75){
                if(i==0) {
                    counter*=9;
                    ten--;
                    continue;
                }
                for (int j = 0; j <= i; j++) {
                    if(s[i]==s[j]) f++;
                }

                if(f==1) {
                    counter*=ten;
                    ten--;
                    f=0;
                }

            }else if(s[i]=='?'){
                if(i==0) {
                    counter*=9;
                }
                else {
                    counter*=10;
                }
            }else if(s[i]>47&&s[i]<58){
                if(i==0) {
                    counter*=9;
                    ten2--;
                }
                else {
                    for(int j = 0; j <= i; j++) {
                        if(s[i]==s[j]) f2++;
                    }

                    if(f2==1) {
                        counter*=ten2;
                        ten2--;
                        f2=0;
                    }
                }
            }
        }
        System.out.println(counter);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class ABBYYCupTemp {

    public static void main(String args[]) throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        String stringMain = bf.readLine();

        int numberWhat = 0;
        int numberCombination = 1;
        int numberCombinationLetter = 1;

        ArrayList<String> arrayLetter = new ArrayList<>();

        for(int i=0; i<stringMain.length(); i++){

            if(!Character.isDigit(stringMain.charAt(i))){

                if(Character.toString(stringMain.charAt(i)).equals("?"))
                    numberWhat++;
                else
                    if(!arrayLetter.contains(Character.toString(stringMain.charAt(i))))
                        arrayLetter.add(Character.toString(stringMain.charAt(i)));

            }

        }

        if(!Character.isDigit(stringMain.charAt(0))){

            if(!Character.toString(stringMain.charAt(0)).equals("?")){

                for(int j=0, tempBase=9; j<(arrayLetter.size()-1); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

                numberCombinationLetter=numberCombinationLetter*9;

                System.out.print(numberCombinationLetter*(int)(Math.pow(10, numberWhat)));

            }
            else {
                for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

                System.out.print(numberCombinationLetter*9*(int)(Math.pow(10, (numberWhat-1))));

            }

        }
        else{

            for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                numberCombinationLetter = numberCombinationLetter*tempBase;

            System.out.print(numberCombinationLetter*(int)(Math.pow(10, numberWhat)));

        }

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class SpecialTask {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);

        String s = in.next();

        int numUnknowns = 0;
        Set<Character> letters = new HashSet<Character>();
        boolean firstUnknown = false;
        boolean firstLetter = false;

        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == '?') {
                ++numUnknowns;
                if (i == 0)
                    firstUnknown = true;
            }
            if (Character.isAlphabetic(s.charAt(i))) {
                letters.add(s.charAt(i));
                if (i == 0)
                    firstLetter = true;
            }
        }

        long ans = 1;
        for (int i = 0; i < numUnknowns ; ++i) {
            if (firstUnknown) {
                ans *= 9;
                firstUnknown = false;
            } else {
                ans *= 10;
            }
        }

        int numDiff = letters.size();
        for (int i = 0; i < numDiff ; ++i) {
            if (firstLetter) {
                ans *= 9;
                firstLetter = false;
            } else {
                ans *= (10 - i);
            }
        }

        System.out.println(ans);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = new StringTokenizer("");
        }

        public String next() {
            try {
                while (!tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = new StringTokenizer("");
                line =  reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) return false;
                tokenizer = new StringTokenizer(line);
            }
            return true;
        }
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class TaskA implements Runnable {

	private void solve() {
		boolean existA = false;
		boolean existJ = false;
		BigInteger ten = BigInteger.valueOf(10);
		BigInteger nine = BigInteger.valueOf(9);
		BigInteger answer = BigInteger.ONE;
		for (int i = 0; i < s.length(); ++i) {
			if (s.charAt(i) == 'A') {
				existA = true;
			}
			else if (s.charAt(i) == 'J') {
				existJ = true;
			}
			else if (s.charAt(i) == '?') {
				answer = answer.multiply(i == 0 ? nine : ten);
			}
		}
		if (existA && existJ) {
			answer = answer.multiply(s.charAt(0) == 'A' || s.charAt(0) == 'J' ? BigInteger.valueOf(81) : BigInteger.valueOf(90));
		}
		else if (existA || existJ) {
			answer = answer.multiply(s.charAt(0) == 'A' || s.charAt(0) == 'J' ? nine : ten);
		}
		out.println(answer);
	}

	private String s;

	private void readData() {
		s = in.next();
	}

	private void begin() {
		in = new InputReader(System.in);
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	private void end() {
		out.flush();
	}

	private InputReader in;
	private PrintWriter out;

	@Override
	public void run() {
		begin();
		readData();
		solve();
		end();
	}

	public static void main(String[] args) {
		new TaskA().run();
	}

	private class InputReader {

	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream));
	        tokenizer = null;
	    }

	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            }
	            catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public int readInt() {
	    	return Integer.parseInt(next());
	    }

	    public long readLong() {
	    	return Long.parseLong(next());
	    }

	    public String readString() {
	    	try {
				return reader.readLine();
			}
	    	catch (IOException e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
	    }

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * User: bpk
 * Date: 13.06.13
 * Time: 21:27
 */
public class SpecialTaskA2 {

    public static int numberOfCodes(String string) {

        List<Character> characters = new LinkedList<Character>();
        int numberOfQuestionMarks = 0;

        if (string.isEmpty()) {
            return 0;
        }

        for (int i = 0; i < string.length(); i++) {
            char c = string.charAt(i);
            if (!characters.contains(c)) {
                if (addToMap(c)) {
                    if (c == '?') {
                        numberOfQuestionMarks++;
                    } else {
                        characters.add(c);
                    }
                }
            }
        }

        int result = 1;
        if (numberOfQuestionMarks > 0) {
            result = result * numberOfQuestionMarks * 10;
        }

        int numberOfLetters = characters.size();
        result = (int) (result * Math.pow((10 - numberOfLetters + 1), numberOfLetters));

        if (addToMap(string.charAt(0))) {
            result--;
        }

        return result;
    }

    private static boolean addToMap(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == '?';
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String inputString = in.readLine();
        in.close();
        System.out.println(SpecialTaskA2.numberOfCodes(inputString));
    }
}

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class A implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(null, new A(), "", 256 * (1L << 20)).start();
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

          //  in = new BufferedReader(new FileReader("src/input.txt"));
            // out = new PrintWriter("output.txt");

            Locale.setDefault(Locale.US);
            solve();
            in.close();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    // solution
    void solve() throws IOException {
        String s = readString();
        HashSet<Character> chars = new HashSet<>();
        int zeroes = 0;
        boolean leadingZeroes = false;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '?') {
                zeroes++;
            } else if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
                continue;
            } else {
                if (i == 0) {
                    leadingZeroes = true;
                }
                chars.add(s.charAt(i));
            }
        }
        int total = 1;
        for (int i = 0; i < chars.size(); i++) {
            total *= (10 - i);
        }
        if (leadingZeroes) {
            total = total * 9 / 10;
        }
        out.print(total);
        for (int i = 0; i < zeroes; i++) {
            out.print('0');
        }
        out.println();
    }
}

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out, true);

		String s = in.readLine();
		BigInteger res = BigInteger.ONE;
		boolean used[] = new boolean[10];
		int ans = 1;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (!Character.isDigit(c) && c != '?') {
				int code = (int)c;
				int index = c - 65;
				used[index] = true;
			}
		}

		int ways = 10;
		for (int i = 0; i < 10; i++) {
			if (used[i]) {
				char c = s.charAt(0);
				if (!Character.isDigit(c) && c != '?') ans *= 9;
				else ans *= ways;
				ways--;
			}
		}
		if (s.charAt(0) == '?')
			ans *= 9;
		System.out.print(ans);
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == '?')
				System.out.print(0);
		}

		System.out.println();
	}
}

import java.util.Scanner;

public class SpecialTask {
	public static void main(String[] args) {
		Scanner k = new Scanner(System.in);
		int counter=1;
		char[] s=k.next().toCharArray();
		int f=0,ten=10;
		for (int i = 0; i < s.length; i++) {
			if(s[i]>64&&s[i]<75){
				if(i==0) {
					counter*=9;
					ten--;
					continue;
				}
				for (int j = 0; j <= i; j++) {
					if(s[i]==s[j]) f++;
				}

				if(f==1) {
					counter*=ten;
					ten--;
					f=0;
				}

			}else if(s[i]=='?'){
				if(i==0) counter*=9;
				else counter*=10;
			}
		}
		System.out.println(counter);
	}
}

import com.sun.imageio.plugins.common.BitFile;

import java.io.*;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: Pavel Kunyavskiy
 * Date: 12/06/13
 * Time: 17:03
 */
public class Main {

    long cnk(int n,int k){
        long ans = 1;
        for (int i = n-k+1; i <= n; i++)
            ans *= i;
        return ans;
    }

    void solve() throws IOException {
        String s = in.readLine();
        int n = s.length();
        BigInteger ans = BigInteger.ONE;
        for (int i = 0; i < n; i++)
            if (s.charAt(i) == '?')
                ans = ans.multiply(BigInteger.TEN);
        boolean used[] = new boolean[10];
        for (int i = 0; i < n; i++)
            if ('A' <= s.charAt(i) && s.charAt(i) <= 'J')
                used[s.charAt(i)-'A'] = true;

        int cnt = 0;
        for (int i = 0; i < 10; i++)
            if (used[i])
                cnt++;
        //System.err.println(cnt);
        long coef = cnk(10,cnt);
        if ('A' <= s.charAt(0) && s.charAt(0) <= 'J')
             coef -= cnk(9,cnt-1);
        ans = ans.multiply(BigInteger.valueOf(coef));
        out.println(ans);
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    BufferedReader in;
    StringTokenizer tokenizer;
    PrintWriter out;

    public void run() throws IOException {
        try {

            Reader reader = new InputStreamReader(System.in);
            Writer writer = new OutputStreamWriter(System.out);
            in = new BufferedReader(reader);
            tokenizer = null;
            out = new PrintWriter(writer);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author karzler
 */
import java.io.*;
import java.util.*;
public class ABBYY_A2 {
    public static void main(String[] args)throws IOException
    {
        BufferedReader br=new BufferedReader (new InputStreamReader (System.in));
        OutputStream out=System.out;
        PrintWriter pw=new PrintWriter (out,true);
        int count=10,ans=1;
        int[] hash=new int[10];
        Arrays.fill(hash,0);

        String s=br.readLine();
        if (Character.isLetter(s.charAt(0)))
        {
            ans*=9;
            count--;
            hash[(int)(s.charAt(0))-65]=1;
        }
        else if(s.charAt(0)=='?')ans*=9;
        for (int i=1;i<s.length();i++)
        {
            char ch=s.charAt(i);
            if (ch=='?')ans*=10;
            else if(Character.isDigit(ch))continue;
            else
            {
                if (hash[(int)(ch)-65]==1)continue;
                else
                {
                    hash[(int)(ch)-65]=1;
                    ans*=count;
                    count--;
                }
            }
        }
        pw.println(ans);

    }
}

import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	long factorial(int n) {
		long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}

	public void solve() throws Exception {
		String str = in.readLine();
		int questionMarks = 0;
		Set<Character> letters = new TreeSet<Character>();
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == '?') {
				questionMarks++;
			} else if (!Character.isDigit(str.charAt(i))) {
				letters.add(str.charAt(i));
			}
		}
		if (Character.isDigit(str.charAt(0))) {
			out.print(factorial(10) / factorial(10 - letters.size()));
			for (int i = 0; i < questionMarks; i++) {
				out.print('0');
			}
			out.println();
		} else if (str.charAt(0) == '?') {
			out.print(factorial(10) / factorial(10 - letters.size()) * 9);
			for (int i = 0; i < questionMarks - 1; i++) {
				out.print('0');
			}
			out.println();
		} else {
			out.print(factorial(9) / factorial(9 - (letters.size() - 1)) * 9);
			for (int i = 0; i < questionMarks - 1; i++) {
				out.print('0');
			}
			out.println();
		}
	}

	static Throwable uncaught;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable uncaught) {
			Solution.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		if (Solution.uncaught != null) {
			throw Solution.uncaught;
		}
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

	public String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zakhar Voit(zakharvoit@gmail.com)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA1 solver = new TaskA1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA1 {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        String s = in.nextToken();
        int cnt = 0;
        int cnt1 = 0;
        boolean[] vis = new boolean[300];

        for (char c : s.toCharArray()) {
            if ('A' <= c && c <= 'Z' && !vis[c]) {
                cnt++;
                vis[c] = true;
            }
            if (c == '?')
                cnt1++;
        }

        if (cnt > 10) {
            out.println(0);
            return;
        }

        long res = fact(10) / fact(10 - cnt);
        if ('A' <= s.charAt(0) && s.charAt(0) <= 'Z') {
            res = res - fact(9) / fact(10 - cnt);
        }

        int cnt2 = 0;
        if (s.charAt(0) == '?') {
            ++cnt2;
            --cnt1;
        }

        res = res * pow(10l, cnt1);
        res = res * pow(9l, cnt2);

        out.println(res);
    }

    long pow(long a, int n) {
        if (n == 0) {
            return 1l;
        }
        for (int i = 1; i < n; i++) {
            a *= a;
        }
        return a;
    }

    long fact(int n) {
        long res = 1l;
        for (Integer i = 2; i <= n; i++) {
            res *= (long)i;
        }
        return res;
    }
}

class Scanner {
    BufferedReader in;
    StringTokenizer tok;

    public Scanner(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
        tok = new StringTokenizer("");
    }

    public String nextToken() {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(nextLine());
        }

        return tok.nextToken();
    }

    private String tryReadNextLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public String nextLine() {
        String newLine = tryReadNextLine();
        if (newLine == null)
            throw new InputMismatchException();
        return newLine;
    }

    }

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        String [] sp;
        String s = br.readLine();
        int a = 0;
        boolean f = false;
        int c = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '?'){
                c++;
            }else if(s.charAt(i) - 'A' >=0 && s.charAt(i) - 'A' < 26){
                a++;
                if(i == 0)
                    f = true;
            }
        }
        BigInteger ans = new BigInteger(10 + "");
        ans = ans.pow(c);
        int r = 1;
        if(f){
            for (int i = 0; i < a -1 ; i++) {
                r *= (9 - i);
            }
            r *= 9;

        }else{
            for (int i = 0; i < a; i++) {
                r *= (10 - i);
            }

        }
        ans = ans.multiply(new BigInteger(r + ""));
        System.out.println(ans);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author shivam
 */
public class specialtask30 {
    public static void main(String[]args) throws IOException
    {
        boolean[] check=new boolean[10];
        BufferedReader n=new BufferedReader(new InputStreamReader(System.in));
        String hint=n.readLine();
        int cases=1;
        int counter=10;
        int length=hint.length();
        for(int h=0;h<length;h++)
        {
            if(hint.charAt(h)=='?')
            {
                if(h==0)
                {
                    cases=9*cases;
                }
                else
                {
                    cases=10*cases;
                }
            }
            else if(((int)hint.charAt(h))>=48 && ((int)hint.charAt(h))<=57 )
            {
                continue;
            }
            else
            {
                if(h==0)
                {
                    cases=9*cases;
                    counter--;
                }
                else
                {
                    if(!check[(int)hint.charAt(h)-65])
                    {
                        cases=counter*cases;
                        counter--;
                        check[(int)hint.charAt(h)-65]=true;
                    }

                }
            }

        }
        System.out.println(cases);
    }

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class A {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	void solve() throws Exception {
		String s = next();
		int cnt[] = new int[10];
		int zc = 0;
		// BigInteger ans = BigInteger.ONE;

		for (int i = 0; i < s.length(); i++) {
			if (Character.isAlphabetic(s.charAt(i)))
				cnt[s.charAt(i) - 'A']++;
			if (s.charAt(i) == '?')
				zc++;
		}

		int dc = 0;
		for (int i = 0; i < 10; i++) {
			if (cnt[i] > 0)
				dc++;
		}

		int ans = 10;
		if (Character.isAlphabetic(s.charAt(0))) {
			ans--;
			for (int i = 1; i < dc; i++)
				ans *= 10 - i;
		}
		if (Character.isDigit(s.charAt(0))) {
			ans = 1;
			for (int i = 0; i < dc; i++)
				ans *= 10 - i;
		}
		out.print(ans);
		for (int i = 0; i < zc; i++)
			out.print(0);
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new A().run();
	}

}

import java.util.Scanner;

public class SpecialTask
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		boolean[] flag = new boolean[10];
		for (int i = 0; i < 10; ++i)
		{
			flag[i] = false;
		}
		for (int i = 0; i < s.length(); ++i)
		{
			if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J')
			{
				flag[s.charAt(i) - 'A'] = true;
			}
		}
		int num = 0;
		for (int i = 0; i < 10; ++i)
		{
			if (flag[i])
			{
				++num;
			}
		}
		int res = 1;
		if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J')
		{
			res = 9;
		}
		int temp = 9;
		for (int i = 0; i < num - 1; ++i)
		{
			res *= temp;
			--temp;
		}
		if (s.charAt(0) == '?')
		{
			res *= 9;
		}
		for (int i = 1; i < s.length(); ++i)
		{
			if (s.charAt(i) == '?')
			{
				res *= 10;
			}
		}
		System.out.println(res);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class ABBYYCupTemp {

    public static void main(String args[]) throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        String stringMain = bf.readLine();
        ArrayList<String> arrayString = new ArrayList<>(Arrays.asList(stringMain.split("(?<=\\G.{2})")));
        ArrayList<Long> arrayResult = new ArrayList<>();

        for (int t=0; t<arrayString.size(); t++){

            long numberWhat = 0;
            long numberCombinationLetter = 1;

            ArrayList<String> arrayLetter = new ArrayList<>();

            stringMain = arrayString.get(t);

            for(int i=0; i<stringMain.length(); i++){

                if(!Character.isDigit(stringMain.charAt(i))){

                    if(Character.toString(stringMain.charAt(i)).equals("?"))
                        numberWhat++;
                    else
                        if(!arrayLetter.contains(Character.toString(stringMain.charAt(i))))
                            arrayLetter.add(Character.toString(stringMain.charAt(i)));

                }

            }

            if(!Character.isDigit(stringMain.charAt(0)) && t==0){

                if(!Character.toString(stringMain.charAt(0)).equals("?")){

                    for(int j=0, tempBase=9; j<(arrayLetter.size()-1); j++, tempBase--)
                        numberCombinationLetter = numberCombinationLetter*tempBase;

                    numberCombinationLetter=numberCombinationLetter*9;

                    arrayResult.add(numberCombinationLetter*(long)(Math.pow(10, numberWhat)));

                }
                else {
                    for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                        numberCombinationLetter = numberCombinationLetter*tempBase;

                    arrayResult.add(numberCombinationLetter*9*(long)(Math.pow(10, (numberWhat-1))));

                }

            }
            else{

                for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

                arrayResult.add(numberCombinationLetter*(long)(Math.pow(10, numberWhat)));

            }

        }

        long result=1;
        for(int r=0; r<arrayResult.size(); r++)
            result = result*arrayResult.get(r);

        System.out.print(result);

    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashSet;

public class A {

	public static void main(String[] args)throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		char s[]=reader.readLine().toCharArray();
//		HashSet<Character> hs=new HashSet<Character>();
		int count=10;
		long ret=1;
//		BigInteger []big=new BigInteger[11];
//		for(int i=0;i<big.length;i++)
//			big[i]=new BigInteger(i+"");

//		BigInteger ret=big[1];
		boolean v[]=new boolean [11];
		if(s[0]=='?')
		{
			ret=9;
//			ret=big[9];
			count=10;
		}
		else if(s[0]>='A' &&s[0]<='J')
		{
			ret=9;
//			ret=big[9];
			count=9;
			v[s[0]-'A']=true;
		}
		for(int i=1;i<s.length;i++)
		{
			if(s[i]=='?')
			{
				ret*=10;
//				ret=ret.multiply(big[10]);
			}
			else if(s[i]>='A' &&s[i]<='J')
			{
				if(!v[s[i]-'A'])
				{
					ret*=count;
//					ret=ret.multiply(big[count]);
					count--;
					v[s[i]-'A']=true;
				}
			}
		}
		System.out.println(ret);
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;

public class ABBYYCupTemp {

    public static void main(String args[]) throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        ArrayList<Long> arrayWhat = new ArrayList<>();
        BigInteger bIntWhatMain = BigInteger.ONE;
        BigInteger bIntWhatDegreeMain = BigInteger.valueOf(10);
        BigInteger bIntWhatSupport = BigInteger.valueOf(1000000000).multiply(BigInteger.valueOf(1000000000).multiply(BigInteger.valueOf(1000000000)));

        String stringMain = bf.readLine();
        String stringWhatList = new String();

        int numberWhat = 0;
        int numberCombinationLetter = 1;

        ArrayList<String> arrayLetter = new ArrayList<>();

        for(int i=0; i<stringMain.length(); i++){

            if(!Character.isDigit(stringMain.charAt(i))){

                if(arrayLetter.size()==10){
                    for(; i<stringMain.length(); i++)
                        if(Character.toString(stringMain.charAt(i)).equals("?")){

                            numberWhat++;
                            if(numberWhat==20){
                                stringWhatList += "00000000000000000000";
                                numberWhat=0;
                            }

                        }
                    break;
                }
                else {
                    if(Character.toString(stringMain.charAt(i)).equals("?")){

                        numberWhat++;
                        if(numberWhat==20){
                            stringWhatList += "00000000000000000000";
                            numberWhat=0;
                        }

                    }
                    else
                        if(!arrayLetter.contains(Character.toString(stringMain.charAt(i))))
                            arrayLetter.add(Character.toString(stringMain.charAt(i)));
                }

            }

        }

        if(numberWhat!=0){

            String stringWhatListTemp;

            if(Character.toString(stringMain.charAt(0)).equals("?"))
                stringWhatListTemp = bIntWhatDegreeMain.pow(numberWhat-1).toString();
            else
                stringWhatListTemp = bIntWhatDegreeMain.pow(numberWhat).toString();

            stringWhatList += stringWhatListTemp.substring(1, stringWhatListTemp.length());
        }

        if(Character.toString(stringMain.charAt(0)).equals("?")){

            for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                numberCombinationLetter = numberCombinationLetter*tempBase;

            numberCombinationLetter *= 9;
            //numberWhat--;

            /*String temp;
            if(numberWhat==0)
                System.out.print(numberCombinationLetter);
            else{
                temp = bIntWhatDegreeMain.pow(numberWhat).toString();
                System.out.print(numberCombinationLetter + "" + temp.substring(1, temp.length()));
            } */
            System.out.print(numberCombinationLetter + "" + stringWhatList);

        }
        else {

            if(!Character.isDigit(stringMain.charAt(0))) {

                numberCombinationLetter = 9;

                for(int j=1, tempBase=9; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

            }
            else
                for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

            //String temp = bIntWhatDegreeMain.pow(numberWhat).toString();

            if(numberCombinationLetter==1)
                if(numberWhat==0)
                    System.out.print(1);
                else
                    System.out.print(stringWhatList);
            else
                if(numberWhat==0)
                    System.out.print(numberCombinationLetter);
                else
                    System.out.print(numberCombinationLetter + "" + stringWhatList);

        }

    }

}

import java.math.BigInteger;
import java.util.Scanner;

public class SpecialTask {
	public static void main(String[] args) {
		Scanner k = new Scanner(System.in);
		int counter2=1;
		char[] s=k.next().toCharArray();
		int f=0,ten2=10;
		if(!(s[0]<58&&s[0]>47)) {
			if(s[0]>64&&s[0]<75) ten2=9;
			counter2=9;
		}
		BigInteger counter = new BigInteger(counter2+"");
		BigInteger ten = new BigInteger(ten2+"");
		BigInteger one = new BigInteger("1");
		BigInteger TEN = new BigInteger("10");
		for (int i = 1; i < s.length; i++) {
			if(s[i]>64&&s[i]<75){

				for (int j = 0; j <= i; j++) {
					if(s[i]==s[j]) {
						f++;
						if(f>1) break;
					}
				}

				if(f==1) {
					counter=counter.multiply(ten);
					ten=ten.subtract(one);

				}
				f=0;

			}else if(s[i]=='?'){

					counter.multiply(TEN);

			}
//			}else if(s[i]>47&&s[i]<58){
//				if(i==0) {
//					counter*=9;
//				}
//				else {
//					for(int j = 0; j <= i; j++) {
//						if(s[i]==s[j]) f2++;
//					}
//
//					if(f2==1) {
//						counter*=10;
//
//					}
//					f2=0;
//				}
//			}
		}
		System.out.println(counter);
	}
}

import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Problem4 {

	private static Set<Character> lettersused = new HashSet<Character>();
	private static long questionMarksUsed=0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		/*
		Scanner in = new Scanner(System.in);

		while (in.hasNextLine()) {
			   String line = in.nextLine();
			   getCombinations(line);
		}
		*/

		getCombinations("BC??");

	}

	private static void getCombinations(String safe) {

        if(safe==null || safe.isEmpty()) {
            System.out.println(0);
        }
        for(int i=0; i<safe.length(); i++) {
            treatCharacter(safe.charAt(i));
        }

        long aux=1;
        if(Character.isDigit(safe.charAt(0))) {
        	for(int i=0 ; i<lettersused.size();i++) {
            	aux*=10-i;
            }
        }
        else {
	       	if (safe.charAt(0)=='?') {
	        	aux=9;
	        	questionMarksUsed--;
	        	for(int i=0 ; i<lettersused.size();i++) {
	            	aux*=9-i;
	            }
	        }
	        else {
	        	aux=9;
	        	for(int i=0 ; i<lettersused.size()-1;i++) {
	            	aux*=9-i;
	            }
	        }
        }

        BigInteger res = new BigInteger(Long.toString(aux));
        aux=1;
        for(int i=0;i<questionMarksUsed; i++) {
        		aux*=10;
        }
        res = res.multiply(new BigInteger(Long.toString(aux)));

        System.out.println(res);

        lettersused.clear();
    }

    private static void treatCharacter(char c) {
        // TODO Auto-generated method stub
        if(c=='?') {
            questionMarksUsed++;
        }

        else if(!Character.isDigit(c)) {
        	checkLetter(c);
        }

    }

    private static void checkLetter(Character c) {

    	if(lettersused.size()<10 && !lettersused.contains(c)) {
    		lettersused.add(c);
    	}
    }

}

import java.io.*;
import java.util.*;
public class a316
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
       // System.out.println("Enter");
        String s=in.readLine();
        String s1="";
        int i,j=1,pro=1,k=0,num=10,nc=0;
        int A[]=new int[10];
        if(s.charAt(0)=='?')
            {
                j=9;
            }
        else if(Character.isLetter(s.charAt(0))==true)
               {
                  A[(int)s.charAt(0)-65]=9;
                   k++;
                }
        for(i=1;i<s.length();i++)
        {
            if( Character.isLetter(s.charAt(i))==true)
            {
                if(A[(int)s.charAt(i)-65]==0)
               {
                   A[(int)s.charAt(i)-65]=num-k;
                   k++;
                }
                nc++;
            }
        }
        for(i=0;i<10;i++)
        {
           // System.out.println(A[i]);
            if(A[i]!=0)
            pro*=A[i];
        }
        System.out.print(pro*j);
        for(i=0;i<(s.length()-1-nc);i++)
        System.out.print("0");
    }
}

import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  String s = input.next();
  long res = 1;
  boolean[] found = new boolean[10];
  int qs = 0;
  for(int i = 0; i<s.length(); i++)
  {
    char c = s.charAt(i);
    if(c=='?') qs++;
    else if(c >= 'A' && c<= 'J') found[c-'A'] = true;
  }
  int count = 0;
  for(int i = 0; i<10; i++) if(found[i]) count++;
  for(int i = 0; i<count; i++)
  {
    res *= (i==0 && s.charAt(0) >= 'A' && s.charAt(0) <= 'J') ? 9 : (10-i);
  }
  PrintWriter out = new PrintWriter(System.out);
  out.print(res);
  for(int i = 0; i<qs; i++) out.print('0');
  out.println();
  out.close();
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
}
}

import java.io.*;
import java.util.*;
public class a316
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
        //System.out.println("Enter");
        String s=in.readLine();
        int i,j=1,pro=1,k=0,num=10;
        int A[]=new int[10];
        if(s.charAt(0)=='?' || Character.isLetter(s.charAt(0))==true)
            {
                j=9;
                if(Character.isLetter(s.charAt(0))==true)
               {
                  A[(int)s.charAt(0)-65]=9;
                   k++;
                }
            }
        for(i=1;i<s.length();i++)
        {
            if( Character.isLetter(s.charAt(i))==true)
            {
                if(A[(int)s.charAt(i)-65]==0)
               {
                   A[(int)s.charAt(i)-65]=num-k;
                   k++;
                }
            }
            if(s.charAt(i)=='?')
            pro*=10;
        }
        for(i=0;i<10;i++)
        {
           // System.out.println(A[i]);
            if(A[i]!=0)
            pro*=A[i];
        }
        System.out.println(pro);
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class A {

	private static StringTokenizer tokenizer;
    private static BufferedReader bf;
    private static PrintWriter out;

	private static int nextInt() throws IOException {
    	return Integer.parseInt(nextToken());
    }

	private static long nextLong() throws IOException {
    	return Long.parseLong(nextToken());
    }

    private static String nextToken() throws IOException {
    	while(tokenizer == null || !tokenizer.hasMoreTokens()) {
    		tokenizer = new StringTokenizer(bf.readLine());
    	}
    	return tokenizer.nextToken();
    }

	public static void main(String[] args) throws IOException {
		bf = new BufferedReader(new InputStreamReader(System.in));
    	tokenizer = null;
    	out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    	String s = nextToken();
    	int len = s.length();
    	int[] a = new int[10];
    	BigInteger res; char c; int num1 = 0, num2 = 0;
    	for(int i = 0; i < len; i++) {
    		c = s.charAt(i);
    		if(c == '?') num1++;
    		else if(c-'A' >= 0 && c-'A' <= 9) a[c-'A']++;
    	}
    	for(int i = 0; i < 10; i++) {
    		if(a[i] != 0) num2++;
    	}
    	c = s.charAt(0);
    	if(c == '?') {
    		res = BigInteger.valueOf(10);
    		res = res.pow(num1-1);
    		res = res.multiply(BigInteger.valueOf(9));
    		for(int i = 10; i > 10-num2; i--)
    			res = res.multiply(BigInteger.valueOf(i));
    	}
    	else if(c-'A' >= 0 && c-'A' <= 9) {
    		res = BigInteger.valueOf(10);
    		res = res.pow(num1);
    		res = res.multiply(BigInteger.valueOf(9));
    		for(int i = 9; i > 10-num2; i--)
    			res = res.multiply(BigInteger.valueOf(i));
    	}
    	else if(num1 + num2 > 0){
    		res = BigInteger.valueOf(10);
    		res = res.pow(num1);
    		for(int i = 10; i > 10-num2; i--)
    			res = res.multiply(BigInteger.valueOf(i));
    	}
    	else res = BigInteger.ZERO;
    	out.println(res);
    	out.close();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        long ans = 1;
        HashSet<Character> H = new HashSet<Character>();
        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) == '?')
                if (i == 0)
                    ans *= 9;
                else
                    ans *= 10;
            else if (Character.isLetter(s.charAt(i)))
                H.add(s.charAt(i));
        if (H.size() > 10)
            System.out.println(0);
        else {
            if (H.size() > 0) {
                if (Character.isLetter(s.charAt(0)))
                    ans *= 9;
                else
                    ans *= 10;
                for (int i = 1; i < H.size(); i++)
                    ans *= 10 - i;
            }
            System.out.println(ans);
        }
    }
}

import java.util.Scanner;

public class a1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n=10,ans=1;
            String a=in.next();
            int[] b = new int[26];
            for (int i=0;i<26;i++) {
                b[i]=0;
            }
            if (a.charAt(0)>='A'&&a.charAt(0)<='Z') {
                ans*=9;
                b[a.charAt(0)-'A']=1;
                n--;
            }
            if (a.charAt(0)=='?') {

                ans*=9;
            }

            for (int i=0;i<a.length();i++) {

                if (a.charAt(i)>='0'&&a.charAt(i)<='9')
                    continue;
                else if (a.charAt(i)=='?')
                    ans*=10;
                else if (a.charAt(i)>='A'&&a.charAt(i)<='Z'){
                    if (b[a.charAt(i)-'A']==0){
                        ans*=n;
                        b[a.charAt(i)-'A']=1;
                        n--;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskA1 solver = new TaskA1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA1 {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    char[] input = in.next().toCharArray();
	    long ans = 1;
	    boolean[] letter = new boolean[26];
	    for(int i = 0; i < input.length; i++) {
		    char c = input[i];
		    if(Character.isDigit(c)) continue;
		    if(c >= 'A' && c <= 'Z'){
			    letter[c - 'A'] = true;
			    continue;
		    }
		    if(i != 0) ans *= 10;
		    else ans *= 9;
	    }
	    int different = 0;
	    for(boolean b : letter) if (b) different++;
	    ans *= IntegerUtils.power(11 - different, different);
	    out.print(ans);
    }
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			if (Character.isValidCodePoint(c))
				res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public String next() {
		return readString();
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void close() {
		writer.close();
	}
	public void print(long i) {
		writer.print(i);
	}
}

class IntegerUtils {
	public static long power(long base, long exponent) {
		if (exponent == 0)
			return 1;
		long result = power(base, exponent >> 1);
		result = result * result;
		if ((exponent & 1) != 0)
			result = result * base;
		return result;
	}
}

import java.util.*;

public class STASK {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String code = in.nextLine();
		int[] deCode = new int[11];
		int questionMark = 0;
		int count = 0;
		boolean leadZero = false;
		int zeroCase = 1;
		if(Character.isLetter(code.charAt(0))) {
			zeroCase = 9;
			leadZero = true;
		}

		for(int i = 0; i < code.length(); i++) {
			if(code.charAt(i) == '?') {
				questionMark++;
			}
			else if(Character.isLetter(code.charAt(i))) {
				deCode[code.charAt(i) - 'A' + 1]++;
			}
		}
		for(int i = 1; i < deCode.length; i++) {
			if(deCode[i] > 0)
				count++;
		}

		int mystery = (int)Math.pow(10, questionMark);
		if(leadZero) {
			int answer = factorial(9, count - 1);
			System.out.println(zeroCase * answer * mystery);
		}
		else {
			int answer2 = factorial(10, count);
			System.out.println(answer2 * mystery);
		}
	}

	public static int factorial(int n, int stop) {
		int x = n;
		int sum = 1;
		for(int i = 0; i < stop; i++) {
				sum *= x--;
		}
		return sum;
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws Exception
    {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run() throws Exception
    {
        //Locale.setDefault(Locale.US);
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    void solve() throws Exception
    {
        String s = in.nextLine();
        boolean used[] = new boolean[10];

        int pow10 = 0;
        for (int i = 0; i < s.length(); i++)
        {
            if (s.charAt(i) == '?')
                pow10++;
            else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J')
                used[s.charAt(i) - 'A'] = true;
        }

        BigInteger res = BigInteger.TEN.pow(pow10);

        int cnt = 0;
        for (int i = 0; i < 10; i++)
            if (used[i])
                cnt++;

        BigInteger fact = BigInteger.ONE;
        for (int i = 10; i > 10 - cnt; i--)
            fact = fact.multiply(BigInteger.valueOf(i));

        if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J')
            fact = fact.divide(BigInteger.TEN).multiply(BigInteger.valueOf(9));
        res = res.multiply(fact);

        out.print(res);
    }
}

import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner cin = new Scanner (new BufferedInputStream(System.in));
    String s;
    s=cin.next();
    int l=s.length();
    int a,b;
    int p[]=new int [300];
    a=0;b=0;;
    for(int i=0;i<300;i++)
      p[i]=0;
    BigInteger ans1,ans2;
    ans2=BigInteger.valueOf(1);
    ans2=BigInteger.valueOf(1);
    for(int i=0;i<l;i++)
      if(s.charAt(i)>='A' && s.charAt(i)<='J')
      {
        if(p[(int)s.charAt(i)]==0)
        {
          p[(int)s.charAt(i)]=1;
          a++;
        }
      }
      else if(s.charAt(i)=='?')b++;
    if(b!=0)
    {
    	ans1=BigInteger.valueOf(10);
        //ans1=ans1.pow(b);
    }
    else ans1=BigInteger.valueOf(1);
    for(int i=0;i<a;i++)
      ans1=ans1.multiply(BigInteger.valueOf(10-i));
    if(s.charAt(0)=='?')ans2=BigInteger.valueOf(1);
    else ans2=BigInteger.valueOf(1);
    if(s.charAt(0)>='A'&&s.charAt(0)<='J')
    {
      a--;
      for(int i=0;i<a;i++)
      ans2=ans2.multiply(BigInteger.valueOf(9-i));
    }
    else
    {
      for(int i=0;i<a;i++)
      ans2=ans2.multiply(BigInteger.valueOf(10-i));
    }
    if(s.charAt(0)>='1'&& s.charAt(0)<='9')ans2=BigInteger.valueOf(0);
    BigInteger ans;
    ans=ans1.subtract(ans2);
    System.out.printf("%s",ans.toString());
    for(int i=1;i<b;i++)
    	System.out.printf("0");
  }
}

import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner input = new Scanner(System.in);
        String s = input.next();
        int an=0,x=11,xx=0;
        boolean a[]=new boolean[10];
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='?')
                an++;
            else if('A'<=s.charAt(i)&&s.charAt(i)<='J'&& !a[s.charAt(i)-'A']){
                a[s.charAt(i)-'A'] = true;
                xx++;x--;
            }
        }
        System.out.println(xx+" "+x+" "+an);
        System.out.println((int)Math.pow(x,xx)*(int)Math.pow(10,an));

    }
}

import java.util.Scanner;

public class Prob316A {
	public static void main(String[] Args) {
		Scanner scan = new Scanner(System.in);
		char[] s = scan.next().toCharArray();
		long ans = 1;
		int count = 0;
		boolean[] temp = new boolean[(int) ('J' - 'A' + 1)];

		if (s[0] == '?')
			ans = 9;
		else if (s[0] >= 'A' && s[0] <= 'J') {
			temp[s[0] - 'A'] = true;
			ans = 9;
			count++;
		}

		for (int i = 1; i < s.length; i++) {
			if (s[i] == '?')
				ans *= 10;
			else if (s[i] >= 'A' && s[i] <= 'J') {
				if (!temp[s[i] - 'A']) {
					temp[s[i] - 'A'] = true;
					ans *= (10 - count);
				}
			}
		}

		System.out.println(ans);
	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        String [] sp;
        String s = br.readLine();
        int a = 0;
        boolean f = false;
        int c = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '?'){
                c++;
            }else if(s.charAt(i) - 'A' >=0 && s.charAt(i) - 'A' < 26){
                a++;
                if(i == 0)
                    f = true;
            }
        }
        BigInteger ans = new BigInteger(10 + "");
        ans = ans.pow(c);
        int r = 1;
        if(f){
            for (int i = 0; i < a -1 ; i++) {
                r *= (9 - i);
            }
            r *= 9;

        }else{
            for (int i = 0; i < a; i++) {
                r *= (10 - i);
            }

        }
        ans = ans.multiply(new BigInteger(r + ""));
        System.out.println(ans);
    }

}

		import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

		public class Main{

		public static void main(String[] args) throws IOException {
		//Scanner k = new Scanner(System.in);
		BufferedReader k=new BufferedReader(new InputStreamReader(System.in));
		StringBuffer str=new StringBuffer();
		PrintWriter out=new PrintWriter (new OutputStreamWriter((System.out)));
        String hint=k.readLine();
        //int num=1;
        BigInteger num=BigInteger.ONE;
        int Qmarkcount=0;
        boolean Qmarkflag=false;
        int charcount=0;

        int count=9;
        boolean check=false;
        ArrayList<Character>array=new ArrayList<>();
        for (int i = 0; i < hint.length(); i++) {
			if (hint.charAt(i)=='?'&&i==0) {
				Qmarkflag=true;
				//num=BigInteger.valueOf(9);
			}
			else if (hint.charAt(i)=='?') {
				//num=num.multiply(BigInteger.TEN);
				Qmarkcount++;
			}
			else if (hint.charAt(i)>='A'&&hint.charAt(i)<='J'&&charcount<11) {
				if (array.isEmpty()&&i!=0) {
					array.add(hint.charAt(i));
					num=num.multiply(BigInteger.TEN);
					charcount++;
					//num*=10;
				}
				else if (array.isEmpty()&&i==0) {
				num=num.multiply(BigInteger.valueOf(9));
				charcount++;

					array.add(hint.charAt(i));
                    check=true;
				}

				else if (!array.isEmpty()&&!array.contains(hint.charAt(i))) {
					if(count>0)
					num=num.multiply(BigInteger.valueOf(count));

					array.add(hint.charAt(i));
                    count--;
					charcount++;

				}
			}

		}
        if (Qmarkflag) {
			num=num.multiply(BigInteger.valueOf(9));
		}
        out.print(num);

        for (int i = 0; i < Qmarkcount; i++) {
			out.print("0");
		}
        out.println(num);
        out.print(str);
		out.close();

		}

		    }

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author Lotus
 */
public class A3161 {
    public static void main(String[]args)
    {
        Scanner input = new Scanner(System.in);
        String str = input.next();
        int counter=1;
        int count1=0;
        int count2=0;
        int[]let= new int[10];

        for(int i=0; i<str.length();i++)
        {
            if(str.charAt(i)=='?')
            {
                count1++;
            }
           else  if(str.codePointAt(i)>=65)
           {
            let[str.codePointAt(i)-65] ++;
           }

        }

        for(int j=0 ;j<let.length;j++)
        {
            if(let[j]!=0)
            {
                count2 ++;
            }
        }
        counter=(int) Math.pow(10, count1);
        int counter2=1;
        int k;
        if(str.codePointAt(0)>=65)
        {
            k=9;
            counter2=k;
        }
        else
        {
            k=10;

        }

        for( int j=k ; j>10-count2; j--)
        {

            counter2*=j;
        }

      System.out.println(counter*counter2);

    }

}

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Javi
 */
public class SpecialTaskA2 {

    private static Character QUESTION_MARK = '?';
    private static int NUM_DIGITS = 10;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] input = in.nextLine().split(" ");
        String hint = input[0];

        int numQMarks = 0;
        int numLetters = 0;
        List<Character> lettersAlreadyVisited = new ArrayList<Character>(10);
        for (int i = 0; i < hint.length(); i++) {
            Character c = hint.charAt(i);
            if(QUESTION_MARK.equals(c)) {
                numQMarks++;
            } else if(Character.isLetter(c) && !lettersAlreadyVisited.contains(c)) {
                numLetters++;
                lettersAlreadyVisited.add(c);
            }
        }
        int letterPermutations = fact(NUM_DIGITS)/fact(NUM_DIGITS-numLetters);
        BigInteger qmarksPermutations = pow2(NUM_DIGITS, numQMarks);
        BigInteger numPasswords = BigInteger.valueOf(letterPermutations);
        numPasswords = numPasswords.multiply(qmarksPermutations);
        if (QUESTION_MARK.equals(hint.charAt(0)) || lettersAlreadyVisited.contains(hint.charAt(0))) {
            numPasswords = numPasswords.subtract(numPasswords.divide(BigInteger.valueOf(10)));
        }

        System.out.println(numPasswords);

        in.close();
    }

    private static int fact(int n) {
        int res = n;
        for (int i = 1; i < n; i++) {
            res = res * (n-i);
        }
        return res;
    }

    private static BigInteger pow(int a, int b) {
        BigInteger res = BigInteger.ONE;
        for (int i = 0; i < b; i++) {
            res = res.multiply(BigInteger.valueOf(a));
        }
        return res;
    }

    private static BigInteger pow2(int a, int b) {
        long res = 1;
        BigInteger resBI = BigInteger.ONE;
        for (int i = 0; i < b; i++) {
            if(res < Long.MAX_VALUE/a) {
                res = res*a;
            } else {
                resBI = resBI.multiply(BigInteger.valueOf(res));
                res = 1;
            }
        }
        return resBI.multiply(BigInteger.valueOf(res));
    }
}

import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class A316 {
	static final double EPS = 1e-10;
	static final double INF = 1 << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		input = br.readLine();
		int ans =1;
		int[] count = new int [26];
		//if (input.charAt(0)=='0')
		int zeros=0;
		for (int i=0; i<input.length(); i++){
			char c =input.charAt(i);
			if (c=='?') zeros++;
			else if ('A'<=c && c<='Z') count[c-'A']=1;
		}
		int s=0;
		for (int i=0; i<26; i++)
			if (count[i]==1) s++;
		if ('A'<=input.charAt(0) && 'Z'>=input.charAt(0)) {
			ans =9;
			for (int i=1; i<s; i++) ans*=10-i;
			if (input.length()==1) ans++;
		}else {
			for (int i=1; i<=s; i++) ans*=11-i;
		}
		if (input.charAt(0)=='?' && input.length()>1){
			ans*=9;
			zeros--;
		}
		sb.append(ans);
		for (int i=0; i<zeros; i++) sb.append('0');
		ln(sb);
	}

	public static void main(String[] args) throws IOException {
		new A316().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class A {
	BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

    public long nCr(int n, int k){
		long ans = 1;
		int cb[] = new int[k];

		for (int i=0; i<k; i++)
			cb[i] = i + 1;
		for (int i=n; i>=n-k+1; i--){
			ans *= i;
			for (int j=0; j<cb.length; j++)
				if (ans % cb[j] == 0){
					ans /= cb[j];
					cb[j] = 1;
				}
		}
		return ans;
	}

    public boolean ischar(char c){
    	return c >= 'A' && c <= 'Z';
    }

	public void solve() throws IOException {
		char[] S = reader.readLine().toCharArray();

		boolean[] set = new boolean[26];
		long ans = 1;
		for(int i = 0; i < S.length; i++){
			if( ischar(S[i]) ){
				set[ S[i]-'A' ] = true;
			}
			else if( S[i] == '?') ans *= 10;
		}
		int count = 0;
		for(int i = 0; i < 26; i++){
			if( set[i] ) count++;
		}
		if( count >= 10) {
			out.println(0); return;
		}
		if( ischar(S[0]) && count >= 9){
			out.println(0); return;
		}

		for(int i = 1; i <= count; i++){
			ans = ans * (11-i);
		}
		if(ischar(S[0])){
			ans = ans / 10 * 9;
		}

//		if(ischar(S[0])){
//			long ans2 = 9;
//			ans2 *= nCr(9, count-1);
//			for(int i = 1; i <= count-1; i++)
//				ans2 *= i;
//			ans *= ans2;
//		}
//		else{
//			long ans2 = nCr(10, count);
//			for(int i = 1; i <= count; i++)
//				ans2 *= i;
//			ans *= ans2;
//		}
		out.println( ans );
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new A().run();
	}

	public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * User: bpk
 * Date: 13.06.13
 * Time: 21:27
 */
public class SpecialTaskA2 {

    public static int numberOfCodes(String string) {

        List<Character> characters = new LinkedList<Character>();
        int numberOfQuestionMarks = 0;

        if (string.isEmpty()) {
            return 0;
        }

        for (int i = 0; i < string.length(); i++) {
            char c = string.charAt(i);
            if (!characters.contains(c)) {
                if (addToMap(c)) {
                    if (c == '?') {
                        numberOfQuestionMarks++;
                    } else {
                        characters.add(c);
                    }
                }
            }
        }

        int result = 1;
        if (numberOfQuestionMarks > 0) {
            result = result * numberOfQuestionMarks * 10;
        }

        int numberOfLetters = characters.size();
        result = (int) (result * Math.pow((10 - numberOfLetters + 1), numberOfLetters));

        return result;
    }

    private static boolean addToMap(char c) {
        return c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == '?';
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String inputString = in.readLine();
        in.close();
        System.out.println(SpecialTaskA2.numberOfCodes(inputString));
    }
}

import java.io.*;
import java.util.*;

public class Main {
//	static Scanner in;
	static PrintWriter out;
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
	static BufferedReader in;

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
//		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		in = new BufferedReader(new InputStreamReader(System.in));

		char[] c = in.readLine().toCharArray();
		int n = c.length;

		int[] kol = new int[27];
		for (char cc : c) {
			if (cc == '?') kol[26]++;
			if ('A' <= cc && cc <= 'J') kol[cc - 'A']++;
		}

		boolean startletter = 'A' <= c[0] && c[0] <= 'J';

		int x = 0;
		for (int i = 0; i < 10; i++) if (kol[i] != 0) x++;

		long ans = 1;

		for (int i = 0; i < x; i++) {
			if (startletter && i == 0) ans *= 9;
			else ans *= (10 - i);
		}

		out.print(ans);
		for (int i = 0; i < kol[26]; i++) out.print("0");
		out.println();
		out.close();
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

    public static void main(String[] args)
    {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run()
    {
        try
        {
            //in = new Scanner(new File("INPUT.TXT")); out = new PrintWriter(new File("OUTPUT.TXT"));
            in = new Scanner(System.in); out = new PrintWriter(System.out);
            solve();
            out.flush();
        }catch (Throwable e)
        {

        }
    }

    BigInteger BI(long a)
    {
        return BigInteger.valueOf(a);
    }

    void solve()
    {
    String s = in.next();
        boolean mas[]=new boolean[256];
        BigInteger answ = BI(1);
        int cnt = 0,k=0;
        boolean nine=false;
        for(int i=0; i<s.length(); ++i)
        {
            if(s.charAt(i) == '?')
                ++k;
            if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z' && !mas[s.charAt(i)])
            {
                mas[s.charAt(i)]=true;
                if(i==0)
                    nine=true;
                else
                    ++cnt;
            }
        }
        if(nine)
        {
            answ = BI(9);
            for(int i=9; i>9-cnt; --i)
                answ = answ.multiply(BI(i));
        }
        else
            for(int i=10; i>10-cnt; --i)
                answ = answ.multiply(BI(i));
        answ = answ.multiply(BI(10).pow(k));
        out.println(answ);
    }
}

import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner input = new Scanner(System.in);
        String s = input.next();
        int an=0,x=11,xx=0;
        boolean a[]=new boolean[10];
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='?')
                an++;
            else if('A'<=s.charAt(i)&&s.charAt(i)<='J'&& !a[s.charAt(i)-'A']){
                a[s.charAt(i)-'A'] = true;
                xx++;x--;
            }
        }
        //System.out.println(xx+" "+x+" "+an);
        System.out.println((int)Math.pow(x,xx)*(int)Math.pow(10,an));
    }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Codeforces {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		char[] c = in.next().toCharArray();
		BigInteger ans = BigInteger.ONE;
		if (c.length == 1) {
			if (c[0] >= '0' && c[0] <= '9') out.println(1);
			else out.println(10);
			return;
		}
		boolean[] was = new boolean[1000];
		boolean first = false;
		int count = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] == '?') {
				if (i != 0) ans = ans.multiply(BigInteger.valueOf(10));
				else {
					ans = ans.multiply(BigInteger.valueOf(9));
				}
			}
			if (c[i] >= 'A' && c[i] <= 'Z') {
				if (i == 0) first = true;
				if (!was[c[i]]) {
					count++;
				}
				was[c[i]] = true;
			}
		}

		int dif = 10;
		if (first) {
			dif--;
			count--;
			ans = ans.multiply(BigInteger.valueOf(9));
		}
		long[][] C = new long[100][100];
		for (int i = 0; i < 100; i++) {
			C[i][0] = 1;
		}
		for (int i = 1; i < 100; i++) {
			for (int j = 1; j < 100; j++) {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
		ans = ans.multiply(BigInteger.valueOf(C[dif][count]));

		out.println(ans);
	}

	public void run() {
		try {
			in = new FastScanner();
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		boolean hasNext() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String s = br.readLine();
					if (s == null) {
						return false;
					}
					st = new StringTokenizer(s);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return true;
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new Codeforces().run();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class A {

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		boolean[] visit = new boolean[10];
		BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
		// StringTokenizer t = new StringTokenizer(rd.readLine(), " ");
		String s = rd.readLine();
		int l = s.length();
		long out = 1;
		int used = 0;
		for (int i = 0; i < l; i++) {
			char c = s.charAt(i);
			if (c == '?') {
				if (i != 0)
					out *= 10;
				else
					out *= 9;
			} else if (c <= 'J' && c >= 'A') {
				if (!visit[c - 'A']) {
					visit[c - 'A'] = true;
					if (i != 0)
						out *= (10 - used);
					else
						out *= (9 - used);
					used++;
				}
			}
		}
		System.out.println(out);
	}
}

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Task316A2 {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Solution {

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner sc = new Scanner(is);

			String inp = sc.nextLine();

			for (int i = 0; i < inp.length(); i++) {
				if (inp.charAt(i) == '?') {
					pw.print('1');
				}
				if (inp.charAt(i) <= '9' && inp.charAt(i) >= '0') {
					pw.print(inp.charAt(i));
				}
				if (inp.charAt(i) <= 'A' && inp.charAt(i) >= 'J') {
					pw.print('0' + inp.charAt(i) - 'A');
				}
			}

			pw.flush();
			sc.close();
		}
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class jvcls
{
    public static List<Integer>[] g;
    public static  boolean [] prime;
    public static boolean [] visited;
    public static StringTokenizer st;
    public static BufferedReader br;
    public static PrintWriter out;
    public static int[] tree;

    public static void main(String... args)throws  IOException{

        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        String s = nextToken();
        Set<Character> letset = new HashSet<Character>();
        int k =0;

        for (int i=0;i<s.length();++i)
        {

            if(s.charAt(i)>='A' && s.charAt(i)<='J'&& !letset.contains(s.charAt(i)))
            {
                letset.add(s.charAt(i));
                k++;
            }
            if(s.charAt(i)=='?')
                k++;

        }
        if(k==0)
        {out.print(0);out.close();return;  }

        BigInteger ans  = BigInteger.ONE;
        for (int i =0;i<k;i++)
        {
          ans=  ans.multiply(BigInteger.TEN);

        }

        if(s.charAt(0)>='0' && s.charAt(0)<='9' )
        {
            out.print(ans);
        }
        else
        {
            if(s.charAt(0)!='?')
            {
               int rep=1;
              ans= BigInteger.ONE;

               for (int i=1;i<s.length();i++)
                   if (s.charAt(i)==s.charAt(0))
                       rep++;
               BigInteger nine = BigInteger.TEN;
                nine = nine.subtract(BigInteger.ONE);

               for (int i =0;i<rep;i++)
                   ans=  ans.multiply(nine);

                for (int i =0;i<k-rep;i++)
                {
                    ans=  ans.multiply(BigInteger.TEN);;
                }
                out.print(ans);
            }
            else
                out.print(ans.subtract(BigInteger.TEN));
        }

        out.close();
    }
  public static   long gcd (long a, long b) {

        return b>0 ? gcd (b, a % b) : a;

    }

    public static void dfs(int v, List<Integer> way)
    {

        visited[v]=true;
        for (int i =0; i<g[v].size(); i++){

            int p = g[v].get(i);
            if(!visited[p]){
          //      found++;
                way.add(p+1);
                dfs(p, way);
            };

        }

    }
    public static void Resheto(int n)
    {
        prime[0] = prime[1] = false;
        for (int i=2; i<=n; ++i)
            if (prime[i])
                if (i * 1l * i <= n)
                    for (int j=i*i; j<=n; j+=i)
                        prime[j] = false;
    }

    public static String nextToken() throws IOException {
        while ( st == null || !st.hasMoreTokens() ) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public static int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public static double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public static long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public static int[] ReadIntArray(int n) throws IOException {
        int[] a = new int[n];
        for ( int i = 0; i < n; i++ ) {
            a[i] = nextInt();
        }
        return a;

    }
    public static void PrintArray(int[] arr) throws IOException
    {
        for ( int anArr : arr ) out.print(anArr+" ");

    }
    public static long[] ShuffleArray(long [] arr)
    {
        Random rnd = new Random();

        int n = arr.length;
        long    temp;
        int     ind;
        while (n > 1)
        {
            ind = rnd.nextInt(n--);
            temp = arr[ind];
            arr[ind] = arr[n];
            arr[n] = temp;
        }

        return arr;
    }
}

import java.util.Scanner;

public class Abby_1 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		long result = 1;
		int dif = 0;
		int quest = 0;
		char c;
		boolean[] exist = new boolean[10];
		for (int i = 0; i < s.length(); i++) {
			c = s.charAt(i);
			if(c == '?') {
				quest++;
			}
			else if(c >= 65 && c <= 74) {
				if(!exist[c-65]) {
					exist[c-65] = true;
					dif++;
				}
			}
		}
		c = s.charAt(0);
		int start = 10;
		if(c >= 65 && c <= 74) {
			start = 9;
			result *= 9;
			dif--;
		}
		else if(c == '?') {
			result *= 9;
			quest--;
		}
		result = (long) (result * Math.pow(10, quest));
		for (int i = 0; i < dif; i++) {
			result = result * (start-i);
		}
		System.out.println(result);
	}

}

import java.util.Scanner;

public class S {
public static void main(String[] args) {
    Scanner in =new Scanner (System.in);
    //System.out.println((int)'Z');
    String a=in.next();
    int sum=1;
    int m=10;
    char[] ar=new char[100];

    for(int i=0;i<a.length();i++){

        if((int)a.charAt(i)>=48&&(int)a.charAt(i)<=57)
            sum*=1;
        if(a.charAt(i)=='?')
            sum*=10;
        if((int)a.charAt(i)>=65&&(int)a.charAt(i)<=90&&ar[(int)a.charAt(i)]==0){
            if(i==0){
                sum*=9;
                m--;
                ar[(int)a.charAt(i)]=1;
            }
            else{
                sum*=m;
                ar[(int)a.charAt(i)]=1;
                m--;
            }
        }
    }

    System.out.println(sum);
}
}

import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class A316 {
	static final double EPS = 1e-10;
	static final double INF = 1 << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		input = br.readLine();
		int ans =1;
		int[] count = new int [26];
		//if (input.charAt(0)=='0')
		int zeros=0;
		for (int i=0; i<input.length(); i++){
			char c =input.charAt(i);
			if (c=='?') zeros++;
			else if ('A'<=c && c<='Z') count[c-'A']=1;
		}
		int s=0;
		for (int i=0; i<26; i++)
			if (count[i]==1) s++;
		if ('A'<=input.charAt(0) && 'Z'>=input.charAt(0)) {
			ans =9;
			for (int i=1; i<s; i++) ans*=10-i;
		}else {
			for (int i=1; i<=s; i++) ans*=11-i;
		}
		sb.append(ans);
		for (int i=0; i<zeros; i++) sb.append('0');
		ln(sb);
	}

	public static void main(String[] args) throws IOException {
		new A316().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
}

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;

public class Main {

    // system
    public static String charset = "UTF-8";
    public static Locale locale = new Locale("en", "US");
    public static PrintWriter stdOut, fileOut;
    public static Scanner stdIn, fileIn;

    // A
    public static void main(String[] args) {
        setIO(null, null);
        Scanner input = stdIn;
        PrintWriter output = stdOut;

        String s = input.next();
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        for (char c = 'A'; c <= 'J'; c++) {
            map.put(c, 0);
        }
        int q = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '?') q++;
            else if (c >= 'A' && c <= 'J') {
                map.put(c, map.get(c) + 1);
            }
        }
        char first = s.charAt(0);
        double total = 1;
        if (first == '?') {
            total *= 9;
            q--;
        }
        if (q != 0) {
            for (int i = 0; i < q; i++) {
                total *= 10;
            }
        }
        int count = 10;
        if (first >= 'A' && first <= 'J') {
            total *= 9;
            count = 9;
            map.put(first, 0);
        }
        for (char c = 'A'; c <= 'J'; c++) {
            if (map.get(c) > 0) {
                total *= count;
                count--;
            }
        }

        output.println(String.format("%1$.0f", total));

        input.close();
        output.close();
    }

    // system
    public static void setIO(String fileInName, String fileOutName) {
        // Standard input
        stdIn = new Scanner(new BufferedInputStream(System.in), charset);
        stdIn.useLocale(locale);

        // Standard output
        try {
            stdOut = new PrintWriter(new OutputStreamWriter(System.out, charset), true);
        }
        catch (UnsupportedEncodingException e) {
            System.err.println(e);
        }

        // File input
        if (fileInName != null) {
            try {
                File file = new File(fileInName);
                if (file.exists()) {
                    fileIn = new Scanner(file, charset);
                    fileIn.useLocale(locale);
                }
            }
            catch (IOException ioe) {
                System.err.println("Could not open " + fileInName);
            }
        }

        // File output
        if (fileOutName != null) {
            try {
                OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(fileOutName), charset);
                fileOut = new PrintWriter(osw, true);
            }
            catch (IOException e) {
                System.err.println(e);
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class SpecialTask {
	public static void main(String[] args) {
		PrintWriter pw = new PrintWriter(System.out);
	    reader(System.in);
	    String s = n();
	    long res = 1;
	    int[] arr = new int[10];
	    int k = 10;
	    if (s.charAt(0) == '?') {
    		res = 9;
    	}
	    else if (s.charAt(0) >= 'A' && s.charAt(0) <= 'J') {
			arr[s.charAt(0) - 'A']++;
			res = 9;
			k = 9;
    	}
	    for (int i = 1; i < s.length(); i++) {
	    	if (s.charAt(i) == '?') {
	    		res *= 10;
	    	}
	    	else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'J') {
	    		if (arr[s.charAt(i) - 'A'] == 0) {
	    			arr[s.charAt(i) - 'A']++;
	    			res *= k;
	    			k--;
	    		}
	    	}
	    }
	    pw.println(res);
	    pw.close();
	}

	private static BufferedReader br;
	private static StringTokenizer st;

	static void reader(InputStream stream) {
	    try {
	        br = new BufferedReader(new InputStreamReader(stream));
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	}

	static String n() {
	    while (st == null || !st.hasMoreTokens()) {
	        try {
	            st = new StringTokenizer(br.readLine());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	    }
	    return st.nextToken();
	}

	static int nI() {
	    return Integer.parseInt(n());
	}

	static long nL() {
	    return Long.parseLong(n());
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Admin
 */
public class A {
    public static void main(String a[]){
        long x;
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String p=br.readLine();
            boolean cc[]=new boolean[10];
            int q=10;
            //boolean z=true;
            char c=p.charAt(0);
            if(c=='?')x=9;
            else if(Character.isDigit(c))x=1;
            else{
                cc[c-'A']=true;
                q--;
                x=9;
            }
            for (int i = 1; i < p.length(); i++) {
                c=p.charAt(i);
                //System.out.println(p+':'+c);
                if(c=='?')x*=10;
                else if(!Character.isDigit(c)){
                    if(c<'A' || c>'J')break;
                    c-='A';
                    if(!cc[c]){
                        cc[c]=true;
                        x*=q;
                        q--;
                    }
                }
            }
        } catch (IOException ex) {
            x=0;
        }
        System.out.println(x);
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author tino
 */
public class SpecialTask {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String x = input.next();
        boolean bol[] = new boolean[10];
        int s;
        int total = 1;
        if ( x.charAt(0)-48 < 10 || x.charAt(0)=='?'  )
            s = 10;
        else
            s = 9;
        System.out.println((char)'J'+0+" "+s);

        for (int i = 0; i < x.length(); i++) {
            int value = x.charAt(i);
            if (i == 0 && s == 9 ) {
                total = total * 9;
                bol[value-65] = true;
            } else {
                if (65 <= value && 75 >= value && bol[value-65] == false) {
                    bol[value - 65] = true;
                    total = total * s;
                    s--;
                }
                else if (value == '?' && i>0) {
                    total = total * 10;
                }
                else if(value == '?' && i==0)
                    total= total*9;
            }
        }
        System.out.println(total);

    }
    }

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	final static double EPS = 1e-7;
	final static int MOD = 1000000007;

	static void solve() throws Exception {
		String s = next();
		int n = 0;
		Set<Character> used = new HashSet<Character>();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				n++;
			} else if (Character.isLetter(s.charAt(i))) {
				used.add(s.charAt(i));
			}
		}
		long res = 1;
		for (int i = 0; i < used.size(); i++) {
			if (i == 0 && Character.isLetter(s.charAt(0))) {
				res *= 9;
			} else {
				res *= 10-i;
			}
		}
		if (s.charAt(0) == '?') {
			res *= 9;
		}
		out.print(res);
		for (int i = 1; i < n; i++) {
			out.print("0");
		}
		out.println();
	}

	static int sqr(int x) {
		return x*x;
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static BigInteger nextBigInteger() throws IOException {
		return new BigInteger(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static String nextLine() throws IOException {
		tok = new StringTokenizer("");
		return in.readLine();
	}

	static boolean hasNext() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null) {
				return false;
			}
			tok = new StringTokenizer(s);
		}
		return true;
	}

	public static void main(String args[]) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			//in = new BufferedReader(new FileReader("input.in"));
			//out = new PrintWriter(new FileWriter("output.out"));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			java.lang.System.exit(1);
		}
	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        String [] sp;
        String s = br.readLine();
        int a = 0;
        boolean f = false;
        int c = 0;
        boolean [] v = new boolean [26];
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '?'){
                c++;
            }else if(s.charAt(i) - 'A' >=0 && s.charAt(i) - 'A' < 26 && !v[s.charAt(i) - 'A']){
                a++;
                v[s.charAt(i) - 'A'] = true;
                if(i == 0)
                    f = true;
            }
        }
        BigInteger ans = new BigInteger(10 + "");
        ans = ans.pow(c);
        int r = 1;
        if(f){
            for (int i = 0; i < a -1 ; i++) {
                r *= (9 - i);
            }
            r *= 9;

        }else{
            for (int i = 0; i < a; i++) {
                r *= (10 - i);
            }

        }
        ans = ans.multiply(new BigInteger(r + ""));
        System.out.println(ans);
    }

}

import java.io.*;
import java.util.*;
public class a316
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
        //System.out.println("Enter");
        String s=in.readLine();
        int i,j=1,pro=1,k=0,num=10;
        int A[]=new int[10];
        if(s.charAt(0)=='?' || Character.isLetter(s.charAt(0))==true)
            {
                j=9;
                if(Character.isLetter(s.charAt(0))==true)
               {
                  A[(int)s.charAt(0)-65]=9;
                   k++;
                }
            }
        for(i=1;i<s.length();i++)
        {
            if( Character.isLetter(s.charAt(i))==true)
            {
                if(A[(int)s.charAt(i)-65]==0)
               {
                   A[(int)s.charAt(i)-65]=num-k;
                   k++;
                }
            }
            if(s.charAt(i)=='?')
            pro*=10;
        }
        for(i=0;i<10;i++)
        {
           // System.out.println(A[i]);
            if(A[i]!=0)
            pro*=A[i];
        }
        System.out.println(pro);
    }
}

import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class A implements Runnable {

    public void solve() throws IOException {
        char[] ch = in.nextLine().toCharArray();
        BigInteger r = BigInteger.ONE;
        boolean[] was = new boolean['J' - 'A' + 1];
        int lCount = 0;
        for ( char c : ch ) {
            if ( c == '?' ) {
                r = r.multiply(BigInteger.TEN);
            } else if ( c >= 'A' && c <= 'J' ) {
                if ( !was[c - 'A'] ) {
                    was[c - 'A'] = true;
                    lCount ++;
                }
            }
        }
        for ( int i = 10; i > 10 - lCount; i -- ) {
            if ( i == 10 && ch[0] >= 'A' && ch[0] <= 'J' ) {
                r = r.multiply( BigInteger.valueOf( 9 ) );
            } else {
                r = r.multiply( BigInteger.valueOf( i ) );
            }
        }
        out.println( r );
    }

    public Scanner in;

    public PrintWriter out;

    A() throws IOException {
        in = new Scanner(System.in);
        // in = new StreamTokenizer( new InputStreamReader( System.in ) );
        out = new PrintWriter(System.out);
    }

//    int nextInt() throws IOException {
//        in.nextToken();
//        return ( int ) in.nval;
//    }

    void check(boolean f, String msg) {
        if (!f) {
            out.close();
            throw new RuntimeException(msg);
        }
    }

    void close() throws IOException {
        out.close();
    }

    public void run() {
        try {
            solve();
            close();
        } catch (Exception e) {
            e.printStackTrace(out);
            out.flush();
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) throws IOException {
        new Thread(new A()).start();
    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

    public static void main(String[] args)
    {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run()
    {
        try
        {
            //in = new Scanner(new File("INPUT.TXT")); out = new PrintWriter(new File("OUTPUT.TXT"));
            in = new Scanner(System.in); out = new PrintWriter(System.out);
            solve();
            out.flush();
        }catch (Throwable e)
        {

        }
    }

    BigInteger BI(long a)
    {
        return BigInteger.valueOf(a);
    }

    void solve()
    {
    String s = in.next();
        boolean mas[]=new boolean[256];
        BigInteger answ = BI(1);
        int cnt = 0,k=0;
        boolean nine=false;
        for(int i=0; i<s.length(); ++i)
        {
            if(s.charAt(i) == '?')
                ++k;
            if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z' && !mas[s.charAt(i)])
            {
                mas[s.charAt(i)]=true;
                if(i==0)
                    nine=true;
                else
                    ++cnt;
            }
        }
        if(nine)
        {
            answ = BI(9);
            for(int i=9; i>9-cnt; --i)
                answ = answ.multiply(BI(i));
        }
        else
            for(int i=10; i>10-cnt; --i)
                answ = answ.multiply(BI(i));
        answ = answ.multiply(BI(10).pow(k));
        out.println(answ);
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashSet;

public class A {

	public static void main(String[] args)throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		char s[]=reader.readLine().toCharArray();
		int count=10;
//		long ret=1;

		BigInteger []big=new BigInteger[11];
		for(int i=0;i<big.length;i++)
			big[i]=new BigInteger(i+"");

		boolean v[]=new boolean [11];
		int num1=0;
		int num2=0;
		long l=10;
		for(int i=0;i<s.length;i++)
		{
			if(s[i]=='?')
				num1++;
			else if(s[i]>='A' &&s[i]<='J')
			{
				if(!v[s[i]-'A'])
				{
					num2++;
					v[s[i]-'A']=true;
				}
			}
		}

		BigInteger n1=big[1];
		count =9;
		if(s[0]=='?')
		{
//			ret=9;
//			ret=big[9];
//			count=10;
			num1--;
			n1=big[9];
		}
		else if(s[0]>='A' && s[0]<='J')
		{
//			ret=9;
//			ret=big[9];
			count=9;
//			v[s[0]-'A']=true;
//			n1=big[9];
			l=9;

		}
		num2--;
		StringBuilder b=new StringBuilder("1");
		for(int i=0;i<num1;i++)
			b.append("0");
//n1=n1.multiply(big[10].pow(num1));
		n1=n1.multiply(new BigInteger(b.toString()));
//System.out.println(num2);
for(int i=0;i<num2;i++)
{
	l*=count--;
}
		n1=n1.multiply(new BigInteger(l+""));

		System.out.println(n1);
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class A {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	void solve() throws Exception {
		String s = next();
		int cnt[] = new int[10];
		int zc = 0;
		// BigInteger ans = BigInteger.ONE;

		for (int i = 0; i < s.length(); i++) {
			if (Character.isAlphabetic(s.charAt(i)))
				cnt[s.charAt(i) - 'A']++;
			if (s.charAt(i) == '?')
				zc++;
		}

		int dc = 0;
		for (int i = 0; i < 10; i++) {
			if (cnt[i] > 0)
				dc++;
		}

		int ans = 10;
		if (Character.isAlphabetic(s.charAt(0))) {
			ans--;
			for (int i = 1; i < dc; i++)
				ans *= 10 - i;
		}
		if (Character.isDigit(s.charAt(0))) {
			ans = 1;
			for (int i = 0; i < dc; i++)
				ans *= 10 - i;
		}
		if (s.charAt(0) == '?') {
			ans *= 9;
			zc--;
		}
		out.print(ans);
		for (int i = 0; i < zc; i++)
			out.print(0);
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new A().run();
	}

}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static void main(String [] args ) {
		try{
			String str;
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			BufferedOutputStream bos = new BufferedOutputStream(System.out);
			String eol = System.getProperty("line.separator");
			byte [] eolb = eol.getBytes();

			str  = br.readLine();
			int numQ = 0;
			int [] numL = new int[10];
			for(int i = 0 ; i < 10 ; i++) {
				numL[i] = 0;
			}
			for(int i = 1 ; i < str.length() ; i++) {
				char c = str.charAt(i);
				if(c=='?') {
					numQ++;
				} else {
					int x = Character.getNumericValue(c);
					if((x>=10)&&(x<35)) {
						numL[x-10] ++;
					}
				}
			}
			BigInteger ans = new BigInteger("1");
			BigInteger ten = new BigInteger("10");
			char c = str.charAt(0);
			if(c=='?') {
				numQ++;
			}
			int sp = 0;
			int x = Character.getNumericValue(c);
			if((x>=10)&&(x<35)) {
				sp = x-10;
				int numDiff =  0;
				for(int i = 0 ; i < 10 ; i++) {
					if(i!=sp) {
						if(numL[i]>0) {
							numDiff++;
						}
					}
				}
				ans = ans.multiply(new BigInteger("9"));
				int iter = 9;
				while(numDiff>0) {
					ans = ans.multiply(new BigInteger(new Integer(iter).toString()));
					iter--;
					numDiff--;
				}
			} else {
				int numDiff =  0;
				for(int i = 0 ; i < 10 ; i++) {
					if(numL[i]>0) {
						numDiff++;
					}
				}
				int iter = 10;
				while(numDiff>0) {
					ans = ans.multiply(new BigInteger(new Integer(iter).toString()));
					iter--;
					numDiff--;
				}
			}
			for(int i = 0 ; i < numQ ; i++) {
				ans = ans.multiply(ten);
			}
			bos.write(ans.toString().getBytes());
			bos.write(eolb);
			bos.flush();
		}  catch(IOException ioe) {
			ioe.printStackTrace();
		}
	}
}

import java.util.Scanner;

public class S {
public static void main(String[] args) {
    Scanner in =new Scanner (System.in);
    String a=in.next();
    int sum=1;
    int m=10;
    char[] ar=new char[100];

    for(int i=0;i<a.length();i++){

        if((int)a.charAt(i)>=48&&(int)a.charAt(i)<=57)
            sum*=1;
        if(a.charAt(i)=='?'){
            if(i==0)
                sum*=9;
            else;
            sum*=10;
        }
        if((int)a.charAt(i)>=65&&(int)a.charAt(i)<=90&&ar[(int)a.charAt(i)]==0){
            if(i==0){
                sum*=9;
                m--;
                ar[(int)a.charAt(i)]=1;
            }
            else{
                sum*=m;
                ar[(int)a.charAt(i)]=1;
                m--;
            }
        }
    }

    System.out.println(sum);
}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;

public class ABBYYCupTemp {

    public static void main(String args[]) throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        ArrayList<Long> arrayWhat = new ArrayList<>();
        BigInteger bIntWhatMain = BigInteger.ONE;
        BigInteger bIntWhatDegreeMain = BigInteger.valueOf(10);
        BigInteger bIntWhatSupport = BigInteger.valueOf(1000000000).multiply(BigInteger.valueOf(1000000000).multiply(BigInteger.valueOf(1000000000)));

        String stringMain = bf.readLine();
        String stringWhatList = new String();

        int numberWhat = 0;
        int numberCombinationLetter = 1;

        ArrayList<String> arrayLetter = new ArrayList<>();

        for(int i=0; i<stringMain.length(); i++){

            if(!Character.isDigit(stringMain.charAt(i))){

                if(arrayLetter.size()==10){
                    for(; i<stringMain.length(); i++)
                        if(Character.toString(stringMain.charAt(i)).equals("?")){

                            numberWhat++;
                            if(numberWhat==20){
                                stringWhatList += "00000000000000000000";
                                numberWhat=0;
                            }

                        }
                    break;
                }
                else {
                    if(Character.toString(stringMain.charAt(i)).equals("?")){

                        numberWhat++;
                        if(numberWhat==20){
                            stringWhatList += "00000000000000000000";
                            numberWhat=0;
                        }

                    }
                    else
                        if(!arrayLetter.contains(Character.toString(stringMain.charAt(i))))
                            arrayLetter.add(Character.toString(stringMain.charAt(i)));
                }

            }

        }

        if(numberWhat!=0){

            String stringWhatListTemp;

            if(Character.toString(stringMain.charAt(0)).equals("?"))
                stringWhatListTemp = bIntWhatDegreeMain.pow(numberWhat-1).toString();
            else
                stringWhatListTemp = bIntWhatDegreeMain.pow(numberWhat).toString();

            stringWhatList += stringWhatListTemp.substring(1, stringWhatListTemp.length());
        }

        if(Character.toString(stringMain.charAt(0)).equals("?")){

            for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                numberCombinationLetter = numberCombinationLetter*tempBase;

            numberCombinationLetter *= 9;
            //numberWhat--;

            /*String temp;
            if(numberWhat==0)
                System.out.print(numberCombinationLetter);
            else{
                temp = bIntWhatDegreeMain.pow(numberWhat).toString();
                System.out.print(numberCombinationLetter + "" + temp.substring(1, temp.length()));
            } */
            System.out.print(numberCombinationLetter + "" + stringWhatList);

        }
        else {

            if(!Character.isDigit(stringMain.charAt(0))) {

                numberCombinationLetter = 9;

                for(int j=1, tempBase=9; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

            }
            else
                for(int j=0, tempBase=10; j<arrayLetter.size(); j++, tempBase--)
                    numberCombinationLetter = numberCombinationLetter*tempBase;

            //String temp = bIntWhatDegreeMain.pow(numberWhat).toString();

            if(numberCombinationLetter==1)
                System.out.print(stringWhatList);
            else
                if(numberWhat==0)
                    System.out.print(numberCombinationLetter);
                else
                    System.out.print(numberCombinationLetter + "" + stringWhatList);

        }

    }

}

import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner cin = new Scanner (new BufferedInputStream(System.in));
    String s;
    s=cin.next();
    int l;
    l=s.length();
    BigInteger ans;
	int a=0,b=0;
	int p[]=new int [300];
	for(int i=0;i<300;i++)
		p[i]=0;
    if(s.charAt(0)=='0')ans=BigInteger.valueOf(0);
    else if(s.charAt(0)>='1'&&s.charAt(0)<='9')
    {
    	for(int i=1;i<l;i++)
    	{
    		if(s.charAt(i)=='?')a++;
    		if(s.charAt(i)>='A'&&s.charAt(i)<='Z')p[s.charAt(i)]=1;
    	}
    	for(int i=0;i<300;i++)
    		if(p[i]!=0)b++;
    	ans=BigInteger.valueOf(1);
    	for(int i=0;i<b;i++)
    		ans=ans.multiply(BigInteger.valueOf(10-i));
    }
    else if(s.charAt(0)=='?')
    {
    	for(int i=1;i<l;i++)
    	{
    		if(s.charAt(i)=='?')a++;
    		if(s.charAt(i)>='A'&&s.charAt(i)<='Z')p[s.charAt(i)]=1;
    	}
    	for(int i=0;i<300;i++)
    		if(p[i]!=0)b++;
    	ans=BigInteger.valueOf(1);
    	for(int i=0;i<b;i++)
    		ans=ans.multiply(BigInteger.valueOf(10-i));
    	ans=ans.multiply(BigInteger.valueOf(9));
    }
    else
    {
    	for(int i=1;i<l;i++)
    	{
    		if(s.charAt(i)=='?')a++;
    		if(s.charAt(i)>='A'&&s.charAt(i)<='Z')p[s.charAt(i)]=1;
    	}
    	for(int i=0;i<300;i++)
    		if(p[i]!=0)b++;
    	ans=BigInteger.valueOf(1);
    	for(int i=0;i<b;i++)
    		ans=ans.multiply(BigInteger.valueOf(9-i));
    	ans=ans.multiply(BigInteger.valueOf(9));
    }
    System.out.printf("%s",ans.toString());
    for(int i=0;i<a;i++)
    	System.out.printf("0");
  }
}

import java.io.*;
import java.lang.*;
import java.util.*;
import java.text.*;

public class Main {

	public static void main(String[] args) throws IOException {

		//BufferedReader cin = new BufferedReader(new FileReader("test.txt"));
		 BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));

		String line = cin.readLine();
		int cq=0;//count question marks
		int[] cl=new int[10];//count letters
		Arrays.fill(cl,0);
		char t;
		char first=line.charAt(0);
		for(int i=0;i<line.length();i++){
			 t=line.charAt(i);
			 if(t=='?') cq++;
			 else if(t>64) cl[t-65]++;
		}
		int cll=0;//count distinct letters
		for(int i=0;i<10;i++)
			if(cl[i]>0)cll++;

		int ans;
		if(first=='?')
			ans=9*(int)Math.pow(10, cq-1)*(fac(10)/fac(cll)/fac(10-cll));
		else if(first>64)//letter
			ans=(int)Math.pow(10, cq)*9*(fac(9)/fac(cll-1)/fac(10-cll));
		else
			ans=(int)Math.pow(10, cq)*(fac(10)/fac(cll)/fac(10-cll));

		System.out.println(ans);

		cin.close();
	}

	public static int fac(int a){
		if(a==0)return 1;
		else return a*fac(a-1);
	}
}