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

public class P1575D {
    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.nextToken().toCharArray();
        int ans = 0;

        if (s.length == 1) {
            if (s[0] == '0' || s[0] == '_' || s[0] == 'X') {
                ans = 1;
            }
        } else {
            int n = s.length;
            if (!(s[n - 1] == 'X' && s[n - 2] == 'X')) {
                // put 25
                if (canPut(s, n - 1, '5') && canPut(s, n - 2, '2')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '5');
                    put(s1, n - 2, '2');
                    ans += possible(s1);
                }
                // put 50
                if (canPut(s, n - 1, '0') && canPut(s, n - 2, '5')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '0');
                    put(s1, n - 2, '5');
                    ans += possible(s1);
                }
                // put 75
                if (canPut(s, n - 1, '5') && canPut(s, n - 2, '7')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '5');
                    put(s1, n - 2, '7');
                    ans += possible(s1);
                }
            }
            // put 00
            if (s[n - 1] == 'X' && s[n - 2] == 'X') {
                char[] s1 = Arrays.copyOf(s, n);
                put(s1, n - 1, '0');
                ans += possible(s1);
            } else if (canPut(s, n - 1, '0') && canPut(s, n - 2, '0')) {
                char[] s1 = Arrays.copyOf(s, n);
                put(s1, n - 1, '0');
                put(s1, n - 2, '0');
                ans += possible(s1);
            }
        }
        writer.println(ans);

        writer.flush();
    }

    private static boolean canPut(char[] s, int p, char d) {
        if (s[p] == 'X' || s[p] == '_') {
            return true;
        }
        return s[p] == d;
    }

    private static void put(char[] s, int p, char d) {
        if (s[p] == 'X') {
            replace(s, d);
        } else {
            s[p] = d;
        }
    }

    private static void replace(char[] s, char d) {
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'X') {
                s[i] = d;
            }
        }
    }

    private static int possible(char[] s) {
        int p = 1;

        if (s[0] == '0') {
            return 0;
        }
        if (s[0] == '_') {
            p *= 9;
        } else if (s[0] == 'X') {
            p *= 9;
            replace(s, '1');
        }
        for (int i = 1; i < s.length; i++) {
            if (s[i] == '_') {
                p *= 10;
            } else if (s[i] == 'X') {
                p *= 10;
                replace(s, '1');
            }
        }

        return p;
    }

    private static class MyScanner {
        private BufferedReader reader;
        private StringTokenizer st;

        public MyScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

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

import java.util.*;

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

/**
 * @author Naitik
 *
 */
public class Main

{
	 static FastReader sc=new FastReader();
	 static long dp[][][];
	 //static int v[][];
	 static int mod=998244353;;
//	 static int mod=1000000007;
	 static long max;
	 static long bit[];
	 static long bit1[];
//	 static long seg[];
	 //static long fact[];
//	 static long A[];
	// static TreeMap<Integer,Integer> map;
	 //static StringBuffer sb=new StringBuffer("");
	 static HashMap<Integer,Integer> map;
	   static PrintWriter out=new PrintWriter(System.out);
	  public static void main(String[] args)
{

		 //  StringBuffer sb=new StringBuffer("");
		  int ttt=1;
		     // ttt =i();
	        outer :while (ttt-- > 0)
			{
	        	char A[]=s().toCharArray();
	        	if(A.length==1 && A[0]=='0') {
	        		System.out.println("1");
	        		return;
	        	}
	        	if(A[0]=='0') {
	        		System.out.println("0");
	        		return;
	        	}
	        	if(A.length==1) {
	        		if(A[0]=='X' || A[0]=='_') {
	        			System.out.println("1");
	        			return;
	        		}
	        	}
	        	dp=new long[A.length+1][25][11];
	        	fill(dp);
	        	System.out.println(go(A, 0, 0, 10));

	        }
	        //System.out.println(sb.toString());
		     out.close();

	    //CHECK FOR N=1                    //CHECK FOR M=0
        //CHECK FOR N=1                    //CHECK FOR M=0
       	//CHECK FOR N=1

    }
	  static long go(char A[],int i,int pv,int v) {
		  if(i==A.length) {
			  if(pv==0)
				  return 1;
			  return 0;
		  }
		  if(dp[i][pv][v]!=-1)
			  return dp[i][pv][v];
		  long ans=0;
		  if(A[i]=='_') {
			  for(int j=0;j<10;j++) {
				  if(i==0 && j==0)
					  continue;
				  int y=pv*10+j;
				  y%=25;
				  ans+=go(A, i+1, y, v);
			  }
		  }
		  else if(A[i]=='X') {
			  if(v!=10) {
				  ans+=go(A, i+1, (pv*10+v)%25, v);
			  }
			  else {
				  for(int j=0;j<10;j++) {
					  if(i==0 && j==0)
						  continue;
					  int y=pv*10+j;
					  y%=25;
					  ans+=go(A, i+1, y, j);
				  }
			  }
		  }
		  else {
			  ans+=go(A, i+1, (pv*10+A[i]-'0')%25, v);
		  }
		  return dp[i][pv][v]=ans;
	  }

static class Pair implements Comparable<Pair>
     {
    	 int x;
    	 int y;
    	 int z;
    	 Pair(int x,int y){
    		 this.x=x;
    		 this.y=y;
    		// this.z=z;

    	 }
		@Override
		public int compareTo(Pair o) {
			if(this.x>o.x)
				return +1;
			else if(this.x<o.x)
				return -1;
			else {
				if(this.y>o.y)
					return 1;
				else if(this.y<o.y)
					return -1;
				else
					return 0;
			}
		}
//		public int hashCode()
//		{
//			final int temp = 14;
//			int ans = 1;
//			ans =x*31+y*13;
//			return ans;
//		}
//		@Override
//		public boolean equals(Object o)
//		{
//			if (this == o) {
//				return true;
//			}
//			if (o == null) {
//				return false;
//			}
//			if (this.getClass() != o.getClass()) {
//				return false;
//			}
//			Pair other = (Pair)o;
//			if (this.x != other.x || this.y!=other.y) {
//				return false;
//			}
//			return true;
//		}
//
		/* FOR TREE MAP PAIR USE */

//		public int compareTo(Pair o) {
// 			if (x > o.x) {
// 				return 1;
// 			}
// 			if (x < o.x) {
// 				return -1;
// 			}
// 			if (y > o.y) {
// 				return 1;
// 			}
// 			if (y < o.y) {
// 				return -1;
// 			}
// 			return 0;
// 		}

     }

//static int find(int A[],int a) {
//	  if(A[a]<0)
//		  return a;
//	  return A[a]=find(A, A[a]);
//}
static int find(int A[],int a) {
	  if(A[a]==a)
		  return a;
	  return A[a]=find(A, A[a]);
}
//FENWICK TREE
static void update(int i, int x){
	for(; i < bit.length; i += (i&-i))
		bit[i] += x;
}

static int sum(int i){
	int ans = 0;
	for(; i > 0; i -= (i&-i))
		ans += bit[i];
	return ans;
}
static void update1(int i, long x){
	for(; i < bit1.length; i += (i&-i))
		bit1[i] += x;
}

static int sum1(int i){
	int ans = 0;
	for(; i > 0; i -= (i&-i))
		ans += bit1[i];
	return ans;
}
//END
static void add(int v) {
	if(!map.containsKey(v)) {
		map.put(v, 1);
	}
	else {
		map.put(v, map.get(v)+1);
	}
}
static void remove(int v) {
	if(map.containsKey(v)) {
		map.put(v, map.get(v)-1);
		if(map.get(v)==0)
			map.remove(v);
	}
}
public static int upper(int A[],int k,int si,int ei)
{
	int l=si;
	int u=ei;
	int ans=-1;
	while(l<=u) {
		int mid=(l+u)/2;
		if(A[mid]<=k) {
			ans=mid;
			l=mid+1;
		}
		else {
			u=mid-1;
		}
	}
	return ans;
}
public static int lower(int A[],int k,int si,int ei)
{
	int l=si;
	int u=ei;
	int ans=-1;
	while(l<=u) {
		int mid=(l+u)/2;
		if(A[mid]<=k) {
			l=mid+1;
		}
		else {
			ans=mid;
			u=mid-1;
		}
	}
	return ans;

}
static int[] copy(int A[]) {
	int B[]=new int[A.length];
	for(int i=0;i<A.length;i++) {
		B[i]=A[i];
	}
	return B;
}
static long[] copy(long A[]) {
	long B[]=new long[A.length];
	for(int i=0;i<A.length;i++) {
		B[i]=A[i];
	}
	return B;
}
static int[] input(int n) {
	int A[]=new int[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextInt();
	   }
	   return A;
   }
static long[] inputL(int n) {
	long A[]=new long[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextLong();
	   }
	   return A;
   }
static String[] inputS(int n) {
	String A[]=new String[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.next();
	   }
	   return A;
   }
static long sum(int A[]) {
	long sum=0;
	for(int i : A) {
		sum+=i;
	}
	return sum;
}
static long sum(long A[]) {
	long sum=0;
	for(long i : A) {
		sum+=i;
	}
	return sum;
}
static void reverse(long A[]) {
	int n=A.length;
	long B[]=new long[n];
	for(int i=0;i<n;i++) {
		B[i]=A[n-i-1];
	}
	for(int i=0;i<n;i++)
		A[i]=B[i];

}
static void reverse(int A[]) {
	int n=A.length;
	int B[]=new int[n];
	for(int i=0;i<n;i++) {
		B[i]=A[n-i-1];
	}
	for(int i=0;i<n;i++)
		A[i]=B[i];

}
static void input(int A[],int B[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
		   B[i]=sc.nextInt();
	   }
}
static int[][] input(int n,int m){
	int A[][]=new int[n][m];
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			A[i][j]=i();
		}
	}
	return A;
}
static char[][] charinput(int n,int m){
	char A[][]=new char[n][m];
	for(int i=0;i<n;i++) {
		String s=s();
		for(int j=0;j<m;j++) {
			A[i][j]=s.charAt(j);
		}
	}
	return A;
}

static int max(int A[]) {
	int max=Integer.MIN_VALUE;
	for(int i=0;i<A.length;i++) {
		max=Math.max(max, A[i]);
	}
	return max;
}
static int min(int A[]) {
	int min=Integer.MAX_VALUE;
	for(int i=0;i<A.length;i++) {
		min=Math.min(min, A[i]);
	}
	return min;
}
static long max(long A[]) {
	long max=Long.MIN_VALUE;
	for(int i=0;i<A.length;i++) {
		max=Math.max(max, A[i]);
	}
	return max;
}
static long min(long A[]) {
	long min=Long.MAX_VALUE;
	for(int i=0;i<A.length;i++) {
		min=Math.min(min, A[i]);
	}
	return min;
}
static long [] prefix(long A[]) {
	long p[]=new long[A.length];
	p[0]=A[0];
	for(int i=1;i<A.length;i++)
		p[i]=p[i-1]+A[i];
	return p;
}
static long [] prefix(int A[]) {
	long p[]=new long[A.length];
	p[0]=A[0];
	for(int i=1;i<A.length;i++)
		p[i]=p[i-1]+A[i];
	return p;
}
static long [] suffix(long A[]) {
	long p[]=new long[A.length];
	p[A.length-1]=A[A.length-1];
	for(int i=A.length-2;i>=0;i--)
		p[i]=p[i+1]+A[i];
	return p;
}
static long [] suffix(int A[]) {
	long p[]=new long[A.length];
	p[A.length-1]=A[A.length-1];
	for(int i=A.length-2;i>=0;i--)
		p[i]=p[i+1]+A[i];
	return p;
}
static void fill(int dp[]) {
	Arrays.fill(dp, -1);
}
static void fill(int dp[][]) {
	for(int i=0;i<dp.length;i++)
	Arrays.fill(dp[i], -1);
}
static void fill(int dp[][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			Arrays.fill(dp[i][j],-1);
		}
	}
}
static void fill(int dp[][][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			for(int k=0;k<dp[0][0].length;k++) {
			Arrays.fill(dp[i][j][k],-1);
			}
		}
	}
}
static void fill(long dp[]) {
	Arrays.fill(dp, -1);
}
static void fill(long dp[][]) {
	for(int i=0;i<dp.length;i++)
	Arrays.fill(dp[i], -1);
}
static void fill(long dp[][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			Arrays.fill(dp[i][j],-1);
		}
	}
}
static void fill(long dp[][][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			for(int k=0;k<dp[0][0].length;k++) {
			Arrays.fill(dp[i][j][k],-1);
			}
		}
	}
}
static int min(int a,int b) {
	return Math.min(a, b);
}
static int min(int a,int b,int c) {
	return Math.min(a, Math.min(b, c));
}
static int min(int a,int b,int c,int d) {
	return Math.min(a, Math.min(b, Math.min(c, d)));
}
static int max(int a,int b) {
	return Math.max(a, b);
}
static int max(int a,int b,int c) {
	return Math.max(a, Math.max(b, c));
}
static int max(int a,int b,int c,int d) {
	return Math.max(a, Math.max(b, Math.max(c, d)));
}
static long min(long a,long b) {
	return Math.min(a, b);
}
static long min(long a,long b,long c) {
	return Math.min(a, Math.min(b, c));
}
static long min(long a,long b,long c,long d) {
	return Math.min(a, Math.min(b, Math.min(c, d)));
}
static long max(long a,long b) {
	return Math.max(a, b);
}
static long max(long a,long b,long c) {
	return Math.max(a, Math.max(b, c));
}
static long max(long a,long b,long c,long d) {
	return Math.max(a, Math.max(b, Math.max(c, d)));
}

static long power(long x, long y, long p)
{

	if(y==0)
		return 1;
	if(x==0)
		return 0;
    long res = 1;
    x = x % p;

    while (y > 0) {

        if (y % 2 == 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
static long power(long x, long y)
{

	if(y==0)
		return 1;
	if(x==0)
		return 0;
    long res = 1;

    while (y > 0) {

        if (y % 2 == 1)
            res = (res * x);

        y = y >> 1;
        x = (x * x);
    }

    return res;
}
static void print(int A[]) {
	for(int i : A) {
		System.out.print(i+" ");
	}
	System.out.println();
}
static void print(long A[]) {
	for(long i : A) {
		System.out.print(i+" ");
	}
	System.out.println();
}
static long mod(long x) {
	  return ((x%mod + mod)%mod);
}
static String reverse(String s) {
	StringBuffer p=new StringBuffer(s);
	p.reverse();
	return p.toString();
}

     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }
     static void sort(int[] A){
        int n = A.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = A[i];
            int randomPos = i + rnd.nextInt(n-i);
            A[i] = A[randomPos];
            A[randomPos] = tmp;
        }
        Arrays.sort(A);
     }
     static void sort(long[] A){
	        int n = A.length;
	        Random rnd = new Random();
	        for(int i=0; i<n; ++i){
	            long tmp = A[i];
	            int randomPos = i + rnd.nextInt(n-i);
	            A[i] = A[randomPos];
	            A[randomPos] = tmp;
	        }
	        Arrays.sort(A);
	     }
  static String sort(String s) {
 	 Character ch[]=new Character[s.length()];
 	 for(int i=0;i<s.length();i++) {
 		 ch[i]=s.charAt(i);
 	 }
 	 Arrays.sort(ch);
 	 StringBuffer st=new StringBuffer("");
 	 for(int i=0;i<s.length();i++) {
 		 st.append(ch[i]);
 	 }
 	 return st.toString();
  }
  static HashMap<Integer,Integer> hash(int A[]){
	  HashMap<Integer,Integer> map=new HashMap<Integer, Integer>();
	  for(int i : A) {
		  if(map.containsKey(i)) {
			  map.put(i, map.get(i)+1);
		  }
		  else {
			  map.put(i, 1);
		  }
	  }
	  return map;
  }
  static TreeMap<Integer,Integer> tree(int A[]){
	  TreeMap<Integer,Integer> map=new TreeMap<Integer, Integer>();
	  for(int i : A) {
		  if(map.containsKey(i)) {
			  map.put(i, map.get(i)+1);
		  }
		  else {
			  map.put(i, 1);
		  }
	  }
	  return map;
  }
     static boolean prime(int n)
	    {
	        if (n <= 1)
	            return false;
	        if (n <= 3)
	            return true;
	        if (n % 2 == 0 || n % 3 == 0)
	            return false;
	        double sq=Math.sqrt(n);

	        for (int i = 5; i <= sq; i = i + 6)
	            if (n % i == 0 || n % (i + 2) == 0)
	                return false;
	        return true;
	    }
     static boolean prime(long n)
	    {
	        if (n <= 1)
	            return false;
	        if (n <= 3)
	            return true;
	        if (n % 2 == 0 || n % 3 == 0)
	            return false;
	        double sq=Math.sqrt(n);

	        for (int i = 5; i <= sq; i = i + 6)
	            if (n % i == 0 || n % (i + 2) == 0)
	                return false;
	        return true;
	    }
     static int gcd(int a, int b)
     {
         if (a == 0)
             return b;
         return gcd(b % a, a);
     }
     static long gcd(long a, long b)
     {
         if (a == 0)
             return b;
         return gcd(b % a, a);
     }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                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());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

public class E {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int l = s.length();

        if(l < 2){
            if(s.equals("0") || s.equals("_") || s.equals("X")){
                System.out.println(1);
            }
            else{
                System.out.println(0);
            }
            System.exit(0);
        }
        else if(l == 2){
            int count = 0;
            for(int i=10;i<=95;i+=5){
                if(i%25 != 0)
                    continue;
                String str = Integer.toString(i);

                if('0'<=s.charAt(0) && s.charAt(0)<='9'){
                    if('0'<=s.charAt(1) && s.charAt(1)<='9'){
                        if(s.equals(str)){
                            count++;
                        }
                    }
                    else {
                        if(s.charAt(0)==str.charAt(0))
                            count++;
                    }
                }
                else if(s.charAt(0)=='_'){
                    if('0'<=s.charAt(1) && s.charAt(1)<='9'){
                        if(s.charAt(1)==str.charAt(1)){
                            count++;
                        }
                    }
                    else {
                        count++;
                    }
                }
                else{
                    if('0'<=s.charAt(1) && s.charAt(1)<='9'){
                        if(s.charAt(1)==str.charAt(1)){
                            count++;
                        }
                    }
                    else if(s.charAt(1)=='_'){
                        count++;
                    }
                }
            }

            System.out.println(count);
            System.exit(0);
        }
        else{
            int start = (int) (Math.pow(10, l-1));
            int end = (int) (Math.pow(10, l));

            int count = 0;
            for(int i=start;i<end;i+=25){
                String str = Integer.toString(i);

                Set<Character> set = new HashSet<>();
                boolean flag = true;
                for(int j=0;j<l;j++){
                    if(s.charAt(j)=='_')
                        continue;
                    else if(s.charAt(j)=='X'){
                        set.add(str.charAt(j));
                    }
                    else if(s.charAt(j)!=str.charAt(j)){
                        flag = false;
                        break;
                    }
                }

                if(flag && set.size() < 2){
                    count++;
                }
            }

            System.out.println(count);
        }

        /*int dash = 0, x = 0;
        for(int i=0;i<l;i++){
            if(s.charAt(i)=='X')
                x++;
            else if(s.charAt(i)=='_')
                dash++;
        }

        if((s.charAt(l-2)=='0' && s.charAt(l-1)=='0') || (s.charAt(l-2)=='2' && s.charAt(l-1)=='5') || (s.charAt(l-2)=='5' && s.charAt(l-1)=='0') || (s.charAt(l-2)=='7' && s.charAt(l-1)=='5')){
            if(s.charAt(0)=='_'){
                int ans = (int) (9 * Math.pow(10, dash - 1));
                if(x > 0)
                    ans *= 10;

                System.out.println(ans);
            }
            else if(s.charAt(0)=='X'){
                int ans = (int) (Math.pow(10, dash));
                ans *= 9;

                System.out.println(ans);
            }
            else{
                int ans = (int) Math.pow(10, dash);
                if(x > 0)
                    ans *= 10;

                System.out.println(ans);
            }
        }
        else if(s.charAt(l-2)=='_'){
            dash--;
            if(s.charAt(l-1)=='0' || s.charAt(l-1)=='5'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    if(x > 0)
                        ans *= 10;

                    ans *= 2;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 9;

                    ans *= 2;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    if(x > 0)
                        ans *= 10;

                    ans *= 2;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='_'){
                dash--;
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 9;

                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='X'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else{
                System.out.println();
            }
        }
        else if(s.charAt(l-2)=='X'){
            if(s.charAt(l-1)=='0'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 2;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);

                    ans *= 2;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='5'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 2;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 2;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);

                    ans *= 2;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='_'){
                dash--;
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 9;

                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='X'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else{
                System.out.println();
            }
        }
        else{
            System.out.println(0);
        }*/

        sc.close();
    }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : way[0];
      way[1] = s.length() == 2 ? 3 : way[1];
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println(arr1[i] + " " + i + " " + way[i]);
          ways = way[i];
        }
      }
      //System.out.println(ways);
      if (v.equals("XX") && s.charAt(0) == 'X') {
        ways = 0;
      }

      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (v.charAt(0) != 'X' && v.charAt(1) != 'X') {
        if (ok) {
          if (s.charAt(0) == 'X') {
            toti *= 1l * 9;
          } else {
            toti *= 1l * 10;
          }
        }
      }
      //System.out.println(ways);
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0' || str[0] == 'X' || str[0] == '_') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f == '_' && b.charAt(0) == '0' && str.length - 2 == 0) return;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    char cv = 'n'; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(char xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == '0' && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != 'n') xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    //System.out.println("add " + add);
    ret += add;
  }
}

//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0' || inp[0] == 'X' || inp[0] == '_') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);
                    idx++;

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    if(cstr.charAt(0) == '0') continue;
                    // System.out.println(cstr);
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }
        }

        System.out.println(count);

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

    //Shortcut function
    public static long lcm(long a , long b){
        return a * (b/gcd(a,b));
    }

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
   //--------------------------------------------------------
}

// -----------------------------------      Duniya Madarchod Hai       -----------------------------------

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

public class Main
 {

/*

    public String wrd() throws IOException{return(read.next());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}
    public int[] ai(int n) throws IOException{int arr[] = new int[n];for(int i = 0; i<n; i++)arr[i] = read.nextInt();return(arr);}
    public double[] ad(int n) throws IOException
    {double arr[] = new double[n];for(int i = 0; i<n; i++)arr[i] = read.nextDouble();return(arr);}
    public long[] al(int n) throws IOException
    {long arr[] = new long[n];for(int i = 0; i<n; i++)arr[i] = read.nextLong();return(arr);}

    class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    InputStream inputStream = new FileInputStream("input.txt");
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                     br = new BufferedReader(inputStreamReader);
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
        }

    String next(){while (st == null || !st.hasMoreElements()){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());}
    String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}}

*/

    class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    din = new DataInputStream(new FileInputStream("input.txt"));
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    }
                    else {
                        continue;
                    }
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0,
                                BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
public String readLine() throws IOException{return(read.readLine());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}

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

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

    long getSum(long arr[], int start, int end)
    {
        if(start == 0)
            return arr[end];
        return(arr[end] - arr[start-1]);
    }
    long MODULO = 1000*1000l*1000l + 7l;
    StringBuilder sb;
    Reader read;
    //FastReader read;

    int count = 0;
    public void solve() throws IOException
    {
        //Scanner sn = new Scanner(System.in);
        sb = new StringBuilder();
        //read = new FastReader();
        read = new Reader();
        int tt = 1;

        for(int tk = 0; tk < tt; tk++)
        {
            String s  = read.readLine();
            s = s.substring(0, s.length()-1);
            char arr[] = s.toCharArray();

            int numX = 0;
            if(arr[0] == '0' && arr.length != 1)
            {
                sb.append(0);
                continue;
            }
            for(char c : arr)
            {
                if(c == 'X')
                    numX++;
            }

            char xStop = numX == 0 ? '0' : '9';

            for(char alpha = '0'; alpha <= xStop ;  alpha++)
            {
                dfs(arr, 0, alpha);
            }

            sb.append(count);

        }

        System.out.println(sb);
    }

    void dfs(char arr[], int idx, char xVal)
    {
        if(idx == arr.length)
        {
            if(check(arr))
                count++;
            return;
        }

        if(arr[idx] == 'X')
        {

            arr[idx] = xVal;
            dfs(arr, idx+1, xVal);
            arr[idx] = 'X';
        }
        else if(arr[idx] == '_')
        {
            //char start = idx ==0 ? '1' : '0';
            for(char curr = '0'; curr <= '9'; curr++)
            {
                arr[idx] = curr;
                dfs(arr, idx+1, xVal);
                arr[idx] = '_';
            }
        }
        else
        {
            dfs(arr, idx+1, xVal);
        }
    }

    boolean check(char arr[])
    {
        if(arr[0] == '0' && arr.length > 1)
            return false;
        //bSystem.out.println("AT CHECK  "+Arrays.toString(arr));
        int temp = 0;
        for(int i = 0; i<arr.length; i++)
        {
            int num = arr[i] - '0';
            temp = temp * 10 + num;
        }

        return(temp % 25 == 0);
    }
}

import java.util.*;

import java.io.*;
import java.math.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;

public class Main {
	 private static class MyScanner {
	        private static final int BUF_SIZE = 2048;
	        BufferedReader br;

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

	        private boolean isSpace(char c) {
	            return c == '\n' || c == '\r' || c == ' ';
	        }

	        String next() {
	            try {
	                StringBuilder sb = new StringBuilder();
	                int r;
	                while ((r = br.read()) != -1 && isSpace((char)r));
	                if (r == -1) {
	                    return null;
	                }

	                sb.append((char) r);
	                while ((r = br.read()) != -1 && !isSpace((char)r)) {
	                    sb.append((char)r);
	                }
	                return sb.toString();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return null;
	        }

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

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

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

			BufferedReader br;
			StringTokenizer st;
			public Reader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			String next()
		    {
		        while (st == null || !st.hasMoreElements())
		        {
		            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());
		    }

		    String nextLine()
		    {
		        String str = "";
		        try
		        {
		            str = br.readLine();
		        }
		        catch (IOException e)
		        {
		            e.printStackTrace();
		        }
		        return str;
		    }
		}

	  static long mod = (long)(1e9 + 7);

	static void sort(long[] arr ) {
		 ArrayList<Long> al = new ArrayList<>();
		 for(long e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }
	static void sort(int[] arr ) {
		 ArrayList<Integer> al = new ArrayList<>();
		 for(int e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }

	static void sort(char[] arr) {
		ArrayList<Character> al = new ArrayList<Character>();
		for(char cc:arr) al.add(cc);
		Collections.sort(al);
		for(int i = 0 ;i<arr.length ;i++) arr[i] = al.get(i);
	}

	static long mod_mul(  long... a) {
		long ans = a[0]%mod;
		for(int i = 1 ; i<a.length ; i++) {
			ans = (ans * (a[i]%mod))%mod;
		}

		return ans;
	}
	static long mod_sum( long... a) {
		long ans = 0;
		for(long e:a) {
			ans = (ans + e)%mod;
		}
		return ans;
	}
	 static long gcd(long a, long b)
	  {
	     if (b == 0)
	        return a;
	     return gcd(b, a % b);
	  }
	 static boolean[] prime(int num) {
			boolean[] bool = new boolean[num];

		      for (int i = 0; i< bool.length; i++) {
		         bool[i] = true;
		      }
		      for (int i = 2; i< Math.sqrt(num); i++) {
		         if(bool[i] == true) {
		            for(int j = (i*i); j<num; j = j+i) {
		               bool[j] = false;
		            }
		         }
		      }
		      if(num >= 0) {
		    	  bool[0] = false;
		    	  bool[1] = false;
		      }

		      return bool;
		}

	 static long modInverse(long a, long m)
	    {
	        long g = gcd(a, m);

	          return   power(a, m - 2, m);

	    }
	   static long lcm(long a , long b) {
		   return (a*b)/gcd(a, b);
	   }
	   static int lcm(int a , int b) {
		   return (int)((a*b)/gcd(a, b));
	   }
	 static long power(long x, long y, long m){
	        if (y == 0) return 1; long p = power(x, y / 2, m) % m; p = (int)((p * (long)p) % m);
	        if (y % 2 == 0) return p; else return (int)((x * (long)p) % m); }

     static class Combinations{
	    	 private long[] z;
	    	 private long[] z1;
	    	 private long[] z2;
	    	 private long mod;
	    	  public Combinations(long N , long mod) {
	    		  this.mod = mod;
				z = new long[(int)N+1];
				z1 = new long[(int)N+1];
				z[0] = 1;
				for(int i =1 ; i<=N ; i++) z[i] = (z[i-1]*i)%mod;
			     z2 = new long[(int)N+1];
				z2[0] = z2[1] = 1;
			    for (int i = 2; i <= N; i++)
			        z2[i] = z2[(int)(mod % i)] * (mod - mod / i) % mod;

			    z1[0] = z1[1] = 1;

			    for (int i = 2; i <= N; i++)
			        z1[i] = (z2[i] * z1[i - 1]) % mod;
			}
	    	  long fac(long n) {
	    		  return z[(int)n];
	    	  }
	    	  long invrsNum(long n) {
	    		  return z2[(int)n];
	    	  }
	    	  long invrsFac(long n) {
	    		  return invrsFac((int)n);
	    	  }
	    	  long ncr(long N, long R)
	    	  {		if(R<0 || R>N ) return 0;
	    		    long ans = ((z[(int)N] * z1[(int)R])
	    		              % mod * z1[(int)(N - R)])
	    		             % mod;
	    		    return ans;
	    		}
	      }
	      static class DisjointUnionSets {
			    int[] rank, parent;
			    int n;

			    public DisjointUnionSets(int n)
			    {
			        rank = new int[n];
			        parent = new int[n];
			        this.n = n;
			        makeSet();
			    }

			    void makeSet()
			    {
			        for (int i = 0; i < n; i++) {

			            parent[i] = i;
			        }
			    }

			    int find(int x)
			    {
			        if (parent[x] != x) {

			            parent[x] = find(parent[x]);

			        }

			        return parent[x];
			    }

			    void union(int x, int y)
			    {
			        int xRoot = find(x), yRoot = find(y);

			        if (xRoot == yRoot)
			            return;

			        if (rank[xRoot] < rank[yRoot])

			            parent[xRoot] = yRoot;

			        else if (rank[yRoot] < rank[xRoot])

			            parent[yRoot] = xRoot;

			        else
			        {
			            parent[yRoot] = xRoot;

			            rank[xRoot] = rank[xRoot] + 1;
			        }
			    }
			}
	      static int max(int... a ) {
	    	  int max = a[0];
	    	  for(int e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static long max(long... a ) {
	    	  long max = a[0];
	    	  for(long e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static int min(int... a ) {
	    	  int min = a[0];
	    	  for(int e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static long min(long... a ) {
	    	  long min = a[0];
	    	  for(long e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static int[] KMP(String str) {
	    	  int n = str.length();
	    	  int[] kmp = new int[n];
	    	  for(int i = 1 ; i<n ; i++) {
	    		  int j = kmp[i-1];
	    		  while(j>0 && str.charAt(i) != str.charAt(j)) {
	    			  j = kmp[j-1];
	    		  }
	    		  if(str.charAt(i) == str.charAt(j)) j++;
	    		  kmp[i] = j;
	    	  }

	    	  return kmp;
	      }

/************************************************ Query **************************************************************************************/

/***************************************** 		Sparse Table	********************************************************/
	      static class SparseTable{

	    		private long[][] st;

	    		SparseTable(long[] arr){
	    			int n = arr.length;
	    			st = new long[n][25];
	    			log = new int[n+2];
	    			build_log(n+1);
	    			build(arr);
	    		}

	    		private void build(long[] arr) {
	    			int n = arr.length;

	    			for(int i = n-1 ; i>=0 ; i--) {
	    				for(int j = 0 ; j<25 ; j++) {
	    					int r = i + (1<<j)-1;
	    					if(r>=n) break;
	    					if(j == 0 ) st[i][j] = arr[i];
	    					else st[i][j] = Math.min(st[i][j-1] , st[ i + ( 1 << (j-1) ) ][ j-1 ] );
	    				}
	    			}
	    		}
	    		public long gcd(long a  ,long b) {
	    			if(a == 0) return b;
	    			return gcd(b%a , a);
	    		}
	    		public long query(int l ,int r) {
	    			int w = r-l+1;
	    			int power = log[w];
	    			return Math.min(st[l][power],st[r - (1<<power) + 1][power]);
	    		}
	    		private int[] log;
	    		void build_log(int n) {
	    			log[1] = 0;
	    			for(int i = 2 ; i<=n ; i++) {
	    				log[i] = 1 + log[i/2];
	    			}
	    		}
	    	}

/********************************************************	Segement Tree	*****************************************************/
/**
	 	 static class SegmentTree{
			 long[] tree;
			 long[] arr;
			 int n;
			 SegmentTree(long[] arr){
				 this.n = arr.length;
				 tree = new long[4*n+1];
				 this.arr = arr;
				 buildTree(0, n-1, 1);
			 }

			  void buildTree(int s ,int e  ,int index ) {
					if(s == e) {
						tree[index] = arr[s];
						return;
					}

					int mid = (s+e)/2;

					buildTree( s,  mid, 2*index);
					buildTree( mid+1, e, 2*index+1);

					tree[index] = Math.min(tree[2*index] , tree[2*index+1]);
				}

			 long query(int si ,int ei) {
				 return query(0 ,n-1 , si ,ei , 1   );
			 }
			 private long query( int ss ,int se ,int qs , int qe,int index) {

					if(ss>=qs && se<=qe) return tree[index];

					if(qe<ss || se<qs) return (long)(1e17);

					int mid = (ss + se)/2;
					long left = query( ss , mid , qs ,qe , 2*index);
					long right= query(mid + 1 , se , qs ,qe , 2*index+1);
					return Math.min(left, right);
				}
			 public void update(int index , int val) {
				 arr[index] = val;
				 for(long e:arr) System.out.print(e+" ");
				 update(index , 0 , n-1 , 1);
			 }
			 private void update(int id ,int si , int ei , int index) {
				 if(id < si || id>ei) return;
				 if(si == ei ) {
					 tree[index] = arr[id];
					 return;
				 }
				 if(si > ei) return;
				 int mid = (ei + si)/2;

					update( id,  si, mid , 2*index);
					update( id , mid+1, ei , 2*index+1);

					tree[index] = Math.min(tree[2*index] ,tree[2*index+1]);
			 }

		 }
		 */

/* ***************************************************************************************************************************************************/

//	      static MyScanner sc = new MyScanner(); // only in case of less memory
	      static Reader sc = new Reader();
	 static StringBuilder sb = new StringBuilder();
	 public static void main(String args[]) throws IOException {

		 int tc = 1;
//		  tc = sc.nextInt();

		 for(int i = 1 ; i<=tc ; i++) {

//			 sb.append("Case #" + i + ": "  );	// During KickStart && HackerCup
			 TEST_CASE();

		 }
		 System.out.print(sb);
	 }
	 static void TEST_CASE() {
		char[] arr = sc.next().toCharArray();

		int n = arr.length;
		if(n == 1) {
			if(arr[0] == '0' || arr[0] == '_' || arr[0] == 'X' ) sb.append("1\n");
			else sb.append("0\n");
			return;
		}
		if(arr[0] == '0') {
			sb.append("0\n");
			return;
		}
		boolean bool = false;
		for(char cc:arr) {
			if(cc == 'X') {
				bool = true;
				break;
			}
		}
		long tot = 0;
		if(bool) {

			for(int i = 0 ; i<10;  i++) {
				char[] temp = new char[n];
				for(int j = 0 ; j<n ; j++)
					temp[j] = arr[j];
				if(temp[0] == 'X' && i == 0) continue;
				for(int j = 0 ; j<n ; j++) {
					if(temp[j] == 'X') {
						temp[j] = (char)(i + '0');
					}
				}

				// we have arr without X
				flag = false;
				long back = back(temp);
				long pre = 1;
				for(int j = 0 ; j<n-2 ; j++) {
					if(temp[j] == '_') {
						if(j == 0) pre *= 9;
						else pre *= 10;
					}
				}
				tot += pre*back;
				if(pre == 1 && flag) {
					tot--;
				}
			}
		}else {
			flag = false;
			long back = back(arr);
			long pre = 1;
			for(int j = 0 ;j<n-2 ; j++) {
				if(arr[j] == '_') {
					if(j == 0) pre *= 9;
					else pre *= 10;
				}
			}
			tot += pre*back;
			if(pre == 1 && flag) {
				tot--;
			}
		}

		sb.append(tot+"\n");

	 }
	 static boolean flag;
	 static long back(char[] arr ) {
//		 System.out.println(String.valueOf(arr));
		 long tot = 0;
		 int n = arr.length;
		 if(fnc(arr, n-1) && fnc(arr , n-2)) {
			 long num = Long.parseLong(""+arr[n-2] + arr[n-1]);
			 if(num%25 == 0) {
				 if(num == 0) flag = true;
				 return 1;
			 }
			 else return 0;
		 }else if(arr[n-1] == '_' && arr[n-2] == '_') {
			 flag = true;
			 return 4;
		 }else if(arr[n-1] == '_' ) {
			 if(arr[n-2] == '2' || arr[n-2] == '0' || arr[n-2] == '7' || arr[n-2] == '5')
			 {	if(arr[n-2] == '0') flag=  true;
				 return 1;
			 }

			 else return 0;
		 }else {
			 if(arr[n-1] == '0' || arr[n-1] == '5')
				 {
				 if(arr[n-1] == '0') flag = true;
				 return 2;
				 }
			 else return 0;
		 }
		 }
	 static boolean fnc(char[] arr , int i) {
		 return arr[i] != '_' ;
	 }
}
/*******************************************************************************************************************************************************/

/**

 */

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

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;

            if(n == 1){
                if(str[0] == '0' || str[0] == '_' || str[0] == 'X' || str[0] == '1'){
                    ans.append(1+"\n");continue;
                }
            }

            long cnt=0;
            boolean Xp =false;
            // boolean allZero=true;
            // for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(n>2)
        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        // System.out.println(cnt);
        return cnt;
    }
}

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

public class Main {

	static AReader scan = new AReader();
	static char[] cs;
	static int res = 0;
	static int X = 0;
	static int n;

	static void dfs(int u,int s){
		if(u >= n){
			if(s % 25 == 0) res++;
			return;
		}
		int t = cs[u] - '0';
		if(t>=0 && t <= 9) dfs(u+1,s*10+t);
		else if(cs[u] == 'X') dfs(u+1,s*10+X);
		else {
			if (u == n - 1) {
				dfs(u + 1, s * 10 + 5);
				dfs(u + 1, s * 10);
			} else {
				for (int i = 0; i < 10; i++) {
					if (i == 0 && u == 0) continue;
					dfs(u + 1, s * 10 + i);
				}
			}
		}
	}

	static void solve() {
		cs = scan.next().toCharArray();
		n = cs.length;
		boolean flag = false;
		for(char c:cs){
			if(c == 'X'){
				flag = true;
				break;
			}
		}
		if(cs[0] == '0' && n != 1){
			System.out.println(0);
			return;
		}
		if(flag){
		for(int i = 0;i<10;i++) {
			if(cs[0] == 'X' && n > 1 && i == 0) continue;
			X = i;
			dfs(0,0);
		}
		}else dfs(0,0);
		System.out.println(res);
	}

	public static void main(String[] args)  {
		//int T = scan.nextInt();
		//while (T-- > 0) {
		solve();
		//}
		//System.out.print(sb.toString());
	}
}

class AReader {
	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private StringTokenizer tokenizer = new StringTokenizer("");

	private String innerNextLine() {
		try {
			return reader.readLine();
		} catch (IOException ex) {
			return null;
		}
	}

	public boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String nextLine = innerNextLine();
			if (nextLine == null) {
				return false;
			}
			tokenizer = new StringTokenizer(nextLine);
		}
		return true;
	}

	public String nextLine() {
		tokenizer = new StringTokenizer("");
		return innerNextLine();
	}

	public String next() {
		hasNext();
		return tokenizer.nextToken();
	}

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

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

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

class Pair {
	int x,y;

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

import java.io.*;
import java.util.*;
// Problem Link: https://codeforces.com/problemset/problem/1575/D
public class div25 {
    public static char[] str;
    public static int S;
    public static void main (String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().toCharArray();
        S = str.length;
        int ans = 0;
        if (S==1) {
            if (str[0]=='X' || str[0] == '_' || Integer.parseInt(String.valueOf(str[0])) == 0) ans = 1;
        }
        else {
            ans += count_possibilities(2, 5);
            ans += count_possibilities(5, 0);
            ans += count_possibilities(7, 5);
            ans += count_possibilities(0, 0); }
        System.out.println(ans);

    }
    static int count_possibilities(int end1, int end2) {
        //System.out.println(end1 + " " + end2);
        if (S==2 && end1==0) return 0;
        int X_val = -1;
        if (str[S-2]=='X') X_val = end1;
        else {
            if (str[S-2]!='_') {
                if (value(S-2) != end1) return 0; } }
        //System.out.println("reached here");
        if (str[S-1]=='X') {
            if (X_val != -1 && end2 != X_val) return 0;
            else X_val = end2; }
        else {
            if (str[S-1]!='_') {
                if (value(S-1) != end2) return 0; } }
        //System.out.println("reached HERE");
        int total = 1;
        for (int i=0;i<S-2;i++) {
//            System.out.println(total);
//            System.out.println(X_val);
//            System.out.println(i + " " + str[i]);
            if (i==0) {
                if (str[i]=='X' && X_val==0) return 0;
                if (value(0) == 0) return 0; }
            if (str[i]=='_') {
                if (i==0) total *= 9;
                else total *= 10; }
            if (str[i]=='X') {
                if (X_val != -1) continue;
                else {
                    X_val = 10; // represents that X can be any integer from 0 to 9 (or possibly 1 to 9)
                    if (i==0) total *= 9;
                    else total *= 10;
                }
            }
        }
        //System.out.println(total);
        return total;
    }

    static boolean isDigit(int pos) {
        if (str[pos]=='_' || str[pos]=='X') return false;
        else return true;
    }

    static int value(int pos) {
        if (!isDigit(pos)) return -1;
        return Integer.parseInt(String.valueOf(str[pos]));
    }
}

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            String s=input.next();
            if(s.length()==1)
            {
                if(s.charAt(0)=='0' || s.charAt(0)=='_' || s.charAt(0)=='X') out.println(1);
                else out.println(0);
            }
            else
            {
                int f=0;
                for(int i=0;i<s.length();i++)
                {
                    if(s.charAt(i)=='X')
                    {
                        f=1;
                        break;
                    }
                }
                if(f==0)
                {
                    out.println(fun(s));
                }
                else
                {
                    int sum=0;
                    for(int i=0;i<10;i++)
                    {
                        char ch[]=s.toCharArray();
                        for(int j=0;j<s.length();j++)
                        {
                            if(ch[j]=='X')
                            {
                                ch[j]=(char)(i+'0');
                            }
                        }
                        String str=String.copyValueOf(ch);
                        sum+=fun(str);
                    }
                    out.println(sum);
                }
            }
        }
        out.close();
    }
    public static int fun(String s)
    {
        int n=s.length();
        int p=0;
        if(s.charAt(0)!='0')p=1;
        for(int i=0;i<n-2;i++)
        {
            if(s.charAt(i)=='_')
            {
                if(i==0) p*=9;
                else p*=10;
            }
        }
        int p1=0;
        if(s.charAt(n-1)=='_' && s.charAt(n-2)=='_')
        {
            p1=4;
            if(n==2) p1=3;
        }
        else if(s.charAt(n-1)=='_')
        {
            if(s.charAt(n-2)=='0' || s.charAt(n-2)=='5' || s.charAt(n-2)=='2' || s.charAt(n-2)=='7') p1=1;
        }
        else if(s.charAt(n-2)=='_')
        {
            if(s.charAt(n-1)=='0')
            {
                p1=2;
                if(n==2) p1=1;
            }
            else if(s.charAt(n-1)=='5')
            {
                p1=2;
            }
        }
        else
        {
            int val=Integer.valueOf(s.substring(n-2));
            if(val%25==0) p1=1;
        }
        int pro=p*p1;
        return pro;
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                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());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.*;
public class TwentyFive {
	public static void main(String[] args) throws Exception {
		FastIO in = new FastIO();
		String s = in.next();
		int ans = 0;
		for (int i=0; i<100000000; i+=25) {
			String test = i+"";
			if (test.length()!=s.length()) continue;
			int xValue = -1;
			boolean works = true;
			for (int j=0; j<s.length(); j++) {
				if (s.charAt(j)=='X') {
					if (xValue==-1) {
						xValue = test.charAt(j);
					}
					if (test.charAt(j)!=xValue) {
						works = false;
						break;
					}
				}
				else if (s.charAt(j)!='_') {
					if (test.charAt(j)!=s.charAt(j)) {
						works = false;
						break;
					}
				}
			}
			if (works) ans++;
		}
		System.out.println(ans);
	}
	static class FastIO {
		BufferedReader br;
	    StringTokenizer st;
	    public FastIO() throws IOException
	    {
	        br = new BufferedReader(
	            new InputStreamReader(System.in));

	    }

	    public String next() throws IOException
	    {
	        while (st == null || !st.hasMoreElements()) {

	            st = new StringTokenizer(br.readLine());
	        }
	        return st.nextToken();
	    }

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

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

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

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

import java.util.*;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine().trim();
        assert str.length() >= 1 && str.length() <= 8 : "Length of S not in range";
        if (str.charAt(0) == '0') {
            System.out.println(str.length() > 1 ? "0" : "1");
            return;
        }
        int fromVal = Integer.parseInt("1" + "0".repeat(str.length() - 1));
        if (fromVal == 1) {
            fromVal = 0;
        } else if (fromVal == 10) {
            fromVal = 25;
        }
        int toVal = Integer.parseInt("9".repeat(str.length()));
        int count = 0;
        for (int val = fromVal; val <= toVal; val += 25) {
            if (canFormInteger(val, str)) {
                count++;
            }
        }
        System.out.println(count);
    }

    private static boolean canFormInteger(int num, String str) {
        String strNum = String.valueOf(num);
        char xVal = '*';
        for (int index = 0; index < str.length(); index++) {
            if (str.charAt(index) == '_') {
                continue;
            } else if (str.charAt(index) == 'X') {
                if (xVal != '*' && xVal != strNum.charAt(index)) {
                    return false;
                }
                xVal = strNum.charAt(index);
            } else if (str.charAt(index) != strNum.charAt(index)) {
                return false;
            }
        }
        return true;
    }
}

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

public class Solution {

    private static final String checkerSolutionOutput = "/home/quanvda/Main/Projects/MyProject/java-competitive-programming/src/_checker.solution.out";
    private static final String checkerInput = "/home/quanvda/Main/Projects/MyProject/java-competitive-programming/src/_checker.in";
    private static final String checkerBruteforcesOutput = "/home/quanvda/Main/Projects/MyProject/java-competitive-programming/src/_checker.bruteforces.out";
    private static final String fileInput = "/home/quanvda/Main/Projects/MyProject/java-competitive-programming/src/_in";
    private static final String fileOutput = "/home/quanvda/Main/Projects/MyProject/java-competitive-programming/src/_out";

    private static class Config {
        private static final boolean useInputFile = false;
        private static final boolean useOutputFile = false;
        private static final String inputFile = fileInput;
        private static final String outputFile = checkerSolutionOutput;
    }

    public static void main(String[] args) throws Exception {
        run();
    }

    public static void run() throws Exception {
        FastScanner sc = new FastScanner();
        int t = 1;
        BufferedWriter writer = getWriter();
        for (int i = 0; i < t; i++)
            solve(sc, writer);
        writer.flush();
    }

    private static void calcMid(long dp[][], int num, int i, String s) {
        int p = (int) ((num * Math.pow(10, s.length() - i - 1)) % 25);
        for (int j = 0; j < 25; j++) {
            int q = j >= p ? j - p : 25 + j - p;
            dp[i][j] += dp[i + 1][q];
        }
    }

    private static void solve(FastScanner sc, BufferedWriter writer) throws Exception {
        String s = sc.next();
        if (s.length() == 1) {
            char c = s.charAt(0);
            if (c == 'X' || c == '_') {
                writer.write("1");
            } else {
                if ((c - '0') % 25 == 0) writer.write("1");
                else writer.write("0");
            }
            return;
        }
        long ans = 0;
        mainLoop:
        for (int r = 0; r < 10; r++) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.length(); i++)
                if (s.charAt(i) == 'X') sb.append(r);
                else sb.append(s.charAt(i));
            String ss = sb.toString();
            long dp[][] = new long[s.length()][25];
            for (int i = s.length() - 1; i >= 0; i--) {
                char c = ss.charAt(i);
                // case last
                if (i == s.length() - 1) {
                    if (c == '_')
                        for (int j = 0; j <= 9; j++)
                            dp[i][j % 25] = 1;
                    else
                        dp[i][(c - '0') % 25] = 1;
                }
                // case first
                else if (i == 0) {
                    if (c == '0')
                        continue mainLoop;
                    else if (c == '_')
                        for (int j = 1; j <= 9; j++)
                            calcMid(dp, j, i, s);
                    else calcMid(dp, c - '0', i, s);
                }
                // case mid
                else {
                    if (c == '_')
                        for (int j = 0; j <= 9; j++)
                            calcMid(dp, j, i, s);
                    else calcMid(dp, c - '0', i, s);
                }
            }

//            System.out.println("__________________________");
//            System.out.println("S: " + ss);
//            for (int i = 0; i < s.length(); i++)
//                for (int j = 0; j < 25; j++)
//                    System.out.println("Dp " + i + "," + j + " is " + dp[i][j]);

            ans += dp[0][0];
            if (!s.contains("X")) break;
        }
        writer.write(ans + "");
    }

    private static class Pair<A, B> {
        A first;
        B second;

        public Pair(A first, B second) {
            this.first = first;
            this.second = second;
        }

        public Pair() {
        }
    }

    private static class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        private FastScanner() throws FileNotFoundException {
            if (Config.useInputFile)
                this.br = new BufferedReader(new InputStreamReader(new FileInputStream(Config.inputFile)));
            else
                this.br = new BufferedReader(new InputStreamReader(System.in));
            this.st = new StringTokenizer("");
        }

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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

    private static BufferedWriter getWriter() throws Exception {
        if (Config.useOutputFile)
            return getFileWriter();
        return getConsoleWriter();
    }

    private static BufferedWriter getFileWriter() throws Exception {
        PrintWriter writer = new PrintWriter(Config.outputFile);
        writer.print("");
        writer.close();
        return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(Config.outputFile)));
    }

    private static BufferedWriter getConsoleWriter() {
        return new BufferedWriter(new OutputStreamWriter(System.out));
    }
}

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

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();

        char s[]=bu.readLine().toCharArray();
        boolean x=false;
        int n=s.length,i;
        for(i=0;i<n;i++) x|=s[i]=='X';

        int ans=0;
        char s2[]=new char[n];
        for(i=0;i<10;i++)
        {
            int j;
            for(j=0;j<n;j++)
            if(s[j]=='X') s2[j]=(char)('0'+i);
            else s2[j]=s[j];
            if(s2[0]=='0') continue;    //not possible

            int dp[][]=new int[2][25],cur=1,l,k;
            dp[0][0]=1;
            for(j=0;j<n;j++)
            {
                for(k=0;k<25;k++) dp[cur][k]=0;
                int lo=0,hi=9,nxt;
                if(s2[j]!='_') lo=hi=(s2[j]-'0');
                else if(s2[j]=='_' && j==0) lo++;

                for(k=0;k<25;k++)
                for(l=lo;l<=hi;l++)
                {
                    nxt=(k*10+l)%25;
                    dp[cur][nxt]+=dp[cur^1][k];
                }
                cur^=1;
            }

            ans+=dp[cur^1][0];
            if(!x) break;
        }

        if(n==1 && (s[0]=='_' || s[0]=='X' || s[0]=='0')) ans++;
        System.out.println(ans);
    }
}

import com.sun.source.tree.Tree;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

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);
        Solution solver = new Solution();
        boolean multipleTC = false;
        int testCount = multipleTC ? Integer.parseInt(in.next()) : 1;
        for (int i = 1; i <= testCount; i++) solver.solve(in, out, i);
        out.close();
    }

    static class Solution {
        PrintWriter out;
        InputReader in;

        int[][][] dp = new int[10][25][10];
        int go(int ind, int sum, int xVal, String s) {
            if(ind == s.length()) {
                if(sum == 0) {
                    return 1;
                } else {
                    return 0;
                }
            }
            if(dp[ind][sum][xVal] != -1)
                return dp[ind][sum][xVal];
            int ans = 0;
            if(Character.isDigit(s.charAt(ind))) {
                ans += go(ind + 1, (sum * 10 + (s.charAt(ind) - '0')) % 25, xVal, s);
            } else if(s.charAt(ind) == 'X') {
                if(!(ind == 0 && s.length() != 1 && xVal == 0))
                    ans += go(ind + 1, (sum * 10 + xVal) % 25, xVal, s);
            } else {
                for(int i = 0; i < 10; i++) {
                    if(i == 0 && ind == 0 && s.length() != 1)
                        continue;
                    ans += go(ind + 1, (sum * 10 + i) % 25, xVal, s);
                }
            }
            return dp[ind][sum][xVal] = ans;
        }
        public void solve(InputReader in, PrintWriter out, int test) {
            this.out = out;
            this.in = in;
            String s = n();
            for(int i = 0; i < 10; i++) {
                for(int j = 0; j < 25; j++) {
                    Arrays.fill(dp[i][j], -1);
                }
            }
            int cntX = 0;
            for(int i = 0; i < s.length(); i++) {
                if(s.charAt(i) == 'X')
                    cntX++;
            }
            if(cntX == 0) {
                pn(go(0, 0, 0, s));
                return;
            }
            int ans = 0;
            for(int i = 0; i < 10; i++) {
                ans += go(0, 0, i, s);
            }
            pn(ans);
        }

        String n() {
            return in.next();
        }

        int ni() {
            return in.nextInt();
        }

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

        void pn(String sz) {
            out.println(sz);
        }

        void pn(double dx) {
            out.println(dx);
        }

    }

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

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

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

// CFPS -> CodeForcesProblemSet
public final class CFPS {
	static FastReader fr = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);
	static final int gigamod = 1000000007;
	static int t = 1;
	static double epsilon = 0.00000001;
	static boolean[] isPrime;
	static int[] smallestFactorOf;

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		OUTER:
		for (int tc = 0; tc < t; tc++) {

			char[] sOG = fr.next().toCharArray();
			int n = sOG.length;

			if (n == 1) {
				if (sOG[0] == '0' || sOG[0] == '_' || sOG[0] == 'X')
					out.println(1);
				else
					out.println(0);
				continue OUTER;
			}

			// 00, 25, 50, 75 are the 4 universes
			// we'll count for all of them independently

			int answer = 0;

			{
				// 00
				// non _ and nonzero == death is true
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= (s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '0');

				if (!shit) {

					if (s[n - 1] == 'X' || s[n - 2] == 'X')
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';
					s[n - 1] = '0';
					s[n - 2] = '0';

					// now, we will iterate over all prefixes and
					// for each prefix, check whether it is possible to transform
					// s[] into (prefix + "00")

					// prefix has to be atmost 6 digits

					answer += check("00".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "00").toCharArray();
						answer += check(tgt, s);
					}

				}
			}

			{
				// 25
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '2';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 2
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '2';
					}

					s[n - 1] = '5';
					s[n - 2] = '2';

					answer += check("25".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "25").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 50
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '5';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 0
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';

					} else if (s[n - 2] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';
					}

					s[n - 1] = '0';
					s[n - 2] = '5';

					answer += check("50".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "50").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 75
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '7';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 7
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '7';
					}

					s[n - 1] = '5';
					s[n - 2] = '7';

					answer += check("75".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "75").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			out.println(answer);

			// out.println(check("34593925".toCharArray(), sOG));
		}
		out.close();
	}

	static int check(char[] tgt, char[] src) {
		int n = tgt.length;
		if (src.length != n) return 0;

		// 'X' check
		char xDig = 0;
		for (int i = 0; i < n; i++)
			if (src[i] == 'X') {
				if (xDig == 0) {
					xDig = tgt[i];
				} else {
					if (tgt[i] != xDig) return 0;
				}
			}
		// assert all 'X's have same digit;

		// no leading zeroes plz
		if (tgt[0] == '0') return 0;

		// all non _s have to be equal
		for (int i = 0; i < n; i++)
			if (src[i] != '_' && src[i] != 'X' && tgt[i] != src[i]) return 0;

		return 1;
	}

	static class Edge implements Comparable<Edge> {
		int from, to;
		long weight;
		int id;
		// int hash;

		Edge(int fro, int t, long weigh, int i) {
			from = fro;
			to = t;
			weight = weigh;
			id = i;
			// hash = Objects.hash(from, to, weight);
		}

		/*public int hashCode() {
			return hash;
		}*/

		public int compareTo(Edge that) {
			return Long.compare(this.id, that.id);
		}
	}

	public static long[][] sparseTable(long[] a)
	{
		int n = a.length;
		int b = 32-Integer.numberOfLeadingZeros(n);
		long[][] ret = new long[b][];
		for(int i = 0, l = 1;i < b;i++, l*=2) {
			if(i == 0) {
				ret[i] = a;
			}else {
				ret[i] = new long[n-l+1];
				for(int j = 0;j < n-l+1;j++) {
					ret[i][j] = Math.min(ret[i-1][j], ret[i-1][j+l/2]);
				}
			}
		}
		return ret;
	}

	public static long sparseRMQ(long[][] table, int l, int r)
	{
		// [a,b)
		assert l <= r;
		if(l >= r)return Integer.MAX_VALUE;
		// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
		int t = 31-Integer.numberOfLeadingZeros(r-l);
		return Math.min(table[t][l], table[t][r-(1<<t)]);
	}

	static class Point implements Comparable<Point> {
		long x;
		long y;
		long z;
		long id;
		// private int hashCode;

		Point() {
			x = z = y = 0;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(Point p) {
			this.x = p.x;
			this.y = p.y;
			this.z = p.z;
			this.id = p.id;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(long x, long y, long z, long id) {
			this.x = x;
			this.y = y;
			this.z = z;
			this.id = id;
			// this.hashCode = Objects.hash(x, y, id);
		}

		Point(long a, long b) {
			this.x = a;
			this.y = b;
			this.z = 0;
			// this.hashCode = Objects.hash(a, b);
		}

		Point(long x, long y, long id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}

		@Override
		public int compareTo(Point o) {
			if (this.x < o.x)
				return -1;
			if (this.x > o.x)
				return 1;
			if (this.y < o.y)
				return -1;
			if (this.y > o.y)
				return 1;
			if (this.z < o.z)
				return -1;
			if (this.z > o.z)
				return 1;
			return 0;
		}

		@Override
		public boolean equals(Object that) {
			return this.compareTo((Point) that) == 0;
		}

		/*@Override
		public int hashCode() {
			return this.hashCode;
		}*/
	}

	static class BinaryLift {

		// FUNCTIONS: k-th ancestor and LCA in log(n)

		int[] parentOf;
		int maxJmpPow;
		int[][] binAncestorOf;
		int n;
		int[] lvlOf;

		// How this works?

		// a. For every node, we store the b-ancestor for b in {1, 2, 4, 8, .. log(n)}.

		// b. When we need k-ancestor, we represent 'k' in binary and for each set bit, we
		//    lift level in the tree.

		public BinaryLift(UGraph tree) {
			n = tree.V();
			maxJmpPow = logk(n, 2) + 1;
			parentOf = new int[n];
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			parentConstruct(0, -1, tree, 0);
			binConstruct();
		}

		// TODO: Implement lvlOf[] initialization
		public BinaryLift(int[] parentOf) {
			this.parentOf = parentOf;
			n = parentOf.length;
			maxJmpPow = logk(n, 2) + 1;
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			UGraph tree = new UGraph(n);
			for (int i = 1; i < n; i++)
				tree.addEdge(i, parentOf[i]);
			binConstruct();
			parentConstruct(0, -1, tree, 0);
		}

		private void parentConstruct(int current, int from, UGraph tree, int depth) {
			parentOf[current] = from;
			lvlOf[current] = depth;
			for (int adj : tree.adj(current))
				if (adj != from)
					parentConstruct(adj, current, tree, depth + 1);
		}

		private void binConstruct() {
			for (int node = 0; node < n; node++)
				for (int lvl = 0; lvl < maxJmpPow; lvl++)
					binConstruct(node, lvl);
		}

		private int binConstruct(int node, int lvl) {
			if (node < 0)
				return -1;
			if (lvl == 0)
				return binAncestorOf[node][lvl] = parentOf[node];
			if (node == 0)
				return binAncestorOf[node][lvl] = -1;

			if (binAncestorOf[node][lvl] != -1)
				return binAncestorOf[node][lvl];
			return binAncestorOf[node][lvl] = binConstruct(binConstruct(node, lvl - 1), lvl - 1);
		}

		// return ancestor which is 'k' levels above this one
		public int ancestor(int node, int k) {
			if (node < 0)
				return -1;
			if (node == 0)
				if (k == 0) return node;
				else return -1;
			if (k > (1 << maxJmpPow) - 1)
				return -1;
			if (k == 0)
				return node;

			int ancestor = node;
			int highestBit = Integer.highestOneBit(k);

			while (k > 0 && ancestor != -1) {
				ancestor = binAncestorOf[ancestor][logk(highestBit, 2)];
				k -= highestBit;
				highestBit = Integer.highestOneBit(k);
			}

			return ancestor;
		}

		public int lca(int u, int v) {

			if (u == v)
				return u;

			// The invariant will be that 'u' is below 'v' initially.
			if (lvlOf[u] < lvlOf[v]) {
				int temp = u;
				u = v;
				v = temp;
			}

			// Equalizing the levels.
			u = ancestor(u, lvlOf[u] - lvlOf[v]);

			if (u == v)
				return u;

			// We will now raise level by largest fitting power of two until possible.
			for (int power = maxJmpPow - 1; power > -1; power--)
				if (binAncestorOf[u][power] != binAncestorOf[v][power]) {
					u = binAncestorOf[u][power];
					v = binAncestorOf[v][power];
				}

			return ancestor(u, 1);
		}
	}

	static class DFSTree {

		// NOTE: The thing is made keeping in mind that the whole
		//  	 input graph is connected.

		UGraph tree;
		UGraph backUG;
		int hasBridge;
		int n;

		DFSTree(UGraph ug) {
			this.n = ug.V();
			tree = new UGraph(n);
			hasBridge = -1;
			backUG = new UGraph(n);
			treeCalc(0, -1, new boolean[n], ug);
		}

		private void treeCalc(int current, int from, boolean[] marked, UGraph ug) {
			if (marked[current]) {
				// This is a backEdge.
				backUG.addEdge(from, current);
				return;
			}

			if (from != -1)
				tree.addEdge(from, current);
			marked[current] = true;

			for (int adj : ug.adj(current))
				if (adj != from)
					treeCalc(adj, current, marked, ug);
		}

		public boolean hasBridge() {
			if (hasBridge != -1)
				return (hasBridge == 1);

			// We have to determine the bridge.
			bridgeFinder();
			return (hasBridge == 1);
		}

		int[] levelOf;
		int[] dp;

		private void bridgeFinder() {

			// Finding the level of each node.
			levelOf = new int[n];

			// Applying DP solution.
			// dp[i] -> Highest level reachable from subtree of 'i' using
			//   		some backEdge.
			dp = new int[n];
			Arrays.fill(dp, Integer.MAX_VALUE / 100);
			dpDFS(0, -1, 0);

			// Now, we will check each edge and determine whether its a
			// bridge.

			for (int i = 0; i < n; i++)
				for (int adj : tree.adj(i)) {

					// (i -> adj) is the edge.

					if (dp[adj] > levelOf[i])
						hasBridge = 1;
				}

			if (hasBridge != 1)
				hasBridge = 0;
		}

		private int dpDFS(int current, int from, int lvl) {
			levelOf[current] = lvl;
			dp[current] = levelOf[current];
			for (int back : backUG.adj(current))
				dp[current] = Math.min(dp[current], levelOf[back]);

			for (int adj : tree.adj(current))
				if (adj != from)
					dp[current] = Math.min(dp[current], dpDFS(adj, current, lvl + 1));

			return dp[current];
		}
	}

	static class UnionFind {
		// Uses weighted quick-union with path compression.
	    private int[] parent;  // parent[i] = parent of i
	    private int[] size;    // size[i] = number of sites in tree rooted at i
	                           // Note: not necessarily correct if i is not a root node
	    private int count;     // number of components

	    public UnionFind(int n) {
	        count = n;
	        parent = new int[n];
	        size = new int[n];
	        for (int i = 0; i < n; i++) {
	            parent[i] = i;
	            size[i] = 1;
	        }
	    }

	    // Number of connected components.
	    public int count() {
	        return count;
	    }

	    // Find the root of p.
	    public int find(int p) {
	    	while (p != parent[p])
	            p = parent[p];
	        return p;
	    }

	    public boolean connected(int p, int q) {
	        return find(p) == find(q);
	    }

	    public int numConnectedTo(int node) {
	    	return size[find(node)];
	    }

	    // Weighted union.
	    public void union(int p, int q) {
	        int rootP = find(p);
	        int rootQ = find(q);

	        if (rootP == rootQ) return;

	        // make smaller root point to larger one
	        if (size[rootP] < size[rootQ]) {
	            parent[rootP] = rootQ;
	            size[rootQ] += size[rootP];
	        }
	        else {
	            parent[rootQ] = rootP;
	            size[rootP] += size[rootQ];
	        }
	        count--;
	    }

	    public static int[] connectedComponents(UnionFind uf) {
	    	// We can do this in nlogn.

	    	int n = uf.size.length;
	    	int[] compoColors = new int[n];
	    	for (int i = 0; i < n; i++)
	    		compoColors[i] = uf.find(i);

	    	HashMap<Integer, Integer> oldToNew = new HashMap<>();
	    	int newCtr = 0;

	    	for (int i = 0; i < n; i++) {

	    		int thisOldColor = compoColors[i];
	    		Integer thisNewColor = oldToNew.get(thisOldColor);
	    		if (thisNewColor == null)
	    			thisNewColor = newCtr++;

	    		oldToNew.put(thisOldColor, thisNewColor);
	    		compoColors[i] = thisNewColor;
	    	}

	    	return compoColors;
	    }
	}

	static class UGraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public UGraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
			adj[to].add(from);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int degree(int v) {
			return adj[v].size();
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static void dfsMark(int current, boolean[] marked, UGraph g) {
			if (marked[current]) return;

			marked[current] = true;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, marked, g);
		}

		public static void dfsMark(int current, int from, long[] distTo, boolean[] marked, UGraph g, ArrayList<Integer> endPoints) {
			if (marked[current]) return;

			marked[current] = true;
			if (from != -1)
				distTo[current] = distTo[from] + 1;
			HashSet<Integer> adj = g.adj(current);
			int alreadyMarkedCtr = 0;
			for (int adjc : adj) {
				if (marked[adjc]) alreadyMarkedCtr++;
				dfsMark(adjc, current, distTo, marked, g, endPoints);
			}

			if (alreadyMarkedCtr == adj.size())
				endPoints.add(current);
		}

		public static void bfsOrder(int current, UGraph g) {
		}

		public static void dfsMark(int current, int[] colorIds, int color, UGraph g) {
			if (colorIds[current] != -1) return;

			colorIds[current] = color;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, colorIds, color, g);
		}

		public static int[] connectedComponents(UGraph g) {
			int n = g.V();
			int[] componentId = new int[n];
			Arrays.fill(componentId, -1);
			int colorCtr = 0;
			for (int i = 0; i < n; i++) {
				if (componentId[i] != -1) continue;
				dfsMark(i, componentId, colorCtr, g);
				colorCtr++;
			}

			return componentId;
		}

		public static boolean hasCycle(UGraph ug) {
			int n = ug.V();
			boolean[] marked = new boolean[n];
			boolean[] hasCycleFirst = new boolean[1];
			for (int i = 0; i < n; i++) {
				if (marked[i]) continue;
				hcDfsMark(i, ug, marked, hasCycleFirst, -1);
			}
			return hasCycleFirst[0];
		}

		// Helper for hasCycle.
		private static void hcDfsMark(int current, UGraph ug, boolean[] marked, boolean[] hasCycleFirst, int parent) {
			if (marked[current]) return;
			if (hasCycleFirst[0]) return;

			marked[current] = true;
			HashSet<Integer> adjc = ug.adj(current);
			for (int adj : adjc) {
				if (marked[adj] && adj != parent && parent != -1) {
					hasCycleFirst[0] = true;
					return;
				}

				hcDfsMark(adj, ug, marked, hasCycleFirst, current);
			}
		}
	}

	static class Digraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public Digraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public Digraph reversed() {
			Digraph dg = new Digraph(V());
			for (int i = 0; i < V(); i++)
				for (int adjVert : adj(i)) dg.addEdge(adjVert, i);
			return dg;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static int[] KosarajuSharirSCC(Digraph dg) {
			int[] id = new int[dg.V()];

			Digraph reversed = dg.reversed();

			// Gotta perform topological sort on this one to get the stack.
			Stack<Integer> revStack = Digraph.topologicalSort(reversed);

			// Initializing id and idCtr.
			id = new int[dg.V()];
			int idCtr = -1;

			// Creating a 'marked' array.
			boolean[] marked = new boolean[dg.V()];

			while (!revStack.isEmpty()) {
				int vertex = revStack.pop();
				if (!marked[vertex])
					sccDFS(dg, vertex, marked, ++idCtr, id);
			}
			return id;
		}

		private static void sccDFS(Digraph dg, int source, boolean[] marked, int idCtr, int[] id) {
			marked[source] = true;
			id[source] = idCtr;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex]) sccDFS(dg, adjVertex, marked, idCtr, id);
		}

		public static Stack<Integer> topologicalSort(Digraph dg) {
			// dg has to be a directed acyclic graph.
			// We'll have to run dfs on the digraph and push the deepest nodes on stack first.
			// We'll need a Stack<Integer> and a int[] marked.
			Stack<Integer> topologicalStack = new Stack<Integer>();
			boolean[] marked = new boolean[dg.V()];

			// Calling dfs
			for (int i = 0; i < dg.V(); i++)
				if (!marked[i])
					runDfs(dg, topologicalStack, marked, i);

			return topologicalStack;
		}

		static void runDfs(Digraph dg, Stack<Integer> topologicalStack, boolean[] marked, int source) {
			marked[source] = true;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex])
					runDfs(dg, topologicalStack, marked, adjVertex);
			topologicalStack.add(source);
		}
	}

	static class FastReader {
		private BufferedReader bfr;
		private StringTokenizer st;
		public FastReader() {
			bfr = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			if (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(bfr.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());
		}

		char nextChar() {
			return next().toCharArray()[0];
		}

		String nextString() {
			return next();
		}

		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		double[] nextDoubleArray(int n) {
			double[] arr = new double[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextDouble();
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		int[][] nextIntGrid(int n, int m) {
			int[][] grid = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					grid[i][j] = fr.nextInt();
			}
			return grid;
		}
	}

	static class LCA {
	    int[] height, first, segtree;
	    ArrayList<Integer> euler;
	    boolean[] visited;
	    int n;

	    LCA(UGraph ug, int root) {
	        n = ug.V();
	        height = new int[n];
	        first = new int[n];
	        euler = new ArrayList<>();
	        visited = new boolean[n];
	        dfs(ug, root, 0);
	        int m = euler.size();
	        segtree = new int[m * 4];
	        build(1, 0, m - 1);
	    }

	    void dfs(UGraph ug, int node, int h) {
	        visited[node] = true;
	        height[node] = h;
	        first[node] = euler.size();
	        euler.add(node);
	        for (int adj : ug.adj(node)) {
	            if (!visited[adj]) {
	                dfs(ug, adj, h + 1);
	                euler.add(node);
	            }
	        }
	    }

	    void build(int node, int b, int e) {
	        if (b == e) {
	            segtree[node] = euler.get(b);
	        } else {
	            int mid = (b + e) / 2;
	            build(node << 1, b, mid);
	            build(node << 1 | 1, mid + 1, e);
	            int l = segtree[node << 1], r = segtree[node << 1 | 1];
	            segtree[node] = (height[l] < height[r]) ? l : r;
	        }
	    }

	    int query(int node, int b, int e, int L, int R) {
	        if (b > R || e < L)
	            return -1;
	        if (b >= L && e <= R)
	            return segtree[node];
	        int mid = (b + e) >> 1;

	        int left = query(node << 1, b, mid, L, R);
	        int right = query(node << 1 | 1, mid + 1, e, L, R);
	        if (left == -1) return right;
	        if (right == -1) return left;
	        return height[left] < height[right] ? left : right;
	    }

	    int lca(int u, int v) {
	        int left = first[u], right = first[v];
	        if (left > right) {
	        	int temp = left;
	        	left = right;
	        	right = temp;
	        }
	        return query(1, 0, euler.size() - 1, left, right);
	    }
	}

	static class FenwickTree {

	    long[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new long[size + 1];
	    }

	    public long rsq(int ind) {
	        assert ind > 0;
	        long sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }

	        return sum;
	    }

	    public long rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;

	        return rsq(b) - rsq(a - 1);
	    }

	    public void update(int ind, long value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }

	    public int size() {
	        return array.length - 1;
	    }
	}

	static class SegmentTree {

	    private Node[] heap;
	    private long[] array;
	    private int size;

	    public SegmentTree(long[] array) {
	        this.array = Arrays.copyOf(array, array.length);
	        //The max size of this array is about 2 * 2 ^ log2(n) + 1
	        size = (int) (2 * Math.pow(2.0, Math.floor((Math.log((double) array.length) / Math.log(2.0)) + 1)));
	        heap = new Node[size];
	        build(1, 0, array.length);
	    }

	    public int size() {
	        return array.length;
	    }

	    //Initialize the Nodes of the Segment tree
	    private void build(int v, int from, int size) {
	        heap[v] = new Node();
	        heap[v].from = from;
	        heap[v].to = from + size - 1;

	        if (size == 1) {
	            heap[v].sum = array[from];
	            heap[v].min = array[from];
	            heap[v].max = array[from];
	        } else {
	            //Build childs
	            build(2 * v, from, size / 2);
	            build(2 * v + 1, from + size / 2, size - size / 2);

	            heap[v].sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            //min = min of the children
	            heap[v].min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            heap[v].max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    public long rsq(int from, int to) {
	        return rsq(1, from, to);
	    }

	    private long rsq(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Sum without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return (to - from + 1) * n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].sum;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftSum = rsq(2 * v, from, to);
	            long rightSum = rsq(2 * v + 1, from, to);

	            return leftSum + rightSum;
	        }

	        return 0;
	    }

	    public long rMinQ(int from, int to) {
	        return rMinQ(1, from, to);
	    }

	    private long rMinQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].min;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMin = rMinQ(2 * v, from, to);
	            long rightMin = rMinQ(2 * v + 1, from, to);

	            return Math.min(leftMin, rightMin);
	        }

	        return Integer.MAX_VALUE;
	    }

	    public long rMaxQ(int from, int to) {
	        return rMaxQ(1, from, to);
	    }

	    private long rMaxQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].max;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMax = rMaxQ(2 * v, from, to);
	            long rightMax = rMaxQ(2 * v + 1, from, to);

	            return Math.max(leftMax, rightMax);
	        }

	        return Integer.MIN_VALUE;
	    }

	    public void update(int from, int to, long value) {
	        update(1, from, to, value);
	    }

	    private void update(int v, int from, int to, long value) {

	        //The Node of the heap tree represents a range of the array with bounds: [n.from, n.to]
	        Node n = heap[v];

	        if (contains(from, to, n.from, n.to)) {
	            change(n, value);
	        }

	        if (n.size() == 1) return;

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);

	            update(2 * v, from, to, value);
	            update(2 * v + 1, from, to, value);

	            n.sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            n.min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            n.max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    //Propagate temporal values to children
	    private void propagate(int v) {
	        Node n = heap[v];

	        if (n.pendingVal != null) {
	            change(heap[2 * v], n.pendingVal);
	            change(heap[2 * v + 1], n.pendingVal);
	            n.pendingVal = null; //unset the pending propagation value
	        }
	    }

	    //Save the temporal values that will be propagated lazily
	    private void change(Node n, long value) {
	        n.pendingVal = value;
	        n.sum = n.size() * value;
	        n.min = value;
	        n.max = value;
	        array[n.from] = value;
	    }

	    //Test if the range1 contains range2
	    private boolean contains(int from1, int to1, int from2, int to2) {
	        return from2 >= from1 && to2 <= to1;
	    }

	    //check inclusive intersection, test if range1[from1, to1] intersects range2[from2, to2]
	    private boolean intersects(int from1, int to1, int from2, int to2) {
	        return from1 <= from2 && to1 >= from2   //  (.[..)..] or (.[...]..)
	                || from1 >= from2 && from1 <= to2; // [.(..]..) or [..(..)..
	    }

	    //The Node class represents a partition range of the array.
	    static class Node {
	        long sum;
	        long min;
	        long max;
	        //Here we store the value that will be propagated lazily
	        Long pendingVal = null;
	        int from;
	        int to;

	        int size() {
	            return to - from + 1;
	        }
	    }
	}

	@SuppressWarnings("serial")
	static class CountMap<T> extends TreeMap<T, Integer>{

		CountMap() {
		}

		CountMap(T[] arr) {
			this.putCM(arr);
		}

		public Integer putCM(T key) {
			return super.put(key, super.getOrDefault(key, 0) + 1);
		}

		public Integer removeCM(T key) {
			int count = super.getOrDefault(key, -1);
			if (count == -1) return -1;
			if (count == 1)
				return super.remove(key);
			else
				return super.put(key, count - 1);
		}

		public Integer getCM(T key) {
			return super.getOrDefault(key, 0);
		}

		public void putCM(T[] arr) {
			for (T l : arr)
				this.putCM(l);
		}
	}

	static long dioGCD(long a, long b, long[] x0, long[] y0) {
	    if (b == 0) {
	        x0[0] = 1;
	        y0[0] = 0;
	        return a;
	    }
	    long[] x1 = new long[1], y1 = new long[1];
	    long d = dioGCD(b, a % b, x1, y1);
	    x0[0] = y1[0];
	    y0[0] = x1[0] - y1[0] * (a / b);
	    return d;
	}

	static boolean diophantine(long a, long b, long c, long[] x0, long[] y0, long[] g) {
	    g[0] = dioGCD(Math.abs(a), Math.abs(b), x0, y0);
	    if (c % g[0] > 0) {
	        return false;
	    }

	    x0[0] *= c / g[0];
	    y0[0] *= c / g[0];
	    if (a < 0) x0[0] = -x0[0];
	    if (b < 0) y0[0] = -y0[0];
	    return true;
	}

	static long[][] prod(long[][] mat1, long[][] mat2) {
		int n = mat1.length;
		long[][] prod = new long[n][n];

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				// determining prod[i][j]
				// it will be the dot product of mat1[i][] and mat2[][i]
				for (int k = 0; k < n; k++)
					prod[i][j] += mat1[i][k] * mat2[k][j];
		return prod;
	}
	static long[][] matExpo(long[][] mat, long power) {
		int n = mat.length;
		long[][] ans = new long[n][n];

		if (power == 0)
			return null;

		if (power == 1)
			return mat;

		long[][] half = matExpo(mat, power / 2);
		ans = prod(half, half);

		if (power % 2 == 1) {
			ans = prod(ans, mat);
		}

		return ans;
	}

	static int KMPNumOcc(char[] text, char[] pat) {
		int n = text.length;
		int m = pat.length;

		char[] patPlusText = new char[n + m + 1];
		for (int i = 0; i < m; i++)
			patPlusText[i] = pat[i];
		patPlusText[m] = '^'; 		// Seperator
		for (int i = 0; i < n; i++)
			patPlusText[m + i] = text[i];

		int[] fullPi = piCalcKMP(patPlusText);
		int answer = 0;
		for (int i = 0; i < n + m + 1; i++)
			if (fullPi[i] == m)
				answer++;
		return answer;
	}
	static int[] piCalcKMP(char[] s) {
		int n = s.length;
		int[] pi = new int[n];
		for (int i = 1; i < n; i++) {
			int j = pi[i - 1];
			while (j > 0 && s[i] != s[j])
				j = pi[j - 1];
			if (s[i] == s[j])
				j++;
			pi[i] = j;
		}
		return pi;
	}
	static long hash(long key) {
        long h = Long.hashCode(key);
        h ^= (h >>> 20) ^ (h >>> 12) ^ (h >>> 7) ^ (h >>> 4);
        return h & (gigamod-1);
    }

	static int mapTo1D(int row, int col, int n, int m) {
		// Maps elements in a 2D matrix serially to elements in
		// a 1D array.
		return row * m + col;
	}
	static int[] mapTo2D(int idx, int n, int m) {
		// Inverse of what the one above does.
		int[] rnc = new int[2];
		rnc[0] = idx / m;
		rnc[1] = idx % m;
		return rnc;
	}

	static boolean[] primeGenerator(int upto) {
		// Sieve of Eratosthenes:
		isPrime = new boolean[upto + 1];
		smallestFactorOf = new int[upto + 1];
		Arrays.fill(smallestFactorOf, 1);
		Arrays.fill(isPrime, true);
		isPrime[1] = isPrime[0] = false;

		for (long i = 2; i < upto + 1; i++)
			if (isPrime[(int) i]) {
				smallestFactorOf[(int) i] = (int) i;
				// Mark all the multiples greater than or equal
				// to the square of i to be false.
				for (long j = i; j * i < upto + 1; j++) {
					if (isPrime[(int) j * (int) i]) {
						isPrime[(int) j * (int) i] = false;
						smallestFactorOf[(int) j * (int) i] = (int) i;
					}
				}
			}
		return isPrime;
	}
	static HashMap<Integer, Integer> smolNumPrimeFactorization(int num) {
		if (smallestFactorOf == null)
			primeGenerator(num + 1);
		HashMap<Integer, Integer> fnps = new HashMap<>();
		while (num != 1) {
			fnps.put(smallestFactorOf[num], fnps.getOrDefault(smallestFactorOf[num], 0) + 1);
			num /= smallestFactorOf[num];
		}
		return fnps;
	}
	static HashMap<Long, Integer> primeFactorization(long num) {
		// Returns map of factor and its power in the number.
		HashMap<Long, Integer> map = new HashMap<>();
		while (num % 2 == 0) {
			num /= 2;
			Integer pwrCnt = map.get(2L);
			map.put(2L, pwrCnt != null ? pwrCnt + 1 : 1);
		}
		for (long i = 3; i * i <= num; i += 2) {
			while (num % i == 0) {
				num /= i;
				Integer pwrCnt = map.get(i);
				map.put(i, pwrCnt != null ? pwrCnt + 1 : 1);
			}
		}
		// If the number is prime, we have to add it to the
		// map.
		if (num != 1)
			map.put(num, 1);
		return map;
	}
	static HashSet<Long> divisors(long num) {
		HashSet<Long> divisors = new HashSet<Long>();
		divisors.add(1L);
		divisors.add(num);
		for (long i = 2; i * i <= num; i++) {
			if (num % i == 0) {
				divisors.add(num/i);
				divisors.add(i);
			}
		}
		return divisors;
	}
	static void coprimeGenerator(int m, int n, ArrayList<Point> coprimes, int limit, int numCoprimes) {
		if (m > limit) return;
		if (m <= limit && n <= limit)
			coprimes.add(new Point(m, n));
		if (coprimes.size() > numCoprimes) return;
		coprimeGenerator(2 * m - n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(2 * m + n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(m + 2 * n, n, coprimes, limit, numCoprimes);
	}

	static int bsearch(int[] arr, int val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi, boolean sMode) {
		// Returns the index of the last element
		// smaller than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}
	static int bsearch(int[] arr, long val, int lo, int hi, boolean sMode) {
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}

	static long nCr(long n, long r, long[] fac) { long p = gigamod; if (r == 0) return 1; return (fac[(int)n] * modInverse(fac[(int)r], p) % p * modInverse(fac[(int)n - (int)r], p) % p) % p; }
	static long modInverse(long n, long p) { return power(n, p - 2, p); }
	static long modDiv(long a, long b){return mod(a * power(b, gigamod - 2, gigamod));}
	static long power(long x, long y, long p) { long res = 1; x = x % p; while (y > 0) { if ((y & 1)==1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
	static int logk(long n, long k) { return (int)(Math.log(n) / Math.log(k)); }
	static long gcd(long a, long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static long gcd(long[] arr) { int n = arr.length; long gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static int gcd(int[] arr) { int n = arr.length; int gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static long lcm(long[] arr) { long lcm = arr[0]; int n = arr.length; for (int i = 1; i < n; i++) { lcm = (lcm * arr[i]) / gcd(lcm, arr[i]); } return lcm; } static long lcm(long a, long b) { return (a * b)/gcd(a, b); } static boolean less(int a, int b) { return a < b ? true : false; } static boolean isSorted(int[] a) { for (int i = 1; i < a.length; i++) { if (less(a[i], a[i - 1])) return false; } return true; } static boolean isSorted(long[] a) { for (int i = 1; i < a.length; i++) { if (a[i] < a[i - 1]) return false; } return true; } static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(long[] a, int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(double[] a, int i, int j) { double temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(char[] a, int i, int j) { char temp = a[i]; a[i] = a[j]; a[j] = temp; }
	static void sort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void reverseSort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverse(char[] arr) { int n = arr.length; for (int i = 0; i < n / 2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); }
	static void shuffleArray(long[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { long tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } } static void shuffleArray(int[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { int tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(double[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { double tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(char[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { char tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static boolean isPrime(long n) {if (n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
	static String toString(int[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(boolean[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(long[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(char[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+"");return sb.toString();}
	static String toString(int[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(long[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++) {sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(double[][] dp){StringBuilder sb=new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(char[][] dp){StringBuilder sb = new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+"");}sb.append('\n');}return sb.toString();}
	static long mod(long a, long m){return(a%m+1000000L*m)%m;}
	static long mod(long num){return(num%gigamod+gigamod)%gigamod;}
}

// NOTES:
// ASCII VALUE OF 'A': 65
// ASCII VALUE OF 'a': 97
// Range of long: 9 * 10^18
// ASCII VALUE OF '0': 48
// Primes upto 'n' can be given by (n / (logn)).

import java.util.*;
import java.io.*;
public class Solution {

    public static Integer[][][] dp;

    public static int f(int p, int x, int lastTwoDigit, int len, String str) {
        if (p == len) {
            if (lastTwoDigit == 0 || lastTwoDigit == 25 || lastTwoDigit == 50 || lastTwoDigit == 75) {
                return 1;
            }
            return 0;
        }
        if (dp[p][x][lastTwoDigit] != null) {
            return dp[p][x][lastTwoDigit];
        }
        int ans = 0;
        if (str.charAt(p) == 'X') {
            if (x != 10) {
                ans = f(p + 1, x, (lastTwoDigit % 10) * 10 + x, len, str);
            } else {
                for (int i = (p == 0 ? 1 : 0); i < 10; i++) {
                    ans += f(p + 1, i, (lastTwoDigit % 10) * 10 + i, len, str);
                }
            }
        } else if (str.charAt(p) == '_') {
            for (int i = (p == 0 ? 1 : 0); i < 10; i++) {
                ans += f(p + 1, x, (lastTwoDigit % 10) * 10 + i, len, str);
            }
        } else {
            ans += f(p + 1, x, (lastTwoDigit % 10) * 10 + (str.charAt(p) - 48), len, str);
        }
        return dp[p][x][lastTwoDigit] = ans;
    }

    public static void solve(InputReader in, PrintWriter out) {
        String str = in.next();
        int len = str.length();
        if (len == 1) {
            if (str.charAt(0) == '0' || str.charAt(0) == '_' || str.charAt(0) == 'X') {
                out.println(1);
            } else {
                out.println(0);
            }
        } else if (str.charAt(0) == '0') {
            out.println(0);
        } else {
            dp = new Integer[len][11][100];
            out.println(f(0, 10, 0, len, str));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

    }
}

import java.util.*;
import java.io.*;
public class DivisibleByTwentyFive {
    public static void main(String[] args) throws IOException {
        Reader in = new Reader();
        PrintWriter out = new PrintWriter(System.out);

        String s = in.next();
        int end = 1;
        for (int i = 0; i < s.length(); i++) {
           end *= 10;
        }
        int res = 0;
        for (int i = 0; i < end; i += 25) {
            if (match(s, i)) {
                res++;
            }
        }
        out.println(res);

        out.close();
    }
    public static boolean match(String s, int n) {
        int x = -1;
        for (int i = s.length() - 1; i >= 0; i--) {
            int d = n % 10;
            if (s.charAt(i) == 'X') {
                if (x >= 0 && x != d) {
                    return false;
                }
                x = d;
            } else if (s.charAt(i) != '_') {
                if (s.charAt(i) - '0' != d) {
                    return false;
                }
            }
            if (s.length() > 1 && i == 0 && d == 0) {
                return false;
            }
            n /= 10;
        }
        return true;
    }
    static class Reader {
        BufferedReader in;
        StringTokenizer st;
        public Reader() {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }
        public String nextLine() throws IOException {
            st = new StringTokenizer("");
            return in.readLine();
        }
        public String next() throws IOException {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
    public static void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int i : arr) {
            list.add(i);
        }
        Collections.sort(list);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = list.get(i);
        }
    }
}

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

public class code{
  public static class Pair{
    int a;
    int b;
    Pair(int i,int j){
      a=i;
      b=j;
    }
  }

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

  public static void shuffle(int a[], int n)
  {
      for (int i = 0; i < n; i++) {

          // getting the random index
          int t = (int)Math.random() * a.length;

          // and swapping values a random index
          // with the current index
          int x = a[t];
          a[t] = a[i];
          a[i] = x;
      }
  }

  public static PrintWriter out = new PrintWriter(System.out);
  //@SuppressWarnings("unchecked")
  public static void main(String[] arg) throws IOException{
      //Reader in=new Reader();

      //PrintWriter out = new PrintWriter(System.out);
      //Scanner in = new Scanner(System.in);
      FastScanner in=new FastScanner();
      int t=1;

      while(t-- > 0){
        String s=in.next();
        if(s.equals("0") || s.equals("X") || s.equals("_")){
          out.println(1);
          continue;
        }
        char[] arr=s.toCharArray();

        int low=(int)Math.pow(10,s.length()-1);
        int high=(int)Math.pow(10,s.length())-25;
        while(low%25!=0) low++;
        int res=0;

        for(;low<=high;low+=25){
          String s1=Integer.toString(low);
          char[] c=s1.toCharArray();
          int count=1;
          char x='#';
          for(int i=0;i<arr.length;i++){
            if(arr[i]=='_') continue;
            if(arr[i]=='X'){
              if(x=='#') x=c[i];
              if(x!=c[i]){
                count=0;
                break;
              }
            }
            else if(arr[i]!=c[i]){
              count=0;
              break;
            }
          }
          res+=count;
        }

        out.println(res);
      }

      out.flush();
  }

}

class Fenwick{
  int[] bit;
  public Fenwick(int n){
    bit=new int[n];
    //int sum=0;
  }

  public void update(int index,int val){
    index++;
    for(;index<bit.length;index += index&(-index)) bit[index]+=val;
  }

  public int presum(int index){
    int sum=0;
    for(;index>0;index-=index&(-index)) sum+=bit[index];
    return sum;
  }

  public int sum(int l,int r){
    return presum(r+1)-presum(l);
  }
}

class FastScanner {

  private int BS = 1 << 16;
  private char NC = (char) 0;
  private byte[] buf = new byte[BS];
  private int bId = 0, size = 0;
  private char c = NC;
  private double cnt = 1;
  private BufferedInputStream in;

  public FastScanner() {
      in = new BufferedInputStream(System.in, BS);
  }

  public FastScanner(String s) {
      try {
          in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
      } catch (Exception e) {
          in = new BufferedInputStream(System.in, BS);
      }
  }

  private char getChar() {
      while (bId == size) {
          try {
              size = in.read(buf);
          } catch (Exception e) {
              return NC;
          }
          if (size == -1) return NC;
          bId = 0;
      }
      return (char) buf[bId++];
  }

  public int nextInt() {
      return (int) nextLong();
  }

  public int[] nextInts(int N) {
      int[] res = new int[N];
      for (int i = 0; i < N; i++) {
          res[i] = (int) nextLong();
      }
      return res;
  }

  public long[] nextLongs(int N) {
      long[] res = new long[N];
      for (int i = 0; i < N; i++) {
          res[i] = nextLong();
      }
      return res;
  }

  public long nextLong() {
      cnt = 1;
      boolean neg = false;
      if (c == NC) c = getChar();
      for (; (c < '0' || c > '9'); c = getChar()) {
          if (c == '-') neg = true;
      }
      long res = 0;
      for (; c >= '0' && c <= '9'; c = getChar()) {
          res = (res << 3) + (res << 1) + c - '0';
          cnt *= 10;
      }
      return neg ? -res : res;
  }

  public double nextDouble() {
      double cur = nextLong();
      return c != '.' ? cur : cur + nextLong() / cnt;
  }

  public double[] nextDoubles(int N) {
      double[] res = new double[N];
      for (int i = 0; i < N; i++) {
          res[i] = nextDouble();
      }
      return res;
  }

  public String next() {
      StringBuilder res = new StringBuilder();
      while (c <= 32) c = getChar();
      while (c > 32) {
          res.append(c);
          c = getChar();
      }
      return res.toString();
  }

  public String nextLine() {
      StringBuilder res = new StringBuilder();
      while (c <= 32) c = getChar();
      while (c != '\n') {
          res.append(c);
          c = getChar();
      }
      return res.toString();
  }

  public boolean hasNext() {
      if (c > 32) return true;
      while (true) {
          c = getChar();
          if (c == NC) return false;
          else if (c > 32) return true;
      }
  }
}

// OM NAMAH SHIVAY
// Stay strong. Be brave. Always belief.
// NOT WITH MY GIO

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

public class Vaibhav {

    static boolean prime[];

    static class Pair implements Comparable<Pair> {
        int a;
        int b;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair o) {

            return (int)(this.a - o.a);
            //else return this.b - o.b;
        }
    }

    static long power(long x, long y, long p) {
        if (y == 0) return 1;
        if (x == 0) return 0;
        long res = 1l;
        x = x % p;
        while (y > 0) {
            if (y % 2 == 1) res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }

    static void sort(long[] a) {
        ArrayList<Long> l = new ArrayList<>();
        for (long i : a) l.add(i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long[] readlongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

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

    static void sieveOfEratosthenes(int n) {
        prime = new boolean[n + 1];
        for (int i = 0; i <= n; i++) prime[i] = true;
        for (int p = 2; p * p <= n; p++) {
            if (prime[p] == true) {
                for (int i = p * p; i <= n; i += p) prime[i] = false;
            }
        }
    }

    public static int log2(int x) {
        return (int) (Math.log(x) / Math.log(2));
    }

    static long binomialCoeff(long n, long r) {
        if (r > n) return 0l;
        long m = 1000000007l;
        long inv[] = new long[(int) r + 1];
        inv[0] = 1;
        if (r + 1 >= 2) inv[1] = 1;
        for (int i = 2; i <= r; i++) {
            inv[i] = m - (m / i) * inv[(int) (m % i)] % m;
        }
        long ans = 1l;
        for (int i = 2; i <= r; i++) {
            ans = (int) (((ans % m) * (inv[i] % m)) % m);
        }
        for (int i = (int) n; i >= (n - r + 1); i--) {
            ans = (int) (((ans % m) * (i % m)) % m);
        }
        return ans;
    }

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

    static long[] facts=new long[3_000_00];
    //don't care about your feelings

    static long mul(long a, long b) {
        return a*b%mod;
    }

    static long add(long a, long b) {
        return (a+b)%mod;
    }

    /*static void precomp() {
        facts[0]=1;
        for (int i=1; i<facts.length; i++) facts[i]=mul(facts[i-1], i);
    }

    static long exp(long base, long pow) {
        if (pow==0) return 1;
        long half=exp(base, pow/2);
        if (pow%2==0) return mul(half, half);
        return mul(half, mul(half, base));
    }

    static long modInv(long x) {
        return exp(x, mod-2);
    }

    static long nCk(int n, int k) {
        if(n<k) return 0;
        return mul(facts[n], mul(modInv(facts[k]), modInv(facts[n-k])));
    }
*/

    static BigInteger bi(String str) {
        return new BigInteger(str);
    }

    // Author - vaibhav_1710
    static FastScanner fs = null;
    static long mod = 1_000_000_007;
    static int[][] dirs = {{0, -1},
            {-1, 0},
            {0, 1},
            {1, 0},
    };

    static int pk[];
    public static void main(String[] args) {
        fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;

        outer:
        while (t-- > 0) {
            String s = fs.next();
            int len = s.length();
            int max = (int)Math.pow(10,len)-1;
            int min = (int)Math.pow(10,len-1);
            if(min==1)min--;
            if(s.charAt(0)=='0' && s.length()>1){
                out.println("0");
                continue outer;
            }
            long ans=0;
            for(int i=min;i<=max;i++){
                if(i%25==0) {
                    ans += (can(i, s) == true ? 1 : 0);
                }
            }
            out.println(ans);
        }
        out.close();
    }

    public static boolean can(int v,String s){
        String ss = Integer.toString(v);
        char king_me = '?';
        for(int i=0;i<ss.length();i++){
         if(s.charAt(i)!='_' && s.charAt(i)!='X'){
             if(s.charAt(i)!=ss.charAt(i)){
                 return false;
             }
         }else if(s.charAt(i)=='_') {
             continue;
         }else if(s.charAt(i)=='X'){
             if(king_me!='?' && ss.charAt(i)!=king_me){
                 return false;
             }else if(king_me=='?'){
                 king_me = ss.charAt(i);
             }else{
                 continue;
             }
         }
        }
            return true;
    }

}

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

public class Main {
    private static int solve(char[] s, char x) {
        for(int i = 0; i < s.length; i++) {
            if(s[i] == 'X') {
                s[i] = x;
            }
        }
        if(s[0] == '0') {
            return 0;
        }
        int ans = 1;
        boolean first = true;
        for(int i = 0; i < s.length; i++) {
            if(s[i] == '_') {
                ans *= i == 0 ? 9 : 10;
            } else if(s[i] == 'X' && first) {
                ans *= i == 0 ? 9 : 10;
                first = false;
            }
        }
        return ans;
    }
    private static boolean canReplace(char[] s, char a, char b) {
        if(s[s.length-2] >= '0' && s[s.length-2] <= '9' && s[s.length-2] != a) {
            return false;
        }
        if(s[s.length-1] >= '0' && s[s.length-1] <= '9' && s[s.length-1] != b) {
            return false;
        }
        if(s[s.length-2] == 'X' && s[s.length-1] == 'X' && a != b) {
            return false;
        }
        return true;
    }
    public static void main(String[] args) throws IOException{
        //BufferedReader f = new BufferedReader(new FileReader("cowjump.in"));
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("cowjump.out")));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        char[] s = f.readLine().toCharArray();
        if(s.length < 2) {
            out.println(s[0] == '0' || s[0] == '_' || s[0] == 'X' ? 1 : 0);
        } else {
            int ans = 0;
            if(canReplace(s, '0', '0')) {
                char[] t = s.clone();
                t[t.length-2] = '0';
                t[t.length-1] = '0';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            if(canReplace(s, '2', '5')) {
                char[] t = s.clone();
                t[t.length-2] = '2';
                t[t.length-1] = '5';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            if(canReplace(s, '5', '0')) {
                char[] t = s.clone();
                t[t.length-2] = '5';
                t[t.length-1] = '0';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            if(canReplace(s, '7', '5')) {
                char[] t = s.clone();
                t[t.length-2] = '7';
                t[t.length-1] = '5';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            out.println(ans);
        }
        f.close();
        out.close();
    }
}

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

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;

            if(n == 1){
                if(str[0] == '0' && str[0] == '_' || str[0] == 'X' || str[0] == '1'){
                    ans.append(1+"\n");continue;
                }
            }
            long cnt=0;
            boolean Xp =false;
            // boolean allZero=true;
            // for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(n>2)
        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        // System.out.println(cnt);
        return cnt;
    }
}

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

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;

            if(n == 1){
                if(str[0] == '_' || str[0] == 'X' || str[0] == '1'){
                    ans.append(1+"\n");continue;
                }
            }
            long cnt=0;
            boolean Xp =false;
            // boolean allZero=true;
            // for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(n>2)
        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        // System.out.println(cnt);
        return cnt;
    }
}

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

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;

            if(n == 1){
                if(str[0] == '_' || str[0] == 'X' || str[0] == '1'){
                    ans.append(1+"\n");continue;
                }
            }
            long cnt=0;
            boolean Xp =false;
            boolean allZero=true;
            for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(allZero) ++cnt;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(n>2)
        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        // System.out.println(cnt);
        return cnt;
    }
}

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

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;

            if(n == 1){
                if(str[0] == '_' || str[0] == 'X' || str[0] == '1'){
                    ans.append(1+"\n");continue;
                }
            }
            long cnt=0;
            boolean Xp =false;
            boolean allZero=true;
            for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(allZero) ++cnt;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        return cnt;
    }
}

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

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;
            long cnt=0;
            boolean Xp =false;
            boolean allZero=true;
            for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(allZero) ++cnt;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        return cnt;
    }
}

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            String s=input.next();
            if(s.length()==1)
            {
                if(s.charAt(0)=='0' || s.charAt(0)=='_' || s.charAt(0)=='X') out.println(1);
                else out.println(0);
            }
            else
            {
                int f=0;
                for(int i=0;i<s.length();i++)
                {
                    if(s.charAt(i)=='X')
                    {
                        f=1;
                        break;
                    }
                }
                if(f==0)
                {
                    out.println(fun(s));
                }
                else
                {
                    int sum=0;
                    for(int i=0;i<10;i++)
                    {
                        char ch[]=s.toCharArray();
                        for(int j=0;j<s.length();j++)
                        {
                            if(ch[j]=='X')
                            {
                                ch[j]=(char)(i+'0');
                            }
                        }
                        String str=String.copyValueOf(ch);
                        sum+=fun(str);
                    }
                    out.println(sum);
                }
            }
        }
        out.close();
    }
    public static int fun(String s)
    {
        int n=s.length();
        int p=0;
        if(s.charAt(0)!='0')p=1;
        for(int i=0;i<n-2;i++)
        {
            if(s.charAt(i)=='_')
            {
                if(i==0) p*=9;
                else p*=10;
            }
        }
        int p1=0;
        if(s.charAt(n-1)=='_' && s.charAt(n-2)=='_')
        {
            p1=4;
        }
        else if(s.charAt(n-1)=='_')
        {
            if(s.charAt(n-2)=='0' || s.charAt(n-2)=='5' || s.charAt(n-2)=='2' || s.charAt(n-2)=='7') p1=1;
        }
        else if(s.charAt(n-2)=='_')
        {
            if(s.charAt(n-1)=='0') p1=2;
            else if(s.charAt(n-1)=='5') p1=2;
        }
        else
        {
            int val=Integer.valueOf(s.substring(n-2));
            if(val%25==0) p1=1;
        }
        int pro=p*p1;
        return pro;
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                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());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            String s=input.next();
            if(s.length()==1)
            {
                if(s.charAt(0)=='0' || s.charAt(0)=='_') out.println(1);
                else out.println(0);
            }
            else
            {
                int f=0;
                for(int i=0;i<s.length();i++)
                {
                    if(s.charAt(i)=='X')
                    {
                        f=1;
                        break;
                    }
                }
                if(f==0)
                {
                    out.println(fun(s));
                }
                else
                {
                    int sum=0;
                    for(int i=0;i<10;i++)
                    {
                        char ch[]=s.toCharArray();
                        for(int j=0;j<s.length();j++)
                        {
                            if(ch[j]=='X')
                            {
                                ch[j]=(char)(i+'0');
                            }
                        }
                        String str=String.copyValueOf(ch);
                        sum+=fun(str);
                    }
                    out.println(sum);
                }
            }
        }
        out.close();
    }
    public static int fun(String s)
    {
        int n=s.length();
        int p=0;
        if(s.charAt(0)!='0')p=1;
        for(int i=0;i<n-2;i++)
        {
            if(s.charAt(i)=='_')
            {
                if(i==0) p*=9;
                else p*=10;
            }
        }
        int p1=0;
        if(s.charAt(n-1)=='_' && s.charAt(n-2)=='_')
        {
            p1=4;
        }
        else if(s.charAt(n-1)=='_')
        {
            if(s.charAt(n-2)=='0' || s.charAt(n-2)=='5' || s.charAt(n-2)=='2' || s.charAt(n-2)=='7') p1=1;
        }
        else if(s.charAt(n-2)=='_')
        {
            if(s.charAt(n-1)=='0') p1=2;
            else if(s.charAt(n-1)=='5') p1=2;
        }
        else
        {
            int val=Integer.valueOf(s.substring(n-2));
            if(val%25==0) p1=1;
        }
        int pro=p*p1;
        return pro;
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                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());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            String s=input.next();
            if(s.length()==1)
            {
                if(s.charAt(0)=='0') out.println(1);
                else out.println(0);
            }
            else
            {
                int f=0;
                for(int i=0;i<s.length();i++)
                {
                    if(s.charAt(i)=='X')
                    {
                        f=1;
                        break;
                    }
                }
                if(f==0)
                {
                    out.println(fun(s));
                }
                else
                {
                    int sum=0;
                    for(int i=0;i<10;i++)
                    {
                        char ch[]=s.toCharArray();
                        for(int j=0;j<s.length();j++)
                        {
                            if(ch[j]=='X')
                            {
                                ch[j]=(char)(i+'0');
                            }
                        }
                        String str=String.copyValueOf(ch);
                        sum+=fun(str);
                    }
                    out.println(sum);
                }
            }
        }
        out.close();
    }
    public static int fun(String s)
    {
        int n=s.length();
        int p=0;
        if(s.charAt(0)!='0')p=1;
        for(int i=0;i<n-2;i++)
        {
            if(s.charAt(i)=='_')
            {
                if(i==0) p*=9;
                else p*=10;
            }
        }
        int p1=0;
        if(s.charAt(n-1)=='_' && s.charAt(n-2)=='_')
        {
            p1=4;
        }
        else if(s.charAt(n-1)=='_')
        {
            if(s.charAt(n-2)=='0' || s.charAt(n-2)=='5' || s.charAt(n-2)=='2' || s.charAt(n-2)=='7') p1=1;
        }
        else if(s.charAt(n-2)=='_')
        {
            if(s.charAt(n-1)=='0') p1=2;
            else if(s.charAt(n-1)=='5') p1=2;
        }
        else
        {
            int val=Integer.valueOf(s.substring(n-2));
            if(val%25==0) p1=1;
        }
        int pro=p*p1;
        return pro;
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                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());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            String s=input.next();
            if(s.length()==1)
            {
                if(s.charAt(0)=='0') out.println(1);
                else out.println(0);
            }
            else
            {
                int f=0;
                for(int i=0;i<s.length();i++)
                {
                    if(s.charAt(i)=='X')
                    {
                        f=1;
                        break;
                    }
                }
                if(f==0)
                {
                    out.println(fun(s));
                }
                else
                {
                    int sum=0;
                    for(int i=0;i<10;i++)
                    {
                        char ch[]=s.toCharArray();
                        for(int j=0;j<s.length();j++)
                        {
                            if(ch[j]=='X')
                            {
                                ch[j]=(char)(i+'0');
                            }
                        }
                        String str=String.copyValueOf(ch);
                        sum+=fun(str);
                    }
                    out.println(sum);
                }
            }
        }
        out.close();
    }
    public static int fun(String s)
    {
        int n=s.length();
        int p=0;
        if(s.charAt(0)!='0')p=1;
        for(int i=0;i<n-2;i++)
        {
            if(s.charAt(i)=='_')
            {
                if(i==0) p*=9;
                else p*=10;
            }
        }
        int p1=0;
        if(s.charAt(n-1)=='_' && s.charAt(n-2)=='_')
        {
            p1=4;
        }
        else if(s.charAt(n-1)=='_')
        {
            if(s.charAt(n-2)=='0' || s.charAt(n-2)=='5' || s.charAt(n-2)=='2' || s.charAt(n-2)=='7') p1=1;
        }
        else if(s.charAt(n-2)=='_')
        {
            if(s.charAt(n-1)=='0') p1=2;
            else if(s.charAt(n-2)=='5') p1=2;
        }
        else
        {
            int val=Integer.valueOf(s.substring(n-2));
            if(val%25==0) p1=1;
        }
        int pro=p*p1;
        return pro;
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                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());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

// CFPS -> CodeForcesProblemSet
public final class CFPS {
	static FastReader fr = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);
	static final int gigamod = 1000000007;
	static int t = 1;
	static double epsilon = 0.00000001;
	static boolean[] isPrime;
	static int[] smallestFactorOf;

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		OUTER:
		for (int tc = 0; tc < t; tc++) {

			char[] sOG = fr.next().toCharArray();
			int n = sOG.length;

			if (n == 1) {
				if (sOG[0] == '0' || sOG[0] == '_' || sOG[0] == 'X')
					out.println(1);
				else
					out.println(0);
				continue OUTER;
			}

			// 00, 25, 50, 75 are the 4 universes
			// we'll count for all of them independently

			int answer = 0;

			{
				// 00
				// non _ and nonzero == death is true
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= (s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '0');

				if (!shit) {

					if (s[n - 1] == 'X' || s[n - 2] == 'X')
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';
					s[n - 1] = '0';
					s[n - 2] = '0';

					// now, we will iterate over all prefixes and
					// for each prefix, check whether it is possible to transform
					// s[] into (prefix + "00")

					// prefix has to be atmost 6 digits

					answer += check("00".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "00").toCharArray();
						answer += check(tgt, s);
					}

				}
			}

			{
				// 25
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '2';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 2
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '2';
					}

					s[n - 1] = '5';
					s[n - 2] = '2';

					answer += check("25".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "25").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 50
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '5';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 0
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';

					} else if (s[n - 2] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';
					}

					s[n - 1] = '0';
					s[n - 2] = '5';

					answer += check("50".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "50").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 75
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '7';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 7
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '7';
					}

					s[n - 1] = '5';
					s[n - 2] = '7';

					answer += check("75".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "75").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			out.println(answer);
		}
		out.close();
	}

	static int check(char[] tgt, char[] src) {
		int n = tgt.length;
		if (src.length != n) return 0;

		// 'X' check
		char xDig = 0;
		for (int i = 0; i < n; i++)
			if (src[i] == 'X') {
				if (xDig == 0) {
					xDig = tgt[i];
				} else {
					if (tgt[i] != xDig) return 0;
				}
			}
		// assert all 'X's have same digit;

		// no leading zeroes plz
		if (tgt[0] == '0') return 0;

		// all non _s have to be equal
		for (int i = 0; i < n; i++)
			if (src[i] != '_' && tgt[i] != src[i]) return 0;

		return 1;
	}

	static class Edge implements Comparable<Edge> {
		int from, to;
		long weight;
		int id;
		// int hash;

		Edge(int fro, int t, long weigh, int i) {
			from = fro;
			to = t;
			weight = weigh;
			id = i;
			// hash = Objects.hash(from, to, weight);
		}

		/*public int hashCode() {
			return hash;
		}*/

		public int compareTo(Edge that) {
			return Long.compare(this.id, that.id);
		}
	}

	public static long[][] sparseTable(long[] a)
	{
		int n = a.length;
		int b = 32-Integer.numberOfLeadingZeros(n);
		long[][] ret = new long[b][];
		for(int i = 0, l = 1;i < b;i++, l*=2) {
			if(i == 0) {
				ret[i] = a;
			}else {
				ret[i] = new long[n-l+1];
				for(int j = 0;j < n-l+1;j++) {
					ret[i][j] = Math.min(ret[i-1][j], ret[i-1][j+l/2]);
				}
			}
		}
		return ret;
	}

	public static long sparseRMQ(long[][] table, int l, int r)
	{
		// [a,b)
		assert l <= r;
		if(l >= r)return Integer.MAX_VALUE;
		// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
		int t = 31-Integer.numberOfLeadingZeros(r-l);
		return Math.min(table[t][l], table[t][r-(1<<t)]);
	}

	static class Point implements Comparable<Point> {
		long x;
		long y;
		long z;
		long id;
		// private int hashCode;

		Point() {
			x = z = y = 0;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(Point p) {
			this.x = p.x;
			this.y = p.y;
			this.z = p.z;
			this.id = p.id;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(long x, long y, long z, long id) {
			this.x = x;
			this.y = y;
			this.z = z;
			this.id = id;
			// this.hashCode = Objects.hash(x, y, id);
		}

		Point(long a, long b) {
			this.x = a;
			this.y = b;
			this.z = 0;
			// this.hashCode = Objects.hash(a, b);
		}

		Point(long x, long y, long id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}

		@Override
		public int compareTo(Point o) {
			if (this.x < o.x)
				return -1;
			if (this.x > o.x)
				return 1;
			if (this.y < o.y)
				return -1;
			if (this.y > o.y)
				return 1;
			if (this.z < o.z)
				return -1;
			if (this.z > o.z)
				return 1;
			return 0;
		}

		@Override
		public boolean equals(Object that) {
			return this.compareTo((Point) that) == 0;
		}

		/*@Override
		public int hashCode() {
			return this.hashCode;
		}*/
	}

	static class BinaryLift {

		// FUNCTIONS: k-th ancestor and LCA in log(n)

		int[] parentOf;
		int maxJmpPow;
		int[][] binAncestorOf;
		int n;
		int[] lvlOf;

		// How this works?

		// a. For every node, we store the b-ancestor for b in {1, 2, 4, 8, .. log(n)}.

		// b. When we need k-ancestor, we represent 'k' in binary and for each set bit, we
		//    lift level in the tree.

		public BinaryLift(UGraph tree) {
			n = tree.V();
			maxJmpPow = logk(n, 2) + 1;
			parentOf = new int[n];
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			parentConstruct(0, -1, tree, 0);
			binConstruct();
		}

		// TODO: Implement lvlOf[] initialization
		public BinaryLift(int[] parentOf) {
			this.parentOf = parentOf;
			n = parentOf.length;
			maxJmpPow = logk(n, 2) + 1;
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			UGraph tree = new UGraph(n);
			for (int i = 1; i < n; i++)
				tree.addEdge(i, parentOf[i]);
			binConstruct();
			parentConstruct(0, -1, tree, 0);
		}

		private void parentConstruct(int current, int from, UGraph tree, int depth) {
			parentOf[current] = from;
			lvlOf[current] = depth;
			for (int adj : tree.adj(current))
				if (adj != from)
					parentConstruct(adj, current, tree, depth + 1);
		}

		private void binConstruct() {
			for (int node = 0; node < n; node++)
				for (int lvl = 0; lvl < maxJmpPow; lvl++)
					binConstruct(node, lvl);
		}

		private int binConstruct(int node, int lvl) {
			if (node < 0)
				return -1;
			if (lvl == 0)
				return binAncestorOf[node][lvl] = parentOf[node];
			if (node == 0)
				return binAncestorOf[node][lvl] = -1;

			if (binAncestorOf[node][lvl] != -1)
				return binAncestorOf[node][lvl];
			return binAncestorOf[node][lvl] = binConstruct(binConstruct(node, lvl - 1), lvl - 1);
		}

		// return ancestor which is 'k' levels above this one
		public int ancestor(int node, int k) {
			if (node < 0)
				return -1;
			if (node == 0)
				if (k == 0) return node;
				else return -1;
			if (k > (1 << maxJmpPow) - 1)
				return -1;
			if (k == 0)
				return node;

			int ancestor = node;
			int highestBit = Integer.highestOneBit(k);

			while (k > 0 && ancestor != -1) {
				ancestor = binAncestorOf[ancestor][logk(highestBit, 2)];
				k -= highestBit;
				highestBit = Integer.highestOneBit(k);
			}

			return ancestor;
		}

		public int lca(int u, int v) {

			if (u == v)
				return u;

			// The invariant will be that 'u' is below 'v' initially.
			if (lvlOf[u] < lvlOf[v]) {
				int temp = u;
				u = v;
				v = temp;
			}

			// Equalizing the levels.
			u = ancestor(u, lvlOf[u] - lvlOf[v]);

			if (u == v)
				return u;

			// We will now raise level by largest fitting power of two until possible.
			for (int power = maxJmpPow - 1; power > -1; power--)
				if (binAncestorOf[u][power] != binAncestorOf[v][power]) {
					u = binAncestorOf[u][power];
					v = binAncestorOf[v][power];
				}

			return ancestor(u, 1);
		}
	}

	static class DFSTree {

		// NOTE: The thing is made keeping in mind that the whole
		//  	 input graph is connected.

		UGraph tree;
		UGraph backUG;
		int hasBridge;
		int n;

		DFSTree(UGraph ug) {
			this.n = ug.V();
			tree = new UGraph(n);
			hasBridge = -1;
			backUG = new UGraph(n);
			treeCalc(0, -1, new boolean[n], ug);
		}

		private void treeCalc(int current, int from, boolean[] marked, UGraph ug) {
			if (marked[current]) {
				// This is a backEdge.
				backUG.addEdge(from, current);
				return;
			}

			if (from != -1)
				tree.addEdge(from, current);
			marked[current] = true;

			for (int adj : ug.adj(current))
				if (adj != from)
					treeCalc(adj, current, marked, ug);
		}

		public boolean hasBridge() {
			if (hasBridge != -1)
				return (hasBridge == 1);

			// We have to determine the bridge.
			bridgeFinder();
			return (hasBridge == 1);
		}

		int[] levelOf;
		int[] dp;

		private void bridgeFinder() {

			// Finding the level of each node.
			levelOf = new int[n];

			// Applying DP solution.
			// dp[i] -> Highest level reachable from subtree of 'i' using
			//   		some backEdge.
			dp = new int[n];
			Arrays.fill(dp, Integer.MAX_VALUE / 100);
			dpDFS(0, -1, 0);

			// Now, we will check each edge and determine whether its a
			// bridge.

			for (int i = 0; i < n; i++)
				for (int adj : tree.adj(i)) {

					// (i -> adj) is the edge.

					if (dp[adj] > levelOf[i])
						hasBridge = 1;
				}

			if (hasBridge != 1)
				hasBridge = 0;
		}

		private int dpDFS(int current, int from, int lvl) {
			levelOf[current] = lvl;
			dp[current] = levelOf[current];
			for (int back : backUG.adj(current))
				dp[current] = Math.min(dp[current], levelOf[back]);

			for (int adj : tree.adj(current))
				if (adj != from)
					dp[current] = Math.min(dp[current], dpDFS(adj, current, lvl + 1));

			return dp[current];
		}
	}

	static class UnionFind {
		// Uses weighted quick-union with path compression.
	    private int[] parent;  // parent[i] = parent of i
	    private int[] size;    // size[i] = number of sites in tree rooted at i
	                           // Note: not necessarily correct if i is not a root node
	    private int count;     // number of components

	    public UnionFind(int n) {
	        count = n;
	        parent = new int[n];
	        size = new int[n];
	        for (int i = 0; i < n; i++) {
	            parent[i] = i;
	            size[i] = 1;
	        }
	    }

	    // Number of connected components.
	    public int count() {
	        return count;
	    }

	    // Find the root of p.
	    public int find(int p) {
	    	while (p != parent[p])
	            p = parent[p];
	        return p;
	    }

	    public boolean connected(int p, int q) {
	        return find(p) == find(q);
	    }

	    public int numConnectedTo(int node) {
	    	return size[find(node)];
	    }

	    // Weighted union.
	    public void union(int p, int q) {
	        int rootP = find(p);
	        int rootQ = find(q);

	        if (rootP == rootQ) return;

	        // make smaller root point to larger one
	        if (size[rootP] < size[rootQ]) {
	            parent[rootP] = rootQ;
	            size[rootQ] += size[rootP];
	        }
	        else {
	            parent[rootQ] = rootP;
	            size[rootP] += size[rootQ];
	        }
	        count--;
	    }

	    public static int[] connectedComponents(UnionFind uf) {
	    	// We can do this in nlogn.

	    	int n = uf.size.length;
	    	int[] compoColors = new int[n];
	    	for (int i = 0; i < n; i++)
	    		compoColors[i] = uf.find(i);

	    	HashMap<Integer, Integer> oldToNew = new HashMap<>();
	    	int newCtr = 0;

	    	for (int i = 0; i < n; i++) {

	    		int thisOldColor = compoColors[i];
	    		Integer thisNewColor = oldToNew.get(thisOldColor);
	    		if (thisNewColor == null)
	    			thisNewColor = newCtr++;

	    		oldToNew.put(thisOldColor, thisNewColor);
	    		compoColors[i] = thisNewColor;
	    	}

	    	return compoColors;
	    }
	}

	static class UGraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public UGraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
			adj[to].add(from);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int degree(int v) {
			return adj[v].size();
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static void dfsMark(int current, boolean[] marked, UGraph g) {
			if (marked[current]) return;

			marked[current] = true;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, marked, g);
		}

		public static void dfsMark(int current, int from, long[] distTo, boolean[] marked, UGraph g, ArrayList<Integer> endPoints) {
			if (marked[current]) return;

			marked[current] = true;
			if (from != -1)
				distTo[current] = distTo[from] + 1;
			HashSet<Integer> adj = g.adj(current);
			int alreadyMarkedCtr = 0;
			for (int adjc : adj) {
				if (marked[adjc]) alreadyMarkedCtr++;
				dfsMark(adjc, current, distTo, marked, g, endPoints);
			}

			if (alreadyMarkedCtr == adj.size())
				endPoints.add(current);
		}

		public static void bfsOrder(int current, UGraph g) {
		}

		public static void dfsMark(int current, int[] colorIds, int color, UGraph g) {
			if (colorIds[current] != -1) return;

			colorIds[current] = color;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, colorIds, color, g);
		}

		public static int[] connectedComponents(UGraph g) {
			int n = g.V();
			int[] componentId = new int[n];
			Arrays.fill(componentId, -1);
			int colorCtr = 0;
			for (int i = 0; i < n; i++) {
				if (componentId[i] != -1) continue;
				dfsMark(i, componentId, colorCtr, g);
				colorCtr++;
			}

			return componentId;
		}

		public static boolean hasCycle(UGraph ug) {
			int n = ug.V();
			boolean[] marked = new boolean[n];
			boolean[] hasCycleFirst = new boolean[1];
			for (int i = 0; i < n; i++) {
				if (marked[i]) continue;
				hcDfsMark(i, ug, marked, hasCycleFirst, -1);
			}
			return hasCycleFirst[0];
		}

		// Helper for hasCycle.
		private static void hcDfsMark(int current, UGraph ug, boolean[] marked, boolean[] hasCycleFirst, int parent) {
			if (marked[current]) return;
			if (hasCycleFirst[0]) return;

			marked[current] = true;
			HashSet<Integer> adjc = ug.adj(current);
			for (int adj : adjc) {
				if (marked[adj] && adj != parent && parent != -1) {
					hasCycleFirst[0] = true;
					return;
				}

				hcDfsMark(adj, ug, marked, hasCycleFirst, current);
			}
		}
	}

	static class Digraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public Digraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public Digraph reversed() {
			Digraph dg = new Digraph(V());
			for (int i = 0; i < V(); i++)
				for (int adjVert : adj(i)) dg.addEdge(adjVert, i);
			return dg;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static int[] KosarajuSharirSCC(Digraph dg) {
			int[] id = new int[dg.V()];

			Digraph reversed = dg.reversed();

			// Gotta perform topological sort on this one to get the stack.
			Stack<Integer> revStack = Digraph.topologicalSort(reversed);

			// Initializing id and idCtr.
			id = new int[dg.V()];
			int idCtr = -1;

			// Creating a 'marked' array.
			boolean[] marked = new boolean[dg.V()];

			while (!revStack.isEmpty()) {
				int vertex = revStack.pop();
				if (!marked[vertex])
					sccDFS(dg, vertex, marked, ++idCtr, id);
			}
			return id;
		}

		private static void sccDFS(Digraph dg, int source, boolean[] marked, int idCtr, int[] id) {
			marked[source] = true;
			id[source] = idCtr;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex]) sccDFS(dg, adjVertex, marked, idCtr, id);
		}

		public static Stack<Integer> topologicalSort(Digraph dg) {
			// dg has to be a directed acyclic graph.
			// We'll have to run dfs on the digraph and push the deepest nodes on stack first.
			// We'll need a Stack<Integer> and a int[] marked.
			Stack<Integer> topologicalStack = new Stack<Integer>();
			boolean[] marked = new boolean[dg.V()];

			// Calling dfs
			for (int i = 0; i < dg.V(); i++)
				if (!marked[i])
					runDfs(dg, topologicalStack, marked, i);

			return topologicalStack;
		}

		static void runDfs(Digraph dg, Stack<Integer> topologicalStack, boolean[] marked, int source) {
			marked[source] = true;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex])
					runDfs(dg, topologicalStack, marked, adjVertex);
			topologicalStack.add(source);
		}
	}

	static class FastReader {
		private BufferedReader bfr;
		private StringTokenizer st;
		public FastReader() {
			bfr = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			if (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(bfr.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());
		}

		char nextChar() {
			return next().toCharArray()[0];
		}

		String nextString() {
			return next();
		}

		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		double[] nextDoubleArray(int n) {
			double[] arr = new double[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextDouble();
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		int[][] nextIntGrid(int n, int m) {
			int[][] grid = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					grid[i][j] = fr.nextInt();
			}
			return grid;
		}
	}

	static class LCA {
	    int[] height, first, segtree;
	    ArrayList<Integer> euler;
	    boolean[] visited;
	    int n;

	    LCA(UGraph ug, int root) {
	        n = ug.V();
	        height = new int[n];
	        first = new int[n];
	        euler = new ArrayList<>();
	        visited = new boolean[n];
	        dfs(ug, root, 0);
	        int m = euler.size();
	        segtree = new int[m * 4];
	        build(1, 0, m - 1);
	    }

	    void dfs(UGraph ug, int node, int h) {
	        visited[node] = true;
	        height[node] = h;
	        first[node] = euler.size();
	        euler.add(node);
	        for (int adj : ug.adj(node)) {
	            if (!visited[adj]) {
	                dfs(ug, adj, h + 1);
	                euler.add(node);
	            }
	        }
	    }

	    void build(int node, int b, int e) {
	        if (b == e) {
	            segtree[node] = euler.get(b);
	        } else {
	            int mid = (b + e) / 2;
	            build(node << 1, b, mid);
	            build(node << 1 | 1, mid + 1, e);
	            int l = segtree[node << 1], r = segtree[node << 1 | 1];
	            segtree[node] = (height[l] < height[r]) ? l : r;
	        }
	    }

	    int query(int node, int b, int e, int L, int R) {
	        if (b > R || e < L)
	            return -1;
	        if (b >= L && e <= R)
	            return segtree[node];
	        int mid = (b + e) >> 1;

	        int left = query(node << 1, b, mid, L, R);
	        int right = query(node << 1 | 1, mid + 1, e, L, R);
	        if (left == -1) return right;
	        if (right == -1) return left;
	        return height[left] < height[right] ? left : right;
	    }

	    int lca(int u, int v) {
	        int left = first[u], right = first[v];
	        if (left > right) {
	        	int temp = left;
	        	left = right;
	        	right = temp;
	        }
	        return query(1, 0, euler.size() - 1, left, right);
	    }
	}

	static class FenwickTree {

	    long[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new long[size + 1];
	    }

	    public long rsq(int ind) {
	        assert ind > 0;
	        long sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }

	        return sum;
	    }

	    public long rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;

	        return rsq(b) - rsq(a - 1);
	    }

	    public void update(int ind, long value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }

	    public int size() {
	        return array.length - 1;
	    }
	}

	static class SegmentTree {

	    private Node[] heap;
	    private long[] array;
	    private int size;

	    public SegmentTree(long[] array) {
	        this.array = Arrays.copyOf(array, array.length);
	        //The max size of this array is about 2 * 2 ^ log2(n) + 1
	        size = (int) (2 * Math.pow(2.0, Math.floor((Math.log((double) array.length) / Math.log(2.0)) + 1)));
	        heap = new Node[size];
	        build(1, 0, array.length);
	    }

	    public int size() {
	        return array.length;
	    }

	    //Initialize the Nodes of the Segment tree
	    private void build(int v, int from, int size) {
	        heap[v] = new Node();
	        heap[v].from = from;
	        heap[v].to = from + size - 1;

	        if (size == 1) {
	            heap[v].sum = array[from];
	            heap[v].min = array[from];
	            heap[v].max = array[from];
	        } else {
	            //Build childs
	            build(2 * v, from, size / 2);
	            build(2 * v + 1, from + size / 2, size - size / 2);

	            heap[v].sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            //min = min of the children
	            heap[v].min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            heap[v].max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    public long rsq(int from, int to) {
	        return rsq(1, from, to);
	    }

	    private long rsq(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Sum without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return (to - from + 1) * n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].sum;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftSum = rsq(2 * v, from, to);
	            long rightSum = rsq(2 * v + 1, from, to);

	            return leftSum + rightSum;
	        }

	        return 0;
	    }

	    public long rMinQ(int from, int to) {
	        return rMinQ(1, from, to);
	    }

	    private long rMinQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].min;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMin = rMinQ(2 * v, from, to);
	            long rightMin = rMinQ(2 * v + 1, from, to);

	            return Math.min(leftMin, rightMin);
	        }

	        return Integer.MAX_VALUE;
	    }

	    public long rMaxQ(int from, int to) {
	        return rMaxQ(1, from, to);
	    }

	    private long rMaxQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].max;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMax = rMaxQ(2 * v, from, to);
	            long rightMax = rMaxQ(2 * v + 1, from, to);

	            return Math.max(leftMax, rightMax);
	        }

	        return Integer.MIN_VALUE;
	    }

	    public void update(int from, int to, long value) {
	        update(1, from, to, value);
	    }

	    private void update(int v, int from, int to, long value) {

	        //The Node of the heap tree represents a range of the array with bounds: [n.from, n.to]
	        Node n = heap[v];

	        if (contains(from, to, n.from, n.to)) {
	            change(n, value);
	        }

	        if (n.size() == 1) return;

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);

	            update(2 * v, from, to, value);
	            update(2 * v + 1, from, to, value);

	            n.sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            n.min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            n.max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    //Propagate temporal values to children
	    private void propagate(int v) {
	        Node n = heap[v];

	        if (n.pendingVal != null) {
	            change(heap[2 * v], n.pendingVal);
	            change(heap[2 * v + 1], n.pendingVal);
	            n.pendingVal = null; //unset the pending propagation value
	        }
	    }

	    //Save the temporal values that will be propagated lazily
	    private void change(Node n, long value) {
	        n.pendingVal = value;
	        n.sum = n.size() * value;
	        n.min = value;
	        n.max = value;
	        array[n.from] = value;
	    }

	    //Test if the range1 contains range2
	    private boolean contains(int from1, int to1, int from2, int to2) {
	        return from2 >= from1 && to2 <= to1;
	    }

	    //check inclusive intersection, test if range1[from1, to1] intersects range2[from2, to2]
	    private boolean intersects(int from1, int to1, int from2, int to2) {
	        return from1 <= from2 && to1 >= from2   //  (.[..)..] or (.[...]..)
	                || from1 >= from2 && from1 <= to2; // [.(..]..) or [..(..)..
	    }

	    //The Node class represents a partition range of the array.
	    static class Node {
	        long sum;
	        long min;
	        long max;
	        //Here we store the value that will be propagated lazily
	        Long pendingVal = null;
	        int from;
	        int to;

	        int size() {
	            return to - from + 1;
	        }
	    }
	}

	@SuppressWarnings("serial")
	static class CountMap<T> extends TreeMap<T, Integer>{

		CountMap() {
		}

		CountMap(T[] arr) {
			this.putCM(arr);
		}

		public Integer putCM(T key) {
			return super.put(key, super.getOrDefault(key, 0) + 1);
		}

		public Integer removeCM(T key) {
			int count = super.getOrDefault(key, -1);
			if (count == -1) return -1;
			if (count == 1)
				return super.remove(key);
			else
				return super.put(key, count - 1);
		}

		public Integer getCM(T key) {
			return super.getOrDefault(key, 0);
		}

		public void putCM(T[] arr) {
			for (T l : arr)
				this.putCM(l);
		}
	}

	static long dioGCD(long a, long b, long[] x0, long[] y0) {
	    if (b == 0) {
	        x0[0] = 1;
	        y0[0] = 0;
	        return a;
	    }
	    long[] x1 = new long[1], y1 = new long[1];
	    long d = dioGCD(b, a % b, x1, y1);
	    x0[0] = y1[0];
	    y0[0] = x1[0] - y1[0] * (a / b);
	    return d;
	}

	static boolean diophantine(long a, long b, long c, long[] x0, long[] y0, long[] g) {
	    g[0] = dioGCD(Math.abs(a), Math.abs(b), x0, y0);
	    if (c % g[0] > 0) {
	        return false;
	    }

	    x0[0] *= c / g[0];
	    y0[0] *= c / g[0];
	    if (a < 0) x0[0] = -x0[0];
	    if (b < 0) y0[0] = -y0[0];
	    return true;
	}

	static long[][] prod(long[][] mat1, long[][] mat2) {
		int n = mat1.length;
		long[][] prod = new long[n][n];

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				// determining prod[i][j]
				// it will be the dot product of mat1[i][] and mat2[][i]
				for (int k = 0; k < n; k++)
					prod[i][j] += mat1[i][k] * mat2[k][j];
		return prod;
	}
	static long[][] matExpo(long[][] mat, long power) {
		int n = mat.length;
		long[][] ans = new long[n][n];

		if (power == 0)
			return null;

		if (power == 1)
			return mat;

		long[][] half = matExpo(mat, power / 2);
		ans = prod(half, half);

		if (power % 2 == 1) {
			ans = prod(ans, mat);
		}

		return ans;
	}

	static int KMPNumOcc(char[] text, char[] pat) {
		int n = text.length;
		int m = pat.length;

		char[] patPlusText = new char[n + m + 1];
		for (int i = 0; i < m; i++)
			patPlusText[i] = pat[i];
		patPlusText[m] = '^'; 		// Seperator
		for (int i = 0; i < n; i++)
			patPlusText[m + i] = text[i];

		int[] fullPi = piCalcKMP(patPlusText);
		int answer = 0;
		for (int i = 0; i < n + m + 1; i++)
			if (fullPi[i] == m)
				answer++;
		return answer;
	}
	static int[] piCalcKMP(char[] s) {
		int n = s.length;
		int[] pi = new int[n];
		for (int i = 1; i < n; i++) {
			int j = pi[i - 1];
			while (j > 0 && s[i] != s[j])
				j = pi[j - 1];
			if (s[i] == s[j])
				j++;
			pi[i] = j;
		}
		return pi;
	}
	static long hash(long key) {
        long h = Long.hashCode(key);
        h ^= (h >>> 20) ^ (h >>> 12) ^ (h >>> 7) ^ (h >>> 4);
        return h & (gigamod-1);
    }

	static int mapTo1D(int row, int col, int n, int m) {
		// Maps elements in a 2D matrix serially to elements in
		// a 1D array.
		return row * m + col;
	}
	static int[] mapTo2D(int idx, int n, int m) {
		// Inverse of what the one above does.
		int[] rnc = new int[2];
		rnc[0] = idx / m;
		rnc[1] = idx % m;
		return rnc;
	}

	static boolean[] primeGenerator(int upto) {
		// Sieve of Eratosthenes:
		isPrime = new boolean[upto + 1];
		smallestFactorOf = new int[upto + 1];
		Arrays.fill(smallestFactorOf, 1);
		Arrays.fill(isPrime, true);
		isPrime[1] = isPrime[0] = false;

		for (long i = 2; i < upto + 1; i++)
			if (isPrime[(int) i]) {
				smallestFactorOf[(int) i] = (int) i;
				// Mark all the multiples greater than or equal
				// to the square of i to be false.
				for (long j = i; j * i < upto + 1; j++) {
					if (isPrime[(int) j * (int) i]) {
						isPrime[(int) j * (int) i] = false;
						smallestFactorOf[(int) j * (int) i] = (int) i;
					}
				}
			}
		return isPrime;
	}
	static HashMap<Integer, Integer> smolNumPrimeFactorization(int num) {
		if (smallestFactorOf == null)
			primeGenerator(num + 1);
		HashMap<Integer, Integer> fnps = new HashMap<>();
		while (num != 1) {
			fnps.put(smallestFactorOf[num], fnps.getOrDefault(smallestFactorOf[num], 0) + 1);
			num /= smallestFactorOf[num];
		}
		return fnps;
	}
	static HashMap<Long, Integer> primeFactorization(long num) {
		// Returns map of factor and its power in the number.
		HashMap<Long, Integer> map = new HashMap<>();
		while (num % 2 == 0) {
			num /= 2;
			Integer pwrCnt = map.get(2L);
			map.put(2L, pwrCnt != null ? pwrCnt + 1 : 1);
		}
		for (long i = 3; i * i <= num; i += 2) {
			while (num % i == 0) {
				num /= i;
				Integer pwrCnt = map.get(i);
				map.put(i, pwrCnt != null ? pwrCnt + 1 : 1);
			}
		}
		// If the number is prime, we have to add it to the
		// map.
		if (num != 1)
			map.put(num, 1);
		return map;
	}
	static HashSet<Long> divisors(long num) {
		HashSet<Long> divisors = new HashSet<Long>();
		divisors.add(1L);
		divisors.add(num);
		for (long i = 2; i * i <= num; i++) {
			if (num % i == 0) {
				divisors.add(num/i);
				divisors.add(i);
			}
		}
		return divisors;
	}
	static void coprimeGenerator(int m, int n, ArrayList<Point> coprimes, int limit, int numCoprimes) {
		if (m > limit) return;
		if (m <= limit && n <= limit)
			coprimes.add(new Point(m, n));
		if (coprimes.size() > numCoprimes) return;
		coprimeGenerator(2 * m - n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(2 * m + n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(m + 2 * n, n, coprimes, limit, numCoprimes);
	}

	static int bsearch(int[] arr, int val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi, boolean sMode) {
		// Returns the index of the last element
		// smaller than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}
	static int bsearch(int[] arr, long val, int lo, int hi, boolean sMode) {
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}

	static long nCr(long n, long r, long[] fac) { long p = gigamod; if (r == 0) return 1; return (fac[(int)n] * modInverse(fac[(int)r], p) % p * modInverse(fac[(int)n - (int)r], p) % p) % p; }
	static long modInverse(long n, long p) { return power(n, p - 2, p); }
	static long modDiv(long a, long b){return mod(a * power(b, gigamod - 2, gigamod));}
	static long power(long x, long y, long p) { long res = 1; x = x % p; while (y > 0) { if ((y & 1)==1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
	static int logk(long n, long k) { return (int)(Math.log(n) / Math.log(k)); }
	static long gcd(long a, long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static long gcd(long[] arr) { int n = arr.length; long gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static int gcd(int[] arr) { int n = arr.length; int gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static long lcm(long[] arr) { long lcm = arr[0]; int n = arr.length; for (int i = 1; i < n; i++) { lcm = (lcm * arr[i]) / gcd(lcm, arr[i]); } return lcm; } static long lcm(long a, long b) { return (a * b)/gcd(a, b); } static boolean less(int a, int b) { return a < b ? true : false; } static boolean isSorted(int[] a) { for (int i = 1; i < a.length; i++) { if (less(a[i], a[i - 1])) return false; } return true; } static boolean isSorted(long[] a) { for (int i = 1; i < a.length; i++) { if (a[i] < a[i - 1]) return false; } return true; } static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(long[] a, int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(double[] a, int i, int j) { double temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(char[] a, int i, int j) { char temp = a[i]; a[i] = a[j]; a[j] = temp; }
	static void sort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void reverseSort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverse(char[] arr) { int n = arr.length; for (int i = 0; i < n / 2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); }
	static void shuffleArray(long[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { long tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } } static void shuffleArray(int[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { int tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(double[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { double tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(char[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { char tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static boolean isPrime(long n) {if (n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
	static String toString(int[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(boolean[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(long[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(char[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+"");return sb.toString();}
	static String toString(int[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(long[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++) {sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(double[][] dp){StringBuilder sb=new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(char[][] dp){StringBuilder sb = new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+"");}sb.append('\n');}return sb.toString();}
	static long mod(long a, long m){return(a%m+1000000L*m)%m;}
	static long mod(long num){return(num%gigamod+gigamod)%gigamod;}
}

// NOTES:
// ASCII VALUE OF 'A': 65
// ASCII VALUE OF 'a': 97
// Range of long: 9 * 10^18
// ASCII VALUE OF '0': 48
// Primes upto 'n' can be given by (n / (logn)).

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

// CFPS -> CodeForcesProblemSet
public final class CFPS {
	static FastReader fr = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);
	static final int gigamod = 1000000007;
	static int t = 1;
	static double epsilon = 0.00000001;
	static boolean[] isPrime;
	static int[] smallestFactorOf;

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		OUTER:
		for (int tc = 0; tc < t; tc++) {

			char[] sOG = fr.next().toCharArray();
			int n = sOG.length;

			if (n == 1) {
				if (sOG[0] == '0' || sOG[0] == '_')
					out.println(1);
				else
					out.println(0);
				continue OUTER;
			}

			// 00, 25, 50, 75 are the 4 universes
			// we'll count for all of them independently

			int answer = 0;

			{
				// 00
				// non _ and nonzero == death is true
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= (s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '0');

				if (!shit) {

					if (s[n - 1] == 'X' || s[n - 2] == 'X')
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';
					s[n - 1] = '0';
					s[n - 2] = '0';

					// now, we will iterate over all prefixes and
					// for each prefix, check whether it is possible to transform
					// s[] into (prefix + "00")

					// prefix has to be atmost 6 digits

					answer += check("00".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "00").toCharArray();
						answer += check(tgt, s);
					}

				}
			}

			{
				// 25
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '2';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 2
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '2';
					}

					s[n - 1] = '5';
					s[n - 2] = '2';

					answer += check("25".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "25").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 50
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '5';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 0
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';

					} else if (s[n - 2] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';
					}

					s[n - 1] = '0';
					s[n - 2] = '5';

					answer += check("50".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "50").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 75
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '7';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 7
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '7';
					}

					s[n - 1] = '5';
					s[n - 2] = '7';

					answer += check("75".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "75").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			out.println(answer);
		}
		out.close();
	}

	static int check(char[] tgt, char[] src) {
		int n = tgt.length;
		if (src.length != n) return 0;

		// 'X' check
		char xDig = 0;
		for (int i = 0; i < n; i++)
			if (src[i] == 'X') {
				if (xDig == 0) {
					xDig = tgt[i];
				} else {
					if (tgt[i] != xDig) return 0;
				}
			}
		// assert all 'X's have same digit;

		// no leading zeroes plz
		if (tgt[0] == '0') return 0;

		// all non _s have to be equal
		for (int i = 0; i < n; i++)
			if (src[i] != '_' && tgt[i] != src[i]) return 0;

		return 1;
	}

	static class Edge implements Comparable<Edge> {
		int from, to;
		long weight;
		int id;
		// int hash;

		Edge(int fro, int t, long weigh, int i) {
			from = fro;
			to = t;
			weight = weigh;
			id = i;
			// hash = Objects.hash(from, to, weight);
		}

		/*public int hashCode() {
			return hash;
		}*/

		public int compareTo(Edge that) {
			return Long.compare(this.id, that.id);
		}
	}

	public static long[][] sparseTable(long[] a)
	{
		int n = a.length;
		int b = 32-Integer.numberOfLeadingZeros(n);
		long[][] ret = new long[b][];
		for(int i = 0, l = 1;i < b;i++, l*=2) {
			if(i == 0) {
				ret[i] = a;
			}else {
				ret[i] = new long[n-l+1];
				for(int j = 0;j < n-l+1;j++) {
					ret[i][j] = Math.min(ret[i-1][j], ret[i-1][j+l/2]);
				}
			}
		}
		return ret;
	}

	public static long sparseRMQ(long[][] table, int l, int r)
	{
		// [a,b)
		assert l <= r;
		if(l >= r)return Integer.MAX_VALUE;
		// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
		int t = 31-Integer.numberOfLeadingZeros(r-l);
		return Math.min(table[t][l], table[t][r-(1<<t)]);
	}

	static class Point implements Comparable<Point> {
		long x;
		long y;
		long z;
		long id;
		// private int hashCode;

		Point() {
			x = z = y = 0;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(Point p) {
			this.x = p.x;
			this.y = p.y;
			this.z = p.z;
			this.id = p.id;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(long x, long y, long z, long id) {
			this.x = x;
			this.y = y;
			this.z = z;
			this.id = id;
			// this.hashCode = Objects.hash(x, y, id);
		}

		Point(long a, long b) {
			this.x = a;
			this.y = b;
			this.z = 0;
			// this.hashCode = Objects.hash(a, b);
		}

		Point(long x, long y, long id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}

		@Override
		public int compareTo(Point o) {
			if (this.x < o.x)
				return -1;
			if (this.x > o.x)
				return 1;
			if (this.y < o.y)
				return -1;
			if (this.y > o.y)
				return 1;
			if (this.z < o.z)
				return -1;
			if (this.z > o.z)
				return 1;
			return 0;
		}

		@Override
		public boolean equals(Object that) {
			return this.compareTo((Point) that) == 0;
		}

		/*@Override
		public int hashCode() {
			return this.hashCode;
		}*/
	}

	static class BinaryLift {

		// FUNCTIONS: k-th ancestor and LCA in log(n)

		int[] parentOf;
		int maxJmpPow;
		int[][] binAncestorOf;
		int n;
		int[] lvlOf;

		// How this works?

		// a. For every node, we store the b-ancestor for b in {1, 2, 4, 8, .. log(n)}.

		// b. When we need k-ancestor, we represent 'k' in binary and for each set bit, we
		//    lift level in the tree.

		public BinaryLift(UGraph tree) {
			n = tree.V();
			maxJmpPow = logk(n, 2) + 1;
			parentOf = new int[n];
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			parentConstruct(0, -1, tree, 0);
			binConstruct();
		}

		// TODO: Implement lvlOf[] initialization
		public BinaryLift(int[] parentOf) {
			this.parentOf = parentOf;
			n = parentOf.length;
			maxJmpPow = logk(n, 2) + 1;
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			UGraph tree = new UGraph(n);
			for (int i = 1; i < n; i++)
				tree.addEdge(i, parentOf[i]);
			binConstruct();
			parentConstruct(0, -1, tree, 0);
		}

		private void parentConstruct(int current, int from, UGraph tree, int depth) {
			parentOf[current] = from;
			lvlOf[current] = depth;
			for (int adj : tree.adj(current))
				if (adj != from)
					parentConstruct(adj, current, tree, depth + 1);
		}

		private void binConstruct() {
			for (int node = 0; node < n; node++)
				for (int lvl = 0; lvl < maxJmpPow; lvl++)
					binConstruct(node, lvl);
		}

		private int binConstruct(int node, int lvl) {
			if (node < 0)
				return -1;
			if (lvl == 0)
				return binAncestorOf[node][lvl] = parentOf[node];
			if (node == 0)
				return binAncestorOf[node][lvl] = -1;

			if (binAncestorOf[node][lvl] != -1)
				return binAncestorOf[node][lvl];
			return binAncestorOf[node][lvl] = binConstruct(binConstruct(node, lvl - 1), lvl - 1);
		}

		// return ancestor which is 'k' levels above this one
		public int ancestor(int node, int k) {
			if (node < 0)
				return -1;
			if (node == 0)
				if (k == 0) return node;
				else return -1;
			if (k > (1 << maxJmpPow) - 1)
				return -1;
			if (k == 0)
				return node;

			int ancestor = node;
			int highestBit = Integer.highestOneBit(k);

			while (k > 0 && ancestor != -1) {
				ancestor = binAncestorOf[ancestor][logk(highestBit, 2)];
				k -= highestBit;
				highestBit = Integer.highestOneBit(k);
			}

			return ancestor;
		}

		public int lca(int u, int v) {

			if (u == v)
				return u;

			// The invariant will be that 'u' is below 'v' initially.
			if (lvlOf[u] < lvlOf[v]) {
				int temp = u;
				u = v;
				v = temp;
			}

			// Equalizing the levels.
			u = ancestor(u, lvlOf[u] - lvlOf[v]);

			if (u == v)
				return u;

			// We will now raise level by largest fitting power of two until possible.
			for (int power = maxJmpPow - 1; power > -1; power--)
				if (binAncestorOf[u][power] != binAncestorOf[v][power]) {
					u = binAncestorOf[u][power];
					v = binAncestorOf[v][power];
				}

			return ancestor(u, 1);
		}
	}

	static class DFSTree {

		// NOTE: The thing is made keeping in mind that the whole
		//  	 input graph is connected.

		UGraph tree;
		UGraph backUG;
		int hasBridge;
		int n;

		DFSTree(UGraph ug) {
			this.n = ug.V();
			tree = new UGraph(n);
			hasBridge = -1;
			backUG = new UGraph(n);
			treeCalc(0, -1, new boolean[n], ug);
		}

		private void treeCalc(int current, int from, boolean[] marked, UGraph ug) {
			if (marked[current]) {
				// This is a backEdge.
				backUG.addEdge(from, current);
				return;
			}

			if (from != -1)
				tree.addEdge(from, current);
			marked[current] = true;

			for (int adj : ug.adj(current))
				if (adj != from)
					treeCalc(adj, current, marked, ug);
		}

		public boolean hasBridge() {
			if (hasBridge != -1)
				return (hasBridge == 1);

			// We have to determine the bridge.
			bridgeFinder();
			return (hasBridge == 1);
		}

		int[] levelOf;
		int[] dp;

		private void bridgeFinder() {

			// Finding the level of each node.
			levelOf = new int[n];

			// Applying DP solution.
			// dp[i] -> Highest level reachable from subtree of 'i' using
			//   		some backEdge.
			dp = new int[n];
			Arrays.fill(dp, Integer.MAX_VALUE / 100);
			dpDFS(0, -1, 0);

			// Now, we will check each edge and determine whether its a
			// bridge.

			for (int i = 0; i < n; i++)
				for (int adj : tree.adj(i)) {

					// (i -> adj) is the edge.

					if (dp[adj] > levelOf[i])
						hasBridge = 1;
				}

			if (hasBridge != 1)
				hasBridge = 0;
		}

		private int dpDFS(int current, int from, int lvl) {
			levelOf[current] = lvl;
			dp[current] = levelOf[current];
			for (int back : backUG.adj(current))
				dp[current] = Math.min(dp[current], levelOf[back]);

			for (int adj : tree.adj(current))
				if (adj != from)
					dp[current] = Math.min(dp[current], dpDFS(adj, current, lvl + 1));

			return dp[current];
		}
	}

	static class UnionFind {
		// Uses weighted quick-union with path compression.
	    private int[] parent;  // parent[i] = parent of i
	    private int[] size;    // size[i] = number of sites in tree rooted at i
	                           // Note: not necessarily correct if i is not a root node
	    private int count;     // number of components

	    public UnionFind(int n) {
	        count = n;
	        parent = new int[n];
	        size = new int[n];
	        for (int i = 0; i < n; i++) {
	            parent[i] = i;
	            size[i] = 1;
	        }
	    }

	    // Number of connected components.
	    public int count() {
	        return count;
	    }

	    // Find the root of p.
	    public int find(int p) {
	    	while (p != parent[p])
	            p = parent[p];
	        return p;
	    }

	    public boolean connected(int p, int q) {
	        return find(p) == find(q);
	    }

	    public int numConnectedTo(int node) {
	    	return size[find(node)];
	    }

	    // Weighted union.
	    public void union(int p, int q) {
	        int rootP = find(p);
	        int rootQ = find(q);

	        if (rootP == rootQ) return;

	        // make smaller root point to larger one
	        if (size[rootP] < size[rootQ]) {
	            parent[rootP] = rootQ;
	            size[rootQ] += size[rootP];
	        }
	        else {
	            parent[rootQ] = rootP;
	            size[rootP] += size[rootQ];
	        }
	        count--;
	    }

	    public static int[] connectedComponents(UnionFind uf) {
	    	// We can do this in nlogn.

	    	int n = uf.size.length;
	    	int[] compoColors = new int[n];
	    	for (int i = 0; i < n; i++)
	    		compoColors[i] = uf.find(i);

	    	HashMap<Integer, Integer> oldToNew = new HashMap<>();
	    	int newCtr = 0;

	    	for (int i = 0; i < n; i++) {

	    		int thisOldColor = compoColors[i];
	    		Integer thisNewColor = oldToNew.get(thisOldColor);
	    		if (thisNewColor == null)
	    			thisNewColor = newCtr++;

	    		oldToNew.put(thisOldColor, thisNewColor);
	    		compoColors[i] = thisNewColor;
	    	}

	    	return compoColors;
	    }
	}

	static class UGraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public UGraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
			adj[to].add(from);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int degree(int v) {
			return adj[v].size();
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static void dfsMark(int current, boolean[] marked, UGraph g) {
			if (marked[current]) return;

			marked[current] = true;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, marked, g);
		}

		public static void dfsMark(int current, int from, long[] distTo, boolean[] marked, UGraph g, ArrayList<Integer> endPoints) {
			if (marked[current]) return;

			marked[current] = true;
			if (from != -1)
				distTo[current] = distTo[from] + 1;
			HashSet<Integer> adj = g.adj(current);
			int alreadyMarkedCtr = 0;
			for (int adjc : adj) {
				if (marked[adjc]) alreadyMarkedCtr++;
				dfsMark(adjc, current, distTo, marked, g, endPoints);
			}

			if (alreadyMarkedCtr == adj.size())
				endPoints.add(current);
		}

		public static void bfsOrder(int current, UGraph g) {
		}

		public static void dfsMark(int current, int[] colorIds, int color, UGraph g) {
			if (colorIds[current] != -1) return;

			colorIds[current] = color;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, colorIds, color, g);
		}

		public static int[] connectedComponents(UGraph g) {
			int n = g.V();
			int[] componentId = new int[n];
			Arrays.fill(componentId, -1);
			int colorCtr = 0;
			for (int i = 0; i < n; i++) {
				if (componentId[i] != -1) continue;
				dfsMark(i, componentId, colorCtr, g);
				colorCtr++;
			}

			return componentId;
		}

		public static boolean hasCycle(UGraph ug) {
			int n = ug.V();
			boolean[] marked = new boolean[n];
			boolean[] hasCycleFirst = new boolean[1];
			for (int i = 0; i < n; i++) {
				if (marked[i]) continue;
				hcDfsMark(i, ug, marked, hasCycleFirst, -1);
			}
			return hasCycleFirst[0];
		}

		// Helper for hasCycle.
		private static void hcDfsMark(int current, UGraph ug, boolean[] marked, boolean[] hasCycleFirst, int parent) {
			if (marked[current]) return;
			if (hasCycleFirst[0]) return;

			marked[current] = true;
			HashSet<Integer> adjc = ug.adj(current);
			for (int adj : adjc) {
				if (marked[adj] && adj != parent && parent != -1) {
					hasCycleFirst[0] = true;
					return;
				}

				hcDfsMark(adj, ug, marked, hasCycleFirst, current);
			}
		}
	}

	static class Digraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public Digraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public Digraph reversed() {
			Digraph dg = new Digraph(V());
			for (int i = 0; i < V(); i++)
				for (int adjVert : adj(i)) dg.addEdge(adjVert, i);
			return dg;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static int[] KosarajuSharirSCC(Digraph dg) {
			int[] id = new int[dg.V()];

			Digraph reversed = dg.reversed();

			// Gotta perform topological sort on this one to get the stack.
			Stack<Integer> revStack = Digraph.topologicalSort(reversed);

			// Initializing id and idCtr.
			id = new int[dg.V()];
			int idCtr = -1;

			// Creating a 'marked' array.
			boolean[] marked = new boolean[dg.V()];

			while (!revStack.isEmpty()) {
				int vertex = revStack.pop();
				if (!marked[vertex])
					sccDFS(dg, vertex, marked, ++idCtr, id);
			}
			return id;
		}

		private static void sccDFS(Digraph dg, int source, boolean[] marked, int idCtr, int[] id) {
			marked[source] = true;
			id[source] = idCtr;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex]) sccDFS(dg, adjVertex, marked, idCtr, id);
		}

		public static Stack<Integer> topologicalSort(Digraph dg) {
			// dg has to be a directed acyclic graph.
			// We'll have to run dfs on the digraph and push the deepest nodes on stack first.
			// We'll need a Stack<Integer> and a int[] marked.
			Stack<Integer> topologicalStack = new Stack<Integer>();
			boolean[] marked = new boolean[dg.V()];

			// Calling dfs
			for (int i = 0; i < dg.V(); i++)
				if (!marked[i])
					runDfs(dg, topologicalStack, marked, i);

			return topologicalStack;
		}

		static void runDfs(Digraph dg, Stack<Integer> topologicalStack, boolean[] marked, int source) {
			marked[source] = true;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex])
					runDfs(dg, topologicalStack, marked, adjVertex);
			topologicalStack.add(source);
		}
	}

	static class FastReader {
		private BufferedReader bfr;
		private StringTokenizer st;
		public FastReader() {
			bfr = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			if (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(bfr.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());
		}

		char nextChar() {
			return next().toCharArray()[0];
		}

		String nextString() {
			return next();
		}

		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		double[] nextDoubleArray(int n) {
			double[] arr = new double[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextDouble();
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		int[][] nextIntGrid(int n, int m) {
			int[][] grid = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					grid[i][j] = fr.nextInt();
			}
			return grid;
		}
	}

	static class LCA {
	    int[] height, first, segtree;
	    ArrayList<Integer> euler;
	    boolean[] visited;
	    int n;

	    LCA(UGraph ug, int root) {
	        n = ug.V();
	        height = new int[n];
	        first = new int[n];
	        euler = new ArrayList<>();
	        visited = new boolean[n];
	        dfs(ug, root, 0);
	        int m = euler.size();
	        segtree = new int[m * 4];
	        build(1, 0, m - 1);
	    }

	    void dfs(UGraph ug, int node, int h) {
	        visited[node] = true;
	        height[node] = h;
	        first[node] = euler.size();
	        euler.add(node);
	        for (int adj : ug.adj(node)) {
	            if (!visited[adj]) {
	                dfs(ug, adj, h + 1);
	                euler.add(node);
	            }
	        }
	    }

	    void build(int node, int b, int e) {
	        if (b == e) {
	            segtree[node] = euler.get(b);
	        } else {
	            int mid = (b + e) / 2;
	            build(node << 1, b, mid);
	            build(node << 1 | 1, mid + 1, e);
	            int l = segtree[node << 1], r = segtree[node << 1 | 1];
	            segtree[node] = (height[l] < height[r]) ? l : r;
	        }
	    }

	    int query(int node, int b, int e, int L, int R) {
	        if (b > R || e < L)
	            return -1;
	        if (b >= L && e <= R)
	            return segtree[node];
	        int mid = (b + e) >> 1;

	        int left = query(node << 1, b, mid, L, R);
	        int right = query(node << 1 | 1, mid + 1, e, L, R);
	        if (left == -1) return right;
	        if (right == -1) return left;
	        return height[left] < height[right] ? left : right;
	    }

	    int lca(int u, int v) {
	        int left = first[u], right = first[v];
	        if (left > right) {
	        	int temp = left;
	        	left = right;
	        	right = temp;
	        }
	        return query(1, 0, euler.size() - 1, left, right);
	    }
	}

	static class FenwickTree {

	    long[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new long[size + 1];
	    }

	    public long rsq(int ind) {
	        assert ind > 0;
	        long sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }

	        return sum;
	    }

	    public long rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;

	        return rsq(b) - rsq(a - 1);
	    }

	    public void update(int ind, long value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }

	    public int size() {
	        return array.length - 1;
	    }
	}

	static class SegmentTree {

	    private Node[] heap;
	    private long[] array;
	    private int size;

	    public SegmentTree(long[] array) {
	        this.array = Arrays.copyOf(array, array.length);
	        //The max size of this array is about 2 * 2 ^ log2(n) + 1
	        size = (int) (2 * Math.pow(2.0, Math.floor((Math.log((double) array.length) / Math.log(2.0)) + 1)));
	        heap = new Node[size];
	        build(1, 0, array.length);
	    }

	    public int size() {
	        return array.length;
	    }

	    //Initialize the Nodes of the Segment tree
	    private void build(int v, int from, int size) {
	        heap[v] = new Node();
	        heap[v].from = from;
	        heap[v].to = from + size - 1;

	        if (size == 1) {
	            heap[v].sum = array[from];
	            heap[v].min = array[from];
	            heap[v].max = array[from];
	        } else {
	            //Build childs
	            build(2 * v, from, size / 2);
	            build(2 * v + 1, from + size / 2, size - size / 2);

	            heap[v].sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            //min = min of the children
	            heap[v].min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            heap[v].max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    public long rsq(int from, int to) {
	        return rsq(1, from, to);
	    }

	    private long rsq(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Sum without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return (to - from + 1) * n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].sum;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftSum = rsq(2 * v, from, to);
	            long rightSum = rsq(2 * v + 1, from, to);

	            return leftSum + rightSum;
	        }

	        return 0;
	    }

	    public long rMinQ(int from, int to) {
	        return rMinQ(1, from, to);
	    }

	    private long rMinQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].min;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMin = rMinQ(2 * v, from, to);
	            long rightMin = rMinQ(2 * v + 1, from, to);

	            return Math.min(leftMin, rightMin);
	        }

	        return Integer.MAX_VALUE;
	    }

	    public long rMaxQ(int from, int to) {
	        return rMaxQ(1, from, to);
	    }

	    private long rMaxQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].max;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMax = rMaxQ(2 * v, from, to);
	            long rightMax = rMaxQ(2 * v + 1, from, to);

	            return Math.max(leftMax, rightMax);
	        }

	        return Integer.MIN_VALUE;
	    }

	    public void update(int from, int to, long value) {
	        update(1, from, to, value);
	    }

	    private void update(int v, int from, int to, long value) {

	        //The Node of the heap tree represents a range of the array with bounds: [n.from, n.to]
	        Node n = heap[v];

	        if (contains(from, to, n.from, n.to)) {
	            change(n, value);
	        }

	        if (n.size() == 1) return;

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);

	            update(2 * v, from, to, value);
	            update(2 * v + 1, from, to, value);

	            n.sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            n.min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            n.max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    //Propagate temporal values to children
	    private void propagate(int v) {
	        Node n = heap[v];

	        if (n.pendingVal != null) {
	            change(heap[2 * v], n.pendingVal);
	            change(heap[2 * v + 1], n.pendingVal);
	            n.pendingVal = null; //unset the pending propagation value
	        }
	    }

	    //Save the temporal values that will be propagated lazily
	    private void change(Node n, long value) {
	        n.pendingVal = value;
	        n.sum = n.size() * value;
	        n.min = value;
	        n.max = value;
	        array[n.from] = value;
	    }

	    //Test if the range1 contains range2
	    private boolean contains(int from1, int to1, int from2, int to2) {
	        return from2 >= from1 && to2 <= to1;
	    }

	    //check inclusive intersection, test if range1[from1, to1] intersects range2[from2, to2]
	    private boolean intersects(int from1, int to1, int from2, int to2) {
	        return from1 <= from2 && to1 >= from2   //  (.[..)..] or (.[...]..)
	                || from1 >= from2 && from1 <= to2; // [.(..]..) or [..(..)..
	    }

	    //The Node class represents a partition range of the array.
	    static class Node {
	        long sum;
	        long min;
	        long max;
	        //Here we store the value that will be propagated lazily
	        Long pendingVal = null;
	        int from;
	        int to;

	        int size() {
	            return to - from + 1;
	        }
	    }
	}

	@SuppressWarnings("serial")
	static class CountMap<T> extends TreeMap<T, Integer>{

		CountMap() {
		}

		CountMap(T[] arr) {
			this.putCM(arr);
		}

		public Integer putCM(T key) {
			return super.put(key, super.getOrDefault(key, 0) + 1);
		}

		public Integer removeCM(T key) {
			int count = super.getOrDefault(key, -1);
			if (count == -1) return -1;
			if (count == 1)
				return super.remove(key);
			else
				return super.put(key, count - 1);
		}

		public Integer getCM(T key) {
			return super.getOrDefault(key, 0);
		}

		public void putCM(T[] arr) {
			for (T l : arr)
				this.putCM(l);
		}
	}

	static long dioGCD(long a, long b, long[] x0, long[] y0) {
	    if (b == 0) {
	        x0[0] = 1;
	        y0[0] = 0;
	        return a;
	    }
	    long[] x1 = new long[1], y1 = new long[1];
	    long d = dioGCD(b, a % b, x1, y1);
	    x0[0] = y1[0];
	    y0[0] = x1[0] - y1[0] * (a / b);
	    return d;
	}

	static boolean diophantine(long a, long b, long c, long[] x0, long[] y0, long[] g) {
	    g[0] = dioGCD(Math.abs(a), Math.abs(b), x0, y0);
	    if (c % g[0] > 0) {
	        return false;
	    }

	    x0[0] *= c / g[0];
	    y0[0] *= c / g[0];
	    if (a < 0) x0[0] = -x0[0];
	    if (b < 0) y0[0] = -y0[0];
	    return true;
	}

	static long[][] prod(long[][] mat1, long[][] mat2) {
		int n = mat1.length;
		long[][] prod = new long[n][n];

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				// determining prod[i][j]
				// it will be the dot product of mat1[i][] and mat2[][i]
				for (int k = 0; k < n; k++)
					prod[i][j] += mat1[i][k] * mat2[k][j];
		return prod;
	}
	static long[][] matExpo(long[][] mat, long power) {
		int n = mat.length;
		long[][] ans = new long[n][n];

		if (power == 0)
			return null;

		if (power == 1)
			return mat;

		long[][] half = matExpo(mat, power / 2);
		ans = prod(half, half);

		if (power % 2 == 1) {
			ans = prod(ans, mat);
		}

		return ans;
	}

	static int KMPNumOcc(char[] text, char[] pat) {
		int n = text.length;
		int m = pat.length;

		char[] patPlusText = new char[n + m + 1];
		for (int i = 0; i < m; i++)
			patPlusText[i] = pat[i];
		patPlusText[m] = '^'; 		// Seperator
		for (int i = 0; i < n; i++)
			patPlusText[m + i] = text[i];

		int[] fullPi = piCalcKMP(patPlusText);
		int answer = 0;
		for (int i = 0; i < n + m + 1; i++)
			if (fullPi[i] == m)
				answer++;
		return answer;
	}
	static int[] piCalcKMP(char[] s) {
		int n = s.length;
		int[] pi = new int[n];
		for (int i = 1; i < n; i++) {
			int j = pi[i - 1];
			while (j > 0 && s[i] != s[j])
				j = pi[j - 1];
			if (s[i] == s[j])
				j++;
			pi[i] = j;
		}
		return pi;
	}
	static long hash(long key) {
        long h = Long.hashCode(key);
        h ^= (h >>> 20) ^ (h >>> 12) ^ (h >>> 7) ^ (h >>> 4);
        return h & (gigamod-1);
    }

	static int mapTo1D(int row, int col, int n, int m) {
		// Maps elements in a 2D matrix serially to elements in
		// a 1D array.
		return row * m + col;
	}
	static int[] mapTo2D(int idx, int n, int m) {
		// Inverse of what the one above does.
		int[] rnc = new int[2];
		rnc[0] = idx / m;
		rnc[1] = idx % m;
		return rnc;
	}

	static boolean[] primeGenerator(int upto) {
		// Sieve of Eratosthenes:
		isPrime = new boolean[upto + 1];
		smallestFactorOf = new int[upto + 1];
		Arrays.fill(smallestFactorOf, 1);
		Arrays.fill(isPrime, true);
		isPrime[1] = isPrime[0] = false;

		for (long i = 2; i < upto + 1; i++)
			if (isPrime[(int) i]) {
				smallestFactorOf[(int) i] = (int) i;
				// Mark all the multiples greater than or equal
				// to the square of i to be false.
				for (long j = i; j * i < upto + 1; j++) {
					if (isPrime[(int) j * (int) i]) {
						isPrime[(int) j * (int) i] = false;
						smallestFactorOf[(int) j * (int) i] = (int) i;
					}
				}
			}
		return isPrime;
	}
	static HashMap<Integer, Integer> smolNumPrimeFactorization(int num) {
		if (smallestFactorOf == null)
			primeGenerator(num + 1);
		HashMap<Integer, Integer> fnps = new HashMap<>();
		while (num != 1) {
			fnps.put(smallestFactorOf[num], fnps.getOrDefault(smallestFactorOf[num], 0) + 1);
			num /= smallestFactorOf[num];
		}
		return fnps;
	}
	static HashMap<Long, Integer> primeFactorization(long num) {
		// Returns map of factor and its power in the number.
		HashMap<Long, Integer> map = new HashMap<>();
		while (num % 2 == 0) {
			num /= 2;
			Integer pwrCnt = map.get(2L);
			map.put(2L, pwrCnt != null ? pwrCnt + 1 : 1);
		}
		for (long i = 3; i * i <= num; i += 2) {
			while (num % i == 0) {
				num /= i;
				Integer pwrCnt = map.get(i);
				map.put(i, pwrCnt != null ? pwrCnt + 1 : 1);
			}
		}
		// If the number is prime, we have to add it to the
		// map.
		if (num != 1)
			map.put(num, 1);
		return map;
	}
	static HashSet<Long> divisors(long num) {
		HashSet<Long> divisors = new HashSet<Long>();
		divisors.add(1L);
		divisors.add(num);
		for (long i = 2; i * i <= num; i++) {
			if (num % i == 0) {
				divisors.add(num/i);
				divisors.add(i);
			}
		}
		return divisors;
	}
	static void coprimeGenerator(int m, int n, ArrayList<Point> coprimes, int limit, int numCoprimes) {
		if (m > limit) return;
		if (m <= limit && n <= limit)
			coprimes.add(new Point(m, n));
		if (coprimes.size() > numCoprimes) return;
		coprimeGenerator(2 * m - n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(2 * m + n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(m + 2 * n, n, coprimes, limit, numCoprimes);
	}

	static int bsearch(int[] arr, int val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi, boolean sMode) {
		// Returns the index of the last element
		// smaller than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}
	static int bsearch(int[] arr, long val, int lo, int hi, boolean sMode) {
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}

	static long nCr(long n, long r, long[] fac) { long p = gigamod; if (r == 0) return 1; return (fac[(int)n] * modInverse(fac[(int)r], p) % p * modInverse(fac[(int)n - (int)r], p) % p) % p; }
	static long modInverse(long n, long p) { return power(n, p - 2, p); }
	static long modDiv(long a, long b){return mod(a * power(b, gigamod - 2, gigamod));}
	static long power(long x, long y, long p) { long res = 1; x = x % p; while (y > 0) { if ((y & 1)==1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
	static int logk(long n, long k) { return (int)(Math.log(n) / Math.log(k)); }
	static long gcd(long a, long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static long gcd(long[] arr) { int n = arr.length; long gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static int gcd(int[] arr) { int n = arr.length; int gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static long lcm(long[] arr) { long lcm = arr[0]; int n = arr.length; for (int i = 1; i < n; i++) { lcm = (lcm * arr[i]) / gcd(lcm, arr[i]); } return lcm; } static long lcm(long a, long b) { return (a * b)/gcd(a, b); } static boolean less(int a, int b) { return a < b ? true : false; } static boolean isSorted(int[] a) { for (int i = 1; i < a.length; i++) { if (less(a[i], a[i - 1])) return false; } return true; } static boolean isSorted(long[] a) { for (int i = 1; i < a.length; i++) { if (a[i] < a[i - 1]) return false; } return true; } static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(long[] a, int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(double[] a, int i, int j) { double temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(char[] a, int i, int j) { char temp = a[i]; a[i] = a[j]; a[j] = temp; }
	static void sort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void reverseSort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverse(char[] arr) { int n = arr.length; for (int i = 0; i < n / 2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); }
	static void shuffleArray(long[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { long tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } } static void shuffleArray(int[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { int tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(double[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { double tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(char[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { char tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static boolean isPrime(long n) {if (n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
	static String toString(int[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(boolean[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(long[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(char[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+"");return sb.toString();}
	static String toString(int[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(long[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++) {sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(double[][] dp){StringBuilder sb=new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(char[][] dp){StringBuilder sb = new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+"");}sb.append('\n');}return sb.toString();}
	static long mod(long a, long m){return(a%m+1000000L*m)%m;}
	static long mod(long num){return(num%gigamod+gigamod)%gigamod;}
}

// NOTES:
// ASCII VALUE OF 'A': 65
// ASCII VALUE OF 'a': 97
// Range of long: 9 * 10^18
// ASCII VALUE OF '0': 48
// Primes upto 'n' can be given by (n / (logn)).

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

// CFPS -> CodeForcesProblemSet
public final class CFPS {
	static FastReader fr = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);
	static final int gigamod = 1000000007;
	static int t = 1;
	static double epsilon = 0.00000001;
	static boolean[] isPrime;
	static int[] smallestFactorOf;

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		OUTER:
		for (int tc = 0; tc < t; tc++) {

			char[] sOG = fr.next().toCharArray();
			int n = sOG.length;

			if (n == 1) {
				if (sOG[0] == '0')
					out.println(1);
				else
					out.println(0);
				continue OUTER;
			}

			// 00, 25, 50, 75 are the 4 universes
			// we'll count for all of them independently

			int answer = 0;

			{
				// 00
				// non _ and nonzero == death is true
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= (s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '0');

				if (!shit) {

					if (s[n - 1] == 'X' || s[n - 2] == 'X')
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';
					s[n - 1] = '0';
					s[n - 2] = '0';

					// now, we will iterate over all prefixes and
					// for each prefix, check whether it is possible to transform
					// s[] into (prefix + "00")

					// prefix has to be atmost 6 digits

					answer += check("00".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "00").toCharArray();
						answer += check(tgt, s);
					}

				}
			}

			{
				// 25
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '2';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 2
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '2';
					}

					s[n - 1] = '5';
					s[n - 2] = '2';

					answer += check("25".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "25").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 50
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '0');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '5';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 0
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '0';

					} else if (s[n - 2] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';
					}

					s[n - 1] = '0';
					s[n - 2] = '5';

					answer += check("50".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "50").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			{
				// 75
				char[] s = sOG.clone();

				boolean shit = (s[n - 1] != '_' && s[n - 1] != 'X' && s[n - 1] != '5');
				shit |= s[n - 2] != '_' && s[n - 2] != 'X' && s[n - 2] != '7';
				shit |= (s[n - 1] == 'X' && s[n - 2] == 'X');

				if (!shit) {

					if (s[n - 1] == 'X') {

						// replace each by 5
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '5';

					} else if (s[n - 2] == 'X') {

						// replace each by 7
						for (int i = 0; i < n; i++)
							if (s[i] == 'X')
								s[i] = '7';
					}

					s[n - 1] = '5';
					s[n - 2] = '7';

					answer += check("75".toCharArray(), s);

					for (int num = 0; num < 1e6; num++) {
						char[] tgt = (Integer.toString(num) + "75").toCharArray();
						answer += check(tgt, s);
					}
				}
			}

			out.println(answer);
		}
		out.close();
	}

	static int check(char[] tgt, char[] src) {
		int n = tgt.length;
		if (src.length != n) return 0;

		// 'X' check
		char xDig = 0;
		for (int i = 0; i < n; i++)
			if (src[i] == 'X') {
				if (xDig == 0) {
					xDig = tgt[i];
				} else {
					if (tgt[i] != xDig) return 0;
				}
			}
		// assert all 'X's have same digit;

		// no leading zeroes plz
		if (tgt[0] == '0') return 0;

		// all non _s have to be equal
		for (int i = 0; i < n; i++)
			if (src[i] != '_' && tgt[i] != src[i]) return 0;

		return 1;
	}

	static class Edge implements Comparable<Edge> {
		int from, to;
		long weight;
		int id;
		// int hash;

		Edge(int fro, int t, long weigh, int i) {
			from = fro;
			to = t;
			weight = weigh;
			id = i;
			// hash = Objects.hash(from, to, weight);
		}

		/*public int hashCode() {
			return hash;
		}*/

		public int compareTo(Edge that) {
			return Long.compare(this.id, that.id);
		}
	}

	public static long[][] sparseTable(long[] a)
	{
		int n = a.length;
		int b = 32-Integer.numberOfLeadingZeros(n);
		long[][] ret = new long[b][];
		for(int i = 0, l = 1;i < b;i++, l*=2) {
			if(i == 0) {
				ret[i] = a;
			}else {
				ret[i] = new long[n-l+1];
				for(int j = 0;j < n-l+1;j++) {
					ret[i][j] = Math.min(ret[i-1][j], ret[i-1][j+l/2]);
				}
			}
		}
		return ret;
	}

	public static long sparseRMQ(long[][] table, int l, int r)
	{
		// [a,b)
		assert l <= r;
		if(l >= r)return Integer.MAX_VALUE;
		// 1:0, 2:1, 3:1, 4:2, 5:2, 6:2, 7:2, 8:3
		int t = 31-Integer.numberOfLeadingZeros(r-l);
		return Math.min(table[t][l], table[t][r-(1<<t)]);
	}

	static class Point implements Comparable<Point> {
		long x;
		long y;
		long z;
		long id;
		// private int hashCode;

		Point() {
			x = z = y = 0;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(Point p) {
			this.x = p.x;
			this.y = p.y;
			this.z = p.z;
			this.id = p.id;
			// this.hashCode = Objects.hash(x, y, cost);
		}

		Point(long x, long y, long z, long id) {
			this.x = x;
			this.y = y;
			this.z = z;
			this.id = id;
			// this.hashCode = Objects.hash(x, y, id);
		}

		Point(long a, long b) {
			this.x = a;
			this.y = b;
			this.z = 0;
			// this.hashCode = Objects.hash(a, b);
		}

		Point(long x, long y, long id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}

		@Override
		public int compareTo(Point o) {
			if (this.x < o.x)
				return -1;
			if (this.x > o.x)
				return 1;
			if (this.y < o.y)
				return -1;
			if (this.y > o.y)
				return 1;
			if (this.z < o.z)
				return -1;
			if (this.z > o.z)
				return 1;
			return 0;
		}

		@Override
		public boolean equals(Object that) {
			return this.compareTo((Point) that) == 0;
		}

		/*@Override
		public int hashCode() {
			return this.hashCode;
		}*/
	}

	static class BinaryLift {

		// FUNCTIONS: k-th ancestor and LCA in log(n)

		int[] parentOf;
		int maxJmpPow;
		int[][] binAncestorOf;
		int n;
		int[] lvlOf;

		// How this works?

		// a. For every node, we store the b-ancestor for b in {1, 2, 4, 8, .. log(n)}.

		// b. When we need k-ancestor, we represent 'k' in binary and for each set bit, we
		//    lift level in the tree.

		public BinaryLift(UGraph tree) {
			n = tree.V();
			maxJmpPow = logk(n, 2) + 1;
			parentOf = new int[n];
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			parentConstruct(0, -1, tree, 0);
			binConstruct();
		}

		// TODO: Implement lvlOf[] initialization
		public BinaryLift(int[] parentOf) {
			this.parentOf = parentOf;
			n = parentOf.length;
			maxJmpPow = logk(n, 2) + 1;
			binAncestorOf = new int[n][maxJmpPow];
			lvlOf = new int[n];
			for (int i = 0; i < n; i++)
				Arrays.fill(binAncestorOf[i], -1);
			UGraph tree = new UGraph(n);
			for (int i = 1; i < n; i++)
				tree.addEdge(i, parentOf[i]);
			binConstruct();
			parentConstruct(0, -1, tree, 0);
		}

		private void parentConstruct(int current, int from, UGraph tree, int depth) {
			parentOf[current] = from;
			lvlOf[current] = depth;
			for (int adj : tree.adj(current))
				if (adj != from)
					parentConstruct(adj, current, tree, depth + 1);
		}

		private void binConstruct() {
			for (int node = 0; node < n; node++)
				for (int lvl = 0; lvl < maxJmpPow; lvl++)
					binConstruct(node, lvl);
		}

		private int binConstruct(int node, int lvl) {
			if (node < 0)
				return -1;
			if (lvl == 0)
				return binAncestorOf[node][lvl] = parentOf[node];
			if (node == 0)
				return binAncestorOf[node][lvl] = -1;

			if (binAncestorOf[node][lvl] != -1)
				return binAncestorOf[node][lvl];
			return binAncestorOf[node][lvl] = binConstruct(binConstruct(node, lvl - 1), lvl - 1);
		}

		// return ancestor which is 'k' levels above this one
		public int ancestor(int node, int k) {
			if (node < 0)
				return -1;
			if (node == 0)
				if (k == 0) return node;
				else return -1;
			if (k > (1 << maxJmpPow) - 1)
				return -1;
			if (k == 0)
				return node;

			int ancestor = node;
			int highestBit = Integer.highestOneBit(k);

			while (k > 0 && ancestor != -1) {
				ancestor = binAncestorOf[ancestor][logk(highestBit, 2)];
				k -= highestBit;
				highestBit = Integer.highestOneBit(k);
			}

			return ancestor;
		}

		public int lca(int u, int v) {

			if (u == v)
				return u;

			// The invariant will be that 'u' is below 'v' initially.
			if (lvlOf[u] < lvlOf[v]) {
				int temp = u;
				u = v;
				v = temp;
			}

			// Equalizing the levels.
			u = ancestor(u, lvlOf[u] - lvlOf[v]);

			if (u == v)
				return u;

			// We will now raise level by largest fitting power of two until possible.
			for (int power = maxJmpPow - 1; power > -1; power--)
				if (binAncestorOf[u][power] != binAncestorOf[v][power]) {
					u = binAncestorOf[u][power];
					v = binAncestorOf[v][power];
				}

			return ancestor(u, 1);
		}
	}

	static class DFSTree {

		// NOTE: The thing is made keeping in mind that the whole
		//  	 input graph is connected.

		UGraph tree;
		UGraph backUG;
		int hasBridge;
		int n;

		DFSTree(UGraph ug) {
			this.n = ug.V();
			tree = new UGraph(n);
			hasBridge = -1;
			backUG = new UGraph(n);
			treeCalc(0, -1, new boolean[n], ug);
		}

		private void treeCalc(int current, int from, boolean[] marked, UGraph ug) {
			if (marked[current]) {
				// This is a backEdge.
				backUG.addEdge(from, current);
				return;
			}

			if (from != -1)
				tree.addEdge(from, current);
			marked[current] = true;

			for (int adj : ug.adj(current))
				if (adj != from)
					treeCalc(adj, current, marked, ug);
		}

		public boolean hasBridge() {
			if (hasBridge != -1)
				return (hasBridge == 1);

			// We have to determine the bridge.
			bridgeFinder();
			return (hasBridge == 1);
		}

		int[] levelOf;
		int[] dp;

		private void bridgeFinder() {

			// Finding the level of each node.
			levelOf = new int[n];

			// Applying DP solution.
			// dp[i] -> Highest level reachable from subtree of 'i' using
			//   		some backEdge.
			dp = new int[n];
			Arrays.fill(dp, Integer.MAX_VALUE / 100);
			dpDFS(0, -1, 0);

			// Now, we will check each edge and determine whether its a
			// bridge.

			for (int i = 0; i < n; i++)
				for (int adj : tree.adj(i)) {

					// (i -> adj) is the edge.

					if (dp[adj] > levelOf[i])
						hasBridge = 1;
				}

			if (hasBridge != 1)
				hasBridge = 0;
		}

		private int dpDFS(int current, int from, int lvl) {
			levelOf[current] = lvl;
			dp[current] = levelOf[current];
			for (int back : backUG.adj(current))
				dp[current] = Math.min(dp[current], levelOf[back]);

			for (int adj : tree.adj(current))
				if (adj != from)
					dp[current] = Math.min(dp[current], dpDFS(adj, current, lvl + 1));

			return dp[current];
		}
	}

	static class UnionFind {
		// Uses weighted quick-union with path compression.
	    private int[] parent;  // parent[i] = parent of i
	    private int[] size;    // size[i] = number of sites in tree rooted at i
	                           // Note: not necessarily correct if i is not a root node
	    private int count;     // number of components

	    public UnionFind(int n) {
	        count = n;
	        parent = new int[n];
	        size = new int[n];
	        for (int i = 0; i < n; i++) {
	            parent[i] = i;
	            size[i] = 1;
	        }
	    }

	    // Number of connected components.
	    public int count() {
	        return count;
	    }

	    // Find the root of p.
	    public int find(int p) {
	    	while (p != parent[p])
	            p = parent[p];
	        return p;
	    }

	    public boolean connected(int p, int q) {
	        return find(p) == find(q);
	    }

	    public int numConnectedTo(int node) {
	    	return size[find(node)];
	    }

	    // Weighted union.
	    public void union(int p, int q) {
	        int rootP = find(p);
	        int rootQ = find(q);

	        if (rootP == rootQ) return;

	        // make smaller root point to larger one
	        if (size[rootP] < size[rootQ]) {
	            parent[rootP] = rootQ;
	            size[rootQ] += size[rootP];
	        }
	        else {
	            parent[rootQ] = rootP;
	            size[rootP] += size[rootQ];
	        }
	        count--;
	    }

	    public static int[] connectedComponents(UnionFind uf) {
	    	// We can do this in nlogn.

	    	int n = uf.size.length;
	    	int[] compoColors = new int[n];
	    	for (int i = 0; i < n; i++)
	    		compoColors[i] = uf.find(i);

	    	HashMap<Integer, Integer> oldToNew = new HashMap<>();
	    	int newCtr = 0;

	    	for (int i = 0; i < n; i++) {

	    		int thisOldColor = compoColors[i];
	    		Integer thisNewColor = oldToNew.get(thisOldColor);
	    		if (thisNewColor == null)
	    			thisNewColor = newCtr++;

	    		oldToNew.put(thisOldColor, thisNewColor);
	    		compoColors[i] = thisNewColor;
	    	}

	    	return compoColors;
	    }
	}

	static class UGraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public UGraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
			adj[to].add(from);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int degree(int v) {
			return adj[v].size();
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static void dfsMark(int current, boolean[] marked, UGraph g) {
			if (marked[current]) return;

			marked[current] = true;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, marked, g);
		}

		public static void dfsMark(int current, int from, long[] distTo, boolean[] marked, UGraph g, ArrayList<Integer> endPoints) {
			if (marked[current]) return;

			marked[current] = true;
			if (from != -1)
				distTo[current] = distTo[from] + 1;
			HashSet<Integer> adj = g.adj(current);
			int alreadyMarkedCtr = 0;
			for (int adjc : adj) {
				if (marked[adjc]) alreadyMarkedCtr++;
				dfsMark(adjc, current, distTo, marked, g, endPoints);
			}

			if (alreadyMarkedCtr == adj.size())
				endPoints.add(current);
		}

		public static void bfsOrder(int current, UGraph g) {
		}

		public static void dfsMark(int current, int[] colorIds, int color, UGraph g) {
			if (colorIds[current] != -1) return;

			colorIds[current] = color;
			Iterable<Integer> adj = g.adj(current);
			for (int adjc : adj)
				dfsMark(adjc, colorIds, color, g);
		}

		public static int[] connectedComponents(UGraph g) {
			int n = g.V();
			int[] componentId = new int[n];
			Arrays.fill(componentId, -1);
			int colorCtr = 0;
			for (int i = 0; i < n; i++) {
				if (componentId[i] != -1) continue;
				dfsMark(i, componentId, colorCtr, g);
				colorCtr++;
			}

			return componentId;
		}

		public static boolean hasCycle(UGraph ug) {
			int n = ug.V();
			boolean[] marked = new boolean[n];
			boolean[] hasCycleFirst = new boolean[1];
			for (int i = 0; i < n; i++) {
				if (marked[i]) continue;
				hcDfsMark(i, ug, marked, hasCycleFirst, -1);
			}
			return hasCycleFirst[0];
		}

		// Helper for hasCycle.
		private static void hcDfsMark(int current, UGraph ug, boolean[] marked, boolean[] hasCycleFirst, int parent) {
			if (marked[current]) return;
			if (hasCycleFirst[0]) return;

			marked[current] = true;
			HashSet<Integer> adjc = ug.adj(current);
			for (int adj : adjc) {
				if (marked[adj] && adj != parent && parent != -1) {
					hasCycleFirst[0] = true;
					return;
				}

				hcDfsMark(adj, ug, marked, hasCycleFirst, current);
			}
		}
	}

	static class Digraph {
		// Adjacency list.
		private HashSet<Integer>[] adj;
		private static final String NEWLINE = "\n";
		private int E;

		@SuppressWarnings("unchecked")
		public Digraph(int V) {
			adj = (HashSet<Integer>[]) new HashSet[V];
			E = 0;
			for (int i = 0; i < V; i++)
				adj[i] = new HashSet<Integer>();
		}

		public void addEdge(int from, int to) {
			if (adj[from].contains(to)) return;
			E++;
			adj[from].add(to);
		}

		public HashSet<Integer> adj(int from) {
			return adj[from];
		}

		public int V() {
			return adj.length;
		}

		public int E() {
			return E;
		}

		public Digraph reversed() {
			Digraph dg = new Digraph(V());
			for (int i = 0; i < V(); i++)
				for (int adjVert : adj(i)) dg.addEdge(adjVert, i);
			return dg;
		}

		public String toString() {
			StringBuilder s = new StringBuilder();
			s.append(V() + " vertices, " + E() + " edges " + NEWLINE);
			for (int v = 0; v < V(); v++) {
				s.append(v + ": ");
				for (int w : adj[v]) {
					s.append(w + " ");
				}
				s.append(NEWLINE);
			}
			return s.toString();
		}

		public static int[] KosarajuSharirSCC(Digraph dg) {
			int[] id = new int[dg.V()];

			Digraph reversed = dg.reversed();

			// Gotta perform topological sort on this one to get the stack.
			Stack<Integer> revStack = Digraph.topologicalSort(reversed);

			// Initializing id and idCtr.
			id = new int[dg.V()];
			int idCtr = -1;

			// Creating a 'marked' array.
			boolean[] marked = new boolean[dg.V()];

			while (!revStack.isEmpty()) {
				int vertex = revStack.pop();
				if (!marked[vertex])
					sccDFS(dg, vertex, marked, ++idCtr, id);
			}
			return id;
		}

		private static void sccDFS(Digraph dg, int source, boolean[] marked, int idCtr, int[] id) {
			marked[source] = true;
			id[source] = idCtr;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex]) sccDFS(dg, adjVertex, marked, idCtr, id);
		}

		public static Stack<Integer> topologicalSort(Digraph dg) {
			// dg has to be a directed acyclic graph.
			// We'll have to run dfs on the digraph and push the deepest nodes on stack first.
			// We'll need a Stack<Integer> and a int[] marked.
			Stack<Integer> topologicalStack = new Stack<Integer>();
			boolean[] marked = new boolean[dg.V()];

			// Calling dfs
			for (int i = 0; i < dg.V(); i++)
				if (!marked[i])
					runDfs(dg, topologicalStack, marked, i);

			return topologicalStack;
		}

		static void runDfs(Digraph dg, Stack<Integer> topologicalStack, boolean[] marked, int source) {
			marked[source] = true;
			for (Integer adjVertex : dg.adj(source))
				if (!marked[adjVertex])
					runDfs(dg, topologicalStack, marked, adjVertex);
			topologicalStack.add(source);
		}
	}

	static class FastReader {
		private BufferedReader bfr;
		private StringTokenizer st;
		public FastReader() {
			bfr = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			if (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(bfr.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());
		}

		char nextChar() {
			return next().toCharArray()[0];
		}

		String nextString() {
			return next();
		}

		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		double[] nextDoubleArray(int n) {
			double[] arr = new double[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextDouble();
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		int[][] nextIntGrid(int n, int m) {
			int[][] grid = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					grid[i][j] = fr.nextInt();
			}
			return grid;
		}
	}

	static class LCA {
	    int[] height, first, segtree;
	    ArrayList<Integer> euler;
	    boolean[] visited;
	    int n;

	    LCA(UGraph ug, int root) {
	        n = ug.V();
	        height = new int[n];
	        first = new int[n];
	        euler = new ArrayList<>();
	        visited = new boolean[n];
	        dfs(ug, root, 0);
	        int m = euler.size();
	        segtree = new int[m * 4];
	        build(1, 0, m - 1);
	    }

	    void dfs(UGraph ug, int node, int h) {
	        visited[node] = true;
	        height[node] = h;
	        first[node] = euler.size();
	        euler.add(node);
	        for (int adj : ug.adj(node)) {
	            if (!visited[adj]) {
	                dfs(ug, adj, h + 1);
	                euler.add(node);
	            }
	        }
	    }

	    void build(int node, int b, int e) {
	        if (b == e) {
	            segtree[node] = euler.get(b);
	        } else {
	            int mid = (b + e) / 2;
	            build(node << 1, b, mid);
	            build(node << 1 | 1, mid + 1, e);
	            int l = segtree[node << 1], r = segtree[node << 1 | 1];
	            segtree[node] = (height[l] < height[r]) ? l : r;
	        }
	    }

	    int query(int node, int b, int e, int L, int R) {
	        if (b > R || e < L)
	            return -1;
	        if (b >= L && e <= R)
	            return segtree[node];
	        int mid = (b + e) >> 1;

	        int left = query(node << 1, b, mid, L, R);
	        int right = query(node << 1 | 1, mid + 1, e, L, R);
	        if (left == -1) return right;
	        if (right == -1) return left;
	        return height[left] < height[right] ? left : right;
	    }

	    int lca(int u, int v) {
	        int left = first[u], right = first[v];
	        if (left > right) {
	        	int temp = left;
	        	left = right;
	        	right = temp;
	        }
	        return query(1, 0, euler.size() - 1, left, right);
	    }
	}

	static class FenwickTree {

	    long[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new long[size + 1];
	    }

	    public long rsq(int ind) {
	        assert ind > 0;
	        long sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }

	        return sum;
	    }

	    public long rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;

	        return rsq(b) - rsq(a - 1);
	    }

	    public void update(int ind, long value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }

	    public int size() {
	        return array.length - 1;
	    }
	}

	static class SegmentTree {

	    private Node[] heap;
	    private long[] array;
	    private int size;

	    public SegmentTree(long[] array) {
	        this.array = Arrays.copyOf(array, array.length);
	        //The max size of this array is about 2 * 2 ^ log2(n) + 1
	        size = (int) (2 * Math.pow(2.0, Math.floor((Math.log((double) array.length) / Math.log(2.0)) + 1)));
	        heap = new Node[size];
	        build(1, 0, array.length);
	    }

	    public int size() {
	        return array.length;
	    }

	    //Initialize the Nodes of the Segment tree
	    private void build(int v, int from, int size) {
	        heap[v] = new Node();
	        heap[v].from = from;
	        heap[v].to = from + size - 1;

	        if (size == 1) {
	            heap[v].sum = array[from];
	            heap[v].min = array[from];
	            heap[v].max = array[from];
	        } else {
	            //Build childs
	            build(2 * v, from, size / 2);
	            build(2 * v + 1, from + size / 2, size - size / 2);

	            heap[v].sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            //min = min of the children
	            heap[v].min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            heap[v].max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    public long rsq(int from, int to) {
	        return rsq(1, from, to);
	    }

	    private long rsq(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Sum without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return (to - from + 1) * n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].sum;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftSum = rsq(2 * v, from, to);
	            long rightSum = rsq(2 * v + 1, from, to);

	            return leftSum + rightSum;
	        }

	        return 0;
	    }

	    public long rMinQ(int from, int to) {
	        return rMinQ(1, from, to);
	    }

	    private long rMinQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].min;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMin = rMinQ(2 * v, from, to);
	            long rightMin = rMinQ(2 * v + 1, from, to);

	            return Math.min(leftMin, rightMin);
	        }

	        return Integer.MAX_VALUE;
	    }

	    public long rMaxQ(int from, int to) {
	        return rMaxQ(1, from, to);
	    }

	    private long rMaxQ(int v, int from, int to) {
	        Node n = heap[v];

	        //If you did a range update that contained this node, you can infer the Min value without going down the tree
	        if (n.pendingVal != null && contains(n.from, n.to, from, to)) {
	            return n.pendingVal;
	        }

	        if (contains(from, to, n.from, n.to)) {
	            return heap[v].max;
	        }

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);
	            long leftMax = rMaxQ(2 * v, from, to);
	            long rightMax = rMaxQ(2 * v + 1, from, to);

	            return Math.max(leftMax, rightMax);
	        }

	        return Integer.MIN_VALUE;
	    }

	    public void update(int from, int to, long value) {
	        update(1, from, to, value);
	    }

	    private void update(int v, int from, int to, long value) {

	        //The Node of the heap tree represents a range of the array with bounds: [n.from, n.to]
	        Node n = heap[v];

	        if (contains(from, to, n.from, n.to)) {
	            change(n, value);
	        }

	        if (n.size() == 1) return;

	        if (intersects(from, to, n.from, n.to)) {
	            propagate(v);

	            update(2 * v, from, to, value);
	            update(2 * v + 1, from, to, value);

	            n.sum = heap[2 * v].sum + heap[2 * v + 1].sum;
	            n.min = Math.min(heap[2 * v].min, heap[2 * v + 1].min);
	            n.max = Math.max(heap[2 * v].max, heap[2 * v + 1].max);
	        }
	    }

	    //Propagate temporal values to children
	    private void propagate(int v) {
	        Node n = heap[v];

	        if (n.pendingVal != null) {
	            change(heap[2 * v], n.pendingVal);
	            change(heap[2 * v + 1], n.pendingVal);
	            n.pendingVal = null; //unset the pending propagation value
	        }
	    }

	    //Save the temporal values that will be propagated lazily
	    private void change(Node n, long value) {
	        n.pendingVal = value;
	        n.sum = n.size() * value;
	        n.min = value;
	        n.max = value;
	        array[n.from] = value;
	    }

	    //Test if the range1 contains range2
	    private boolean contains(int from1, int to1, int from2, int to2) {
	        return from2 >= from1 && to2 <= to1;
	    }

	    //check inclusive intersection, test if range1[from1, to1] intersects range2[from2, to2]
	    private boolean intersects(int from1, int to1, int from2, int to2) {
	        return from1 <= from2 && to1 >= from2   //  (.[..)..] or (.[...]..)
	                || from1 >= from2 && from1 <= to2; // [.(..]..) or [..(..)..
	    }

	    //The Node class represents a partition range of the array.
	    static class Node {
	        long sum;
	        long min;
	        long max;
	        //Here we store the value that will be propagated lazily
	        Long pendingVal = null;
	        int from;
	        int to;

	        int size() {
	            return to - from + 1;
	        }
	    }
	}

	@SuppressWarnings("serial")
	static class CountMap<T> extends TreeMap<T, Integer>{

		CountMap() {
		}

		CountMap(T[] arr) {
			this.putCM(arr);
		}

		public Integer putCM(T key) {
			return super.put(key, super.getOrDefault(key, 0) + 1);
		}

		public Integer removeCM(T key) {
			int count = super.getOrDefault(key, -1);
			if (count == -1) return -1;
			if (count == 1)
				return super.remove(key);
			else
				return super.put(key, count - 1);
		}

		public Integer getCM(T key) {
			return super.getOrDefault(key, 0);
		}

		public void putCM(T[] arr) {
			for (T l : arr)
				this.putCM(l);
		}
	}

	static long dioGCD(long a, long b, long[] x0, long[] y0) {
	    if (b == 0) {
	        x0[0] = 1;
	        y0[0] = 0;
	        return a;
	    }
	    long[] x1 = new long[1], y1 = new long[1];
	    long d = dioGCD(b, a % b, x1, y1);
	    x0[0] = y1[0];
	    y0[0] = x1[0] - y1[0] * (a / b);
	    return d;
	}

	static boolean diophantine(long a, long b, long c, long[] x0, long[] y0, long[] g) {
	    g[0] = dioGCD(Math.abs(a), Math.abs(b), x0, y0);
	    if (c % g[0] > 0) {
	        return false;
	    }

	    x0[0] *= c / g[0];
	    y0[0] *= c / g[0];
	    if (a < 0) x0[0] = -x0[0];
	    if (b < 0) y0[0] = -y0[0];
	    return true;
	}

	static long[][] prod(long[][] mat1, long[][] mat2) {
		int n = mat1.length;
		long[][] prod = new long[n][n];

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				// determining prod[i][j]
				// it will be the dot product of mat1[i][] and mat2[][i]
				for (int k = 0; k < n; k++)
					prod[i][j] += mat1[i][k] * mat2[k][j];
		return prod;
	}
	static long[][] matExpo(long[][] mat, long power) {
		int n = mat.length;
		long[][] ans = new long[n][n];

		if (power == 0)
			return null;

		if (power == 1)
			return mat;

		long[][] half = matExpo(mat, power / 2);
		ans = prod(half, half);

		if (power % 2 == 1) {
			ans = prod(ans, mat);
		}

		return ans;
	}

	static int KMPNumOcc(char[] text, char[] pat) {
		int n = text.length;
		int m = pat.length;

		char[] patPlusText = new char[n + m + 1];
		for (int i = 0; i < m; i++)
			patPlusText[i] = pat[i];
		patPlusText[m] = '^'; 		// Seperator
		for (int i = 0; i < n; i++)
			patPlusText[m + i] = text[i];

		int[] fullPi = piCalcKMP(patPlusText);
		int answer = 0;
		for (int i = 0; i < n + m + 1; i++)
			if (fullPi[i] == m)
				answer++;
		return answer;
	}
	static int[] piCalcKMP(char[] s) {
		int n = s.length;
		int[] pi = new int[n];
		for (int i = 1; i < n; i++) {
			int j = pi[i - 1];
			while (j > 0 && s[i] != s[j])
				j = pi[j - 1];
			if (s[i] == s[j])
				j++;
			pi[i] = j;
		}
		return pi;
	}
	static long hash(long key) {
        long h = Long.hashCode(key);
        h ^= (h >>> 20) ^ (h >>> 12) ^ (h >>> 7) ^ (h >>> 4);
        return h & (gigamod-1);
    }

	static int mapTo1D(int row, int col, int n, int m) {
		// Maps elements in a 2D matrix serially to elements in
		// a 1D array.
		return row * m + col;
	}
	static int[] mapTo2D(int idx, int n, int m) {
		// Inverse of what the one above does.
		int[] rnc = new int[2];
		rnc[0] = idx / m;
		rnc[1] = idx % m;
		return rnc;
	}

	static boolean[] primeGenerator(int upto) {
		// Sieve of Eratosthenes:
		isPrime = new boolean[upto + 1];
		smallestFactorOf = new int[upto + 1];
		Arrays.fill(smallestFactorOf, 1);
		Arrays.fill(isPrime, true);
		isPrime[1] = isPrime[0] = false;

		for (long i = 2; i < upto + 1; i++)
			if (isPrime[(int) i]) {
				smallestFactorOf[(int) i] = (int) i;
				// Mark all the multiples greater than or equal
				// to the square of i to be false.
				for (long j = i; j * i < upto + 1; j++) {
					if (isPrime[(int) j * (int) i]) {
						isPrime[(int) j * (int) i] = false;
						smallestFactorOf[(int) j * (int) i] = (int) i;
					}
				}
			}
		return isPrime;
	}
	static HashMap<Integer, Integer> smolNumPrimeFactorization(int num) {
		if (smallestFactorOf == null)
			primeGenerator(num + 1);
		HashMap<Integer, Integer> fnps = new HashMap<>();
		while (num != 1) {
			fnps.put(smallestFactorOf[num], fnps.getOrDefault(smallestFactorOf[num], 0) + 1);
			num /= smallestFactorOf[num];
		}
		return fnps;
	}
	static HashMap<Long, Integer> primeFactorization(long num) {
		// Returns map of factor and its power in the number.
		HashMap<Long, Integer> map = new HashMap<>();
		while (num % 2 == 0) {
			num /= 2;
			Integer pwrCnt = map.get(2L);
			map.put(2L, pwrCnt != null ? pwrCnt + 1 : 1);
		}
		for (long i = 3; i * i <= num; i += 2) {
			while (num % i == 0) {
				num /= i;
				Integer pwrCnt = map.get(i);
				map.put(i, pwrCnt != null ? pwrCnt + 1 : 1);
			}
		}
		// If the number is prime, we have to add it to the
		// map.
		if (num != 1)
			map.put(num, 1);
		return map;
	}
	static HashSet<Long> divisors(long num) {
		HashSet<Long> divisors = new HashSet<Long>();
		divisors.add(1L);
		divisors.add(num);
		for (long i = 2; i * i <= num; i++) {
			if (num % i == 0) {
				divisors.add(num/i);
				divisors.add(i);
			}
		}
		return divisors;
	}
	static void coprimeGenerator(int m, int n, ArrayList<Point> coprimes, int limit, int numCoprimes) {
		if (m > limit) return;
		if (m <= limit && n <= limit)
			coprimes.add(new Point(m, n));
		if (coprimes.size() > numCoprimes) return;
		coprimeGenerator(2 * m - n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(2 * m + n, m, coprimes, limit, numCoprimes);
		coprimeGenerator(m + 2 * n, n, coprimes, limit, numCoprimes);
	}

	static int bsearch(int[] arr, int val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi) {
		// Returns the index of the first element
		// larger than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] >= val) {
				idx = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return idx;
	}
	static int bsearch(long[] arr, long val, int lo, int hi, boolean sMode) {
		// Returns the index of the last element
		// smaller than or equal to val.
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}
	static int bsearch(int[] arr, long val, int lo, int hi, boolean sMode) {
		int idx = -1;
		while (lo <= hi) {
			int mid = lo + (hi - lo)/2;
			if (arr[mid] > val) {
				hi = mid - 1;
			} else {
				idx = mid;
				lo = mid + 1;
			}
		}
		return idx;
	}

	static long nCr(long n, long r, long[] fac) { long p = gigamod; if (r == 0) return 1; return (fac[(int)n] * modInverse(fac[(int)r], p) % p * modInverse(fac[(int)n - (int)r], p) % p) % p; }
	static long modInverse(long n, long p) { return power(n, p - 2, p); }
	static long modDiv(long a, long b){return mod(a * power(b, gigamod - 2, gigamod));}
	static long power(long x, long y, long p) { long res = 1; x = x % p; while (y > 0) { if ((y & 1)==1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
	static int logk(long n, long k) { return (int)(Math.log(n) / Math.log(k)); }
	static long gcd(long a, long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } static long gcd(long[] arr) { int n = arr.length; long gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static int gcd(int[] arr) { int n = arr.length; int gcd = arr[0]; for (int i = 1; i < n; i++) { gcd = gcd(gcd, arr[i]); } return gcd; } static long lcm(long[] arr) { long lcm = arr[0]; int n = arr.length; for (int i = 1; i < n; i++) { lcm = (lcm * arr[i]) / gcd(lcm, arr[i]); } return lcm; } static long lcm(long a, long b) { return (a * b)/gcd(a, b); } static boolean less(int a, int b) { return a < b ? true : false; } static boolean isSorted(int[] a) { for (int i = 1; i < a.length; i++) { if (less(a[i], a[i - 1])) return false; } return true; } static boolean isSorted(long[] a) { for (int i = 1; i < a.length; i++) { if (a[i] < a[i - 1]) return false; } return true; } static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(long[] a, int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(double[] a, int i, int j) { double temp = a[i]; a[i] = a[j]; a[j] = temp; } static void swap(char[] a, int i, int j) { char temp = a[i]; a[i] = a[j]; a[j] = temp; }
	static void sort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void sort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); } static void reverseSort(int[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(char[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverse(char[] arr) { int n = arr.length; for (int i = 0; i < n / 2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(long[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); } static void reverseSort(double[] arr) { shuffleArray(arr, 0, arr.length - 1); Arrays.sort(arr); int n = arr.length; for (int i = 0; i < n/2; i++) swap(arr, i, n - 1 - i); }
	static void shuffleArray(long[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { long tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } } static void shuffleArray(int[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { int tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(double[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { double tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static void shuffleArray(char[] arr, int startPos, int endPos) { Random rnd = new Random(); for (int i = startPos; i < endPos; ++i) { char tmp = arr[i]; int randomPos = i + rnd.nextInt(endPos - i); arr[i] = arr[randomPos]; arr[randomPos] = tmp; } }
	static boolean isPrime(long n) {if (n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
	static String toString(int[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(boolean[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(long[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+" ");return sb.toString();}
	static String toString(char[] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++)sb.append(dp[i]+"");return sb.toString();}
	static String toString(int[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(long[][] dp){StringBuilder sb=new StringBuilder();for(int i=0;i<dp.length;i++){for(int j=0;j<dp[i].length;j++) {sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(double[][] dp){StringBuilder sb=new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+" ");}sb.append('\n');}return sb.toString();}
	static String toString(char[][] dp){StringBuilder sb = new StringBuilder();for(int i = 0;i<dp.length;i++){for(int j = 0;j<dp[i].length;j++){sb.append(dp[i][j]+"");}sb.append('\n');}return sb.toString();}
	static long mod(long a, long m){return(a%m+1000000L*m)%m;}
	static long mod(long num){return(num%gigamod+gigamod)%gigamod;}
}

// NOTES:
// ASCII VALUE OF 'A': 65
// ASCII VALUE OF 'a': 97
// Range of long: 9 * 10^18
// ASCII VALUE OF '0': 48
// Primes upto 'n' can be given by (n / (logn)).

import java.util.*;
import java.io.*;
public class Solution {

    public static Integer[][][] dp;

    public static int f(int p, int x, int lastTwoDigit, int len, String str) {
        if (p == len) {
            if (lastTwoDigit == 0 || lastTwoDigit == 25 || lastTwoDigit == 50 || lastTwoDigit == 75) {
                return 1;
            }
            return 0;
        }
        if (dp[p][x][lastTwoDigit] != null) {
            return dp[p][x][lastTwoDigit];
        }
        int ans = 0;
        if (str.charAt(p) == 'X') {
            if (x != 10) {
                ans = f(p + 1, x, (lastTwoDigit % 10) * 10 + x, len, str);
            } else {
                for (int i = (p == 0 ? 1 : 0); i < 10; i++) {
                    ans += f(p + 1, i, (lastTwoDigit % 10) * 10 + i, len, str);
                }
            }
        } else if (str.charAt(p) == '_') {
            for (int i = (p == 0 ? 1 : 0); i < 10; i++) {
                ans += f(p + 1, x, (lastTwoDigit % 10) * 10 + i, len, str);
            }
        } else {
            ans += f(p + 1, x, (lastTwoDigit % 10) * 10 + (str.charAt(p) - 48), len, str);
        }
        return dp[p][x][lastTwoDigit] = ans;
    }

    public static void solve(InputReader in, PrintWriter out) {
        String str = in.next();
        int len = str.length();
        if (len == 1) {
            if (str.charAt(0) == '0') {
                out.println(1);
            } else {
                out.println(0);
            }
        } else if (str.charAt(0) == '0') {
            out.println(0);
        } else {
            dp = new Integer[len][11][100];
            out.println(f(0, 10, 0, len, str));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

    }
}

import java.util.*;
import java.io.*;
public class Solution {

    public static Integer[][][][] dp;

    public static int f(int p, int x, int hasNonZero, int lastTwoDigit, int len, String str) {
        if (p == len) {
            if (lastTwoDigit == 0 || lastTwoDigit == 25 || lastTwoDigit == 50 || lastTwoDigit == 75) {
                return 1;
            }
            return 0;
        }
        if (dp[p][x][lastTwoDigit][hasNonZero] != null) {
            return dp[p][x][lastTwoDigit][hasNonZero];
        }
        int ans = 0;
        if (str.charAt(p) == 'X') {
            if (x != 10) {
                ans = f(p + 1, x, hasNonZero, (lastTwoDigit % 10) * 10 + x, len, str);
            } else {
                int y = 0;
                if (p == 0 || hasNonZero == 0) {
                    y = 1;
                }
                for (int i = y; i < 10; i++) {
                    if (p == 0) {
                        ans += f(p + 1, i, 1, i, len, str);
                    } else {
                        ans += f(p + 1, i, i == 0 ? hasNonZero : 1, (lastTwoDigit % 10) * 10 + i, len, str);
                    }
                }
            }
        } else if (str.charAt(p) == '_') {
            int y = 0;
            if (p == 0 || hasNonZero == 0) {
                y = 1;
            }
            for (int i = y; i < 10; i++) {
                if (p == 0) {
                    ans += f(p + 1, x, 1, i, len, str);
                } else {
                    ans += f(p + 1, x, i == 0 ? hasNonZero : 1, (lastTwoDigit % 10) * 10 + i, len, str);
                }
            }
        } else {
            if (p == 0) {
                ans += f(p + 1, x, 1, (str.charAt(p)-48), len, str);
            } else {
                ans += f(p + 1, x, 1, (lastTwoDigit % 10) * 10 + (str.charAt(p)-48), len, str);
            }
        }
        return dp[p][x][lastTwoDigit][hasNonZero] = ans;
    }

    public static void solve(InputReader in, PrintWriter out) {
        String str = in.next();
        int len = str.length();
        if (len == 1) {
            if (str.charAt(0) == '0') {
                out.println(1);
            } else {
                out.println(0);
            }
        } else if (str.charAt(0) == '0') {
            out.println(0);
        } else {
            dp = new Integer[len][11][100][2];
            out.println(f(0, 10, 0, 0, len, str));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

    }
}

import java.util.*;
import java.io.*;
public class Solution {

    public static Integer[][][][] dp;

    public static int f(int p, int x, int hasNonZero, int lastTwoDigit, int len, String str) {
        if (p == len) {
            if (lastTwoDigit == 0 || lastTwoDigit == 25 || lastTwoDigit == 50 || lastTwoDigit == 75) {
                return 1;
            }
            return 0;
        }
        if (dp[p][x][lastTwoDigit][hasNonZero] != null) {
            return dp[p][x][lastTwoDigit][hasNonZero];
        }
        int ans = 0;
        if (str.charAt(p) == 'X') {
            if (x != 10) {
                ans = f(p + 1, x, hasNonZero, (lastTwoDigit % 10) * 10 + x, len, str);
            } else {
                int y = 0;
                if (p == 0 || hasNonZero == 0) {
                    y = 1;
                }
                for (int i = y; i < 10; i++) {
                    if (p == 0) {
                        ans += f(p + 1, i, 1, i * 10, len, str);
                    } else {
                        ans += f(p + 1, i, i == 0 ? hasNonZero : 1, (lastTwoDigit % 10) * 10 + i, len, str);
                    }
                }
            }
        } else if (str.charAt(p) == '_') {
            int y = 0;
            if (p == 0 || hasNonZero == 0) {
                y = 1;
            }
            for (int i = y; i < 10; i++) {
                if (p == 0) {
                    ans += f(p + 1, x, 1, i * 10, len, str);
                } else {
                    ans += f(p + 1, x, i == 0 ? hasNonZero : 1, (lastTwoDigit % 10) * 10 + i, len, str);
                }
            }
        } else {
            if (p == 0) {
                ans += f(p + 1, x, 1, (str.charAt(p)-48) * 10, len, str);
            } else {
                ans += f(p + 1, x, 1, (lastTwoDigit % 10) * 10 + (str.charAt(p)-48), len, str);
            }
        }
        return dp[p][x][lastTwoDigit][hasNonZero] = ans;
    }

    public static void solve(InputReader in, PrintWriter out) {
        String str = in.next();
        int len = str.length();
        if (len == 1) {
            if (str.charAt(0) == '0') {
                out.println(1);
            } else {
                out.println(0);
            }
        } else if (str.charAt(0) == '0') {
            out.println(0);
        } else {
            dp = new Integer[len][11][100][2];
            out.println(f(0, 10, 0, 0, len, str));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

    }
}

import java.util.*;
import java.io.*;
public class DivisibleByTwentyFive {
    public static void main(String[] args) throws IOException {
        Reader in = new Reader();
        PrintWriter out = new PrintWriter(System.out);

        String s = in.next();
        int end = 1;
        for (int i = 0; i < s.length(); i++) {
           end *= 10;
        }
        int res = 0;
        for (int i = 0; i < end; i += 25) {
            if (match(s, i)) {
                res++;
            }
        }
        out.println(res);

        out.close();
    }
    public static boolean match(String s, int n) {
        int x = -1;
        for (int i = s.length() - 1; i >= 0; i--) {
            int d = n % 10;
            if (s.charAt(i) == 'X') {
                if (x >= 0 && x != d) {
                    return false;
                }
                x = d;
            } else if (s.charAt(i) != '_') {
                if (s.charAt(i) - '0' != d) {
                    return false;
                }
            }
            if (i == 0 && d == 0) {
                return false;
            }
            n /= 10;
        }
        return true;
    }
    static class Reader {
        BufferedReader in;
        StringTokenizer st;
        public Reader() {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }
        public String nextLine() throws IOException {
            st = new StringTokenizer("");
            return in.readLine();
        }
        public String next() throws IOException {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
    public static void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int i : arr) {
            list.add(i);
        }
        Collections.sort(list);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = list.get(i);
        }
    }
}

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

public class code{
  public static class Pair{
    int a;
    int b;
    Pair(int i,int j){
      a=i;
      b=j;
    }
  }

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

  public static void shuffle(int a[], int n)
  {
      for (int i = 0; i < n; i++) {

          // getting the random index
          int t = (int)Math.random() * a.length;

          // and swapping values a random index
          // with the current index
          int x = a[t];
          a[t] = a[i];
          a[i] = x;
      }
  }

  public static PrintWriter out = new PrintWriter(System.out);
  //@SuppressWarnings("unchecked")
  public static void main(String[] arg) throws IOException{
      //Reader in=new Reader();

      //PrintWriter out = new PrintWriter(System.out);
      //Scanner in = new Scanner(System.in);
      FastScanner in=new FastScanner();
      int t=1;

      while(t-- > 0){
        String s=in.next();
        if(s.equals("0")){
          out.println(1);
          continue;
        }
        char[] arr=s.toCharArray();

        int low=(int)Math.pow(10,s.length()-1);
        int high=(int)Math.pow(10,s.length())-25;
        while(low%25!=0) low++;
        int res=0;

        for(;low<=high;low+=25){
          String s1=Integer.toString(low);
          char[] c=s1.toCharArray();
          int count=1;
          char x='#';
          for(int i=0;i<arr.length;i++){
            if(arr[i]=='_') continue;
            if(arr[i]=='X'){
              if(x=='#') x=c[i];
              if(x!=c[i]){
                count=0;
                break;
              }
            }
            else if(arr[i]!=c[i]){
              count=0;
              break;
            }
          }
          res+=count;
        }

        out.println(res);
      }

      out.flush();
  }

}

class Fenwick{
  int[] bit;
  public Fenwick(int n){
    bit=new int[n];
    //int sum=0;
  }

  public void update(int index,int val){
    index++;
    for(;index<bit.length;index += index&(-index)) bit[index]+=val;
  }

  public int presum(int index){
    int sum=0;
    for(;index>0;index-=index&(-index)) sum+=bit[index];
    return sum;
  }

  public int sum(int l,int r){
    return presum(r+1)-presum(l);
  }
}

class FastScanner {

  private int BS = 1 << 16;
  private char NC = (char) 0;
  private byte[] buf = new byte[BS];
  private int bId = 0, size = 0;
  private char c = NC;
  private double cnt = 1;
  private BufferedInputStream in;

  public FastScanner() {
      in = new BufferedInputStream(System.in, BS);
  }

  public FastScanner(String s) {
      try {
          in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
      } catch (Exception e) {
          in = new BufferedInputStream(System.in, BS);
      }
  }

  private char getChar() {
      while (bId == size) {
          try {
              size = in.read(buf);
          } catch (Exception e) {
              return NC;
          }
          if (size == -1) return NC;
          bId = 0;
      }
      return (char) buf[bId++];
  }

  public int nextInt() {
      return (int) nextLong();
  }

  public int[] nextInts(int N) {
      int[] res = new int[N];
      for (int i = 0; i < N; i++) {
          res[i] = (int) nextLong();
      }
      return res;
  }

  public long[] nextLongs(int N) {
      long[] res = new long[N];
      for (int i = 0; i < N; i++) {
          res[i] = nextLong();
      }
      return res;
  }

  public long nextLong() {
      cnt = 1;
      boolean neg = false;
      if (c == NC) c = getChar();
      for (; (c < '0' || c > '9'); c = getChar()) {
          if (c == '-') neg = true;
      }
      long res = 0;
      for (; c >= '0' && c <= '9'; c = getChar()) {
          res = (res << 3) + (res << 1) + c - '0';
          cnt *= 10;
      }
      return neg ? -res : res;
  }

  public double nextDouble() {
      double cur = nextLong();
      return c != '.' ? cur : cur + nextLong() / cnt;
  }

  public double[] nextDoubles(int N) {
      double[] res = new double[N];
      for (int i = 0; i < N; i++) {
          res[i] = nextDouble();
      }
      return res;
  }

  public String next() {
      StringBuilder res = new StringBuilder();
      while (c <= 32) c = getChar();
      while (c > 32) {
          res.append(c);
          c = getChar();
      }
      return res.toString();
  }

  public String nextLine() {
      StringBuilder res = new StringBuilder();
      while (c <= 32) c = getChar();
      while (c != '\n') {
          res.append(c);
          c = getChar();
      }
      return res.toString();
  }

  public boolean hasNext() {
      if (c > 32) return true;
      while (true) {
          c = getChar();
          if (c == NC) return false;
          else if (c > 32) return true;
      }
  }
}

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

public class E {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int l = s.length();

        if(l < 2){
            if(s.equals("0")){
                System.out.println(1);
            }
            else{
                System.out.println(0);
            }
            System.exit(0);
        }
        else if(l == 2){
            int count = 0;
            for(int i=10;i<=95;i+=5){
                if(i%25 != 0)
                    continue;
                String str = Integer.toString(i);

                if('0'<=s.charAt(0) && s.charAt(0)<='9'){
                    if('0'<=s.charAt(1) && s.charAt(1)<='9'){
                        if(s.equals(str)){
                            count++;
                        }
                    }
                    else {
                        if(s.charAt(0)==str.charAt(0))
                            count++;
                    }
                }
                else if(s.charAt(0)=='_'){
                    if('0'<=s.charAt(1) && s.charAt(1)<='9'){
                        if(s.charAt(1)==str.charAt(1)){
                            count++;
                        }
                    }
                    else {
                        count++;
                    }
                }
                else{
                    if('0'<=s.charAt(1) && s.charAt(1)<='9'){
                        if(s.charAt(1)==str.charAt(1)){
                            count++;
                        }
                    }
                    else if(s.charAt(1)=='_'){
                        count++;
                    }
                }
            }

            System.out.println(count);
            System.exit(0);
        }
        else{
            int start = (int) (Math.pow(10, l-1));
            int end = (int) (Math.pow(10, l));

            int count = 0;
            for(int i=start;i<end;i+=25){
                String str = Integer.toString(i);

                Set<Character> set = new HashSet<>();
                boolean flag = true;
                for(int j=0;j<l;j++){
                    if(s.charAt(j)=='_')
                        continue;
                    else if(s.charAt(j)=='X'){
                        set.add(str.charAt(j));
                    }
                    else if(s.charAt(j)!=str.charAt(j)){
                        flag = false;
                        break;
                    }
                }

                if(flag && set.size() < 2){
                    count++;
                }
            }

            System.out.println(count);
        }

        /*int dash = 0, x = 0;
        for(int i=0;i<l;i++){
            if(s.charAt(i)=='X')
                x++;
            else if(s.charAt(i)=='_')
                dash++;
        }

        if((s.charAt(l-2)=='0' && s.charAt(l-1)=='0') || (s.charAt(l-2)=='2' && s.charAt(l-1)=='5') || (s.charAt(l-2)=='5' && s.charAt(l-1)=='0') || (s.charAt(l-2)=='7' && s.charAt(l-1)=='5')){
            if(s.charAt(0)=='_'){
                int ans = (int) (9 * Math.pow(10, dash - 1));
                if(x > 0)
                    ans *= 10;

                System.out.println(ans);
            }
            else if(s.charAt(0)=='X'){
                int ans = (int) (Math.pow(10, dash));
                ans *= 9;

                System.out.println(ans);
            }
            else{
                int ans = (int) Math.pow(10, dash);
                if(x > 0)
                    ans *= 10;

                System.out.println(ans);
            }
        }
        else if(s.charAt(l-2)=='_'){
            dash--;
            if(s.charAt(l-1)=='0' || s.charAt(l-1)=='5'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    if(x > 0)
                        ans *= 10;

                    ans *= 2;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 9;

                    ans *= 2;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    if(x > 0)
                        ans *= 10;

                    ans *= 2;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='_'){
                dash--;
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 9;

                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='X'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else{
                System.out.println();
            }
        }
        else if(s.charAt(l-2)=='X'){
            if(s.charAt(l-1)=='0'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 2;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);

                    ans *= 2;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='5'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 2;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 2;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);

                    ans *= 2;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='_'){
                dash--;
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 9;

                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    if(x > 0)
                        ans *= 10;

                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else if(s.charAt(l-1)=='X'){
                if(s.charAt(0)=='_'){
                    int ans = (int) (9 * Math.pow(10, dash - 1));
                    ans *= 4;

                    System.out.println(ans);
                }
                else if(s.charAt(0)=='X'){
                    int ans = (int) (Math.pow(10, dash));
                    ans *= 4;

                    System.out.println(ans);
                }
                else{
                    int ans = (int) Math.pow(10, dash);
                    ans *= 4;

                    System.out.println(ans);
                }
            }
            else{
                System.out.println();
            }
        }
        else{
            System.out.println(0);
        }*/

        sc.close();
    }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v.equals("XX") && s.charAt(0) == 'X') {
        ways = 0;
      }

      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (v.charAt(0) != 'X' && v.charAt(1) != 'X') {
        if (ok) {
          if (s.charAt(0) == 'X') {
            toti *= 1l * 9;
          } else {
            toti *= 1l * 10;
          }
        }
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v.equals("XX") && s.charAt(0) == 'X') {
        ways = 0;
      }

      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }

      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v.equals("XX") && s.charAt(0) == 'X') {
        ways = 0;
      }

      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    boolean r = true;
    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'X' || s.charAt(i) == '_') {
        continue;
      } else {
        if (s.charAt(i) != '0') {
          r = false;
        }
      }
    }
    if (r && (s.charAt(0) == '0' || s.length() == 1)) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    boolean r = true;
    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'X' || s.charAt(i) == '_') {
        continue;
      } else {
        if (s.charAt(i) != '0') {
          r = false;
        }
      }
    }
    if (r && (s.charAt(0) == '0' || s.length() == 1)) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    boolean r = true;
    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'X' || s.charAt(i) == '_') {
        continue;
      } else {
        if (s.charAt(i) != '0') {
          r = false;
        }
      }
    }
    if (r && (s.charAt(0) == '0' || s.length() == 1)) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    boolean r = true;
    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'X' || s.charAt(i) == '_') {
        continue;
      } else {
        if (s.charAt(i) != '0') {
          r = false;
        }
      }
    }
    if (r && (s.charAt(0) == '0' || s.length() == 1)) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    boolean r = true;
    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'X' || s.charAt(i) == '_') {
        continue;
      } else {
        if (s.charAt(i) != '0') {
          r = false;
        }
      }
    }
    if (r && s.charAt(0) == '0') {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    boolean r = true;
    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'X' || s.charAt(i) == '_') {
        continue;
      } else {
        if (s.charAt(i) != '0') {
          r = false;
        }
      }
    }
    if (r) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (s.charAt(0) == '0' && s.length() == 1) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (s.charAt(0) == '0' && s.length() == 1) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (s.charAt(0) == '0' || s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      } else if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      } else if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (s.charAt(0) == '0' || s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      } else if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      } else if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1];
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    int i;
    if (s.charAt(0) == '0' || s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 2, 1, 1 };
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_') {
        ways = 2;
      } else if (
        v.charAt(0) == 'X' || v.charAt(1) == '_' || v.charAt(1) == 'X'
      ) {
        ways = 1;
      }
      for (i = 0; i < 3; i++) {
        if (v.equals(arr1[i])) {
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      int xways = (v.charAt(0) == 'X' || v.charAt(1) == 'X')
        ? 1
        : (s.charAt(0) == 'X' ? 9 : 10);
      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}

/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0' || str[0] == 'X' || str[0] == '_') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    char cv = 'n'; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if((f != '_' || f2 != '0') && f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(char xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == '0' && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != 'n') xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    ret += add;
  }
}

/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0' || str[0] == 'X' || str[0] == '_') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    int cv = -1; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if((f != '_' || f2 != '0') && f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(int xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == 0 && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != -1) xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    ret += add;
  }
}

/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0' || str[0] == 'X' || str[0] == '_') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    int cv = -1; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(int xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == 0 && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != -1) xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    ret += add;
  }
}

/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    int cv = -1; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(int xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == 0 && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != -1) xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    ret += add;
  }
}

/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    int cv = -1; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(int xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if(xVal == 0 && str[0] == 'X') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != -1) xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    ret += add;
  }
}

//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0' || inp[0] == 'X' || inp[0] == '_') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                    idx++;
                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    if(cstr.compareTo("00") == 0) continue;
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }
        }

        System.out.println(count);

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

    //Shortcut function
    public static long lcm(long a , long b){
        return a * (b/gcd(a,b));
    }

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
   //--------------------------------------------------------
}

//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0' || inp[0] == 'X' || inp[0] == '_') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                    idx++;
                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }
        }

        System.out.println(count);

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

    //Shortcut function
    public static long lcm(long a , long b){
        return a * (b/gcd(a,b));
    }

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
   //--------------------------------------------------------
}

//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                    idx++;
                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }
        }

        System.out.println(count);

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

    //Shortcut function
    public static long lcm(long a , long b){
        return a * (b/gcd(a,b));
    }

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
   //--------------------------------------------------------
}

//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                    idx++;
                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }

            System.out.println(count); //

        }

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

    //Shortcut function
    public static long lcm(long a , long b){
        return a * (b/gcd(a,b));
    }

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
   //--------------------------------------------------------
}

// -----------------------------------      Duniya Madarchod Hai       -----------------------------------

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

public class Main
 {

/*

    public String wrd() throws IOException{return(read.next());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}
    public int[] ai(int n) throws IOException{int arr[] = new int[n];for(int i = 0; i<n; i++)arr[i] = read.nextInt();return(arr);}
    public double[] ad(int n) throws IOException
    {double arr[] = new double[n];for(int i = 0; i<n; i++)arr[i] = read.nextDouble();return(arr);}
    public long[] al(int n) throws IOException
    {long arr[] = new long[n];for(int i = 0; i<n; i++)arr[i] = read.nextLong();return(arr);}

    class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    InputStream inputStream = new FileInputStream("input.txt");
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                     br = new BufferedReader(inputStreamReader);
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
        }

    String next(){while (st == null || !st.hasMoreElements()){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());}
    String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}}

*/

    class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    din = new DataInputStream(new FileInputStream("input.txt"));
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    }
                    else {
                        continue;
                    }
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0,
                                BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
public String readLine() throws IOException{return(read.readLine());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}

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

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

    long getSum(long arr[], int start, int end)
    {
        if(start == 0)
            return arr[end];
        return(arr[end] - arr[start-1]);
    }
    long MODULO = 1000*1000l*1000l + 7l;
    StringBuilder sb;
    Reader read;
    //FastReader read;

    int count = 0;
    public void solve() throws IOException
    {
        //Scanner sn = new Scanner(System.in);
        sb = new StringBuilder();
        //read = new FastReader();
        read = new Reader();
        int tt = 1;

        for(int tk = 0; tk < tt; tk++)
        {
            String s  = read.readLine();
            s = s.substring(0, s.length()-1);
            char arr[] = s.toCharArray();

            int numX = 0;
            if(arr[0] == '0' && arr.length != 1)
            {
                sb.append(0);
                continue;
            }
            for(char c : arr)
            {
                if(c == 'X')
                    numX++;
            }

            char xStop = numX == 0 ? '0' : '9';

            for(char alpha = '0'; alpha <= xStop ;  alpha++)
            {
                dfs(arr, 0, alpha);
            }

            sb.append(count);

        }

        System.out.println(sb);
    }

    void dfs(char arr[], int idx, char xVal)
    {
        if(idx == arr.length)
        {
            if(check(arr))
                count++;
            return;
        }

        if(arr[idx] == 'X')
        {

            arr[idx] = xVal;
            dfs(arr, idx+1, xVal);
            arr[idx] = 'X';
        }
        else if(arr[idx] == '_')
        {
            //char start = idx ==0 ? '1' : '0';
            for(char curr = '0'; curr <= '9'; curr++)
            {
                arr[idx] = curr;
                dfs(arr, idx+1, xVal);
                arr[idx] = '_';
            }
        }
        else
        {
            dfs(arr, idx+1, xVal);
        }
    }

    boolean check(char arr[])
    {
        if(arr[0] == 0 && arr.length > 1)
            return false;
        //System.out.println("AT CHECK  "+Arrays.toString(arr));
        int temp = 0;
        for(int i = 0; i<arr.length; i++)
        {
            int num = arr[i] - '0';
            temp = temp * 10 + num;
        }

        return(temp % 25 == 0);
    }
}

// -----------------------------------      Duniya Madarchod Hai       -----------------------------------

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

public class Main
 {

/*

    public String wrd() throws IOException{return(read.next());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}
    public int[] ai(int n) throws IOException{int arr[] = new int[n];for(int i = 0; i<n; i++)arr[i] = read.nextInt();return(arr);}
    public double[] ad(int n) throws IOException
    {double arr[] = new double[n];for(int i = 0; i<n; i++)arr[i] = read.nextDouble();return(arr);}
    public long[] al(int n) throws IOException
    {long arr[] = new long[n];for(int i = 0; i<n; i++)arr[i] = read.nextLong();return(arr);}

    class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    InputStream inputStream = new FileInputStream("input.txt");
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                     br = new BufferedReader(inputStreamReader);
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
        }

    String next(){while (st == null || !st.hasMoreElements()){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());}
    String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}}

*/

    class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    din = new DataInputStream(new FileInputStream("input.txt"));
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    }
                    else {
                        continue;
                    }
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0,
                                BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
public String readLine() throws IOException{return(read.readLine());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}

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

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

    long getSum(long arr[], int start, int end)
    {
        if(start == 0)
            return arr[end];
        return(arr[end] - arr[start-1]);
    }
    long MODULO = 1000*1000l*1000l + 7l;
    StringBuilder sb;
    Reader read;
    //FastReader read;

    int count = 0;
    public void solve() throws IOException
    {
        //Scanner sn = new Scanner(System.in);
        sb = new StringBuilder();
        //read = new FastReader();
        read = new Reader();
        int tt = 1;

        for(int tk = 0; tk < tt; tk++)
        {
            String s  = read.readLine();
            s = s.substring(0, s.length()-1);
            char arr[] = s.toCharArray();

            int numX = 0;
            if(arr[0] == '0' && arr.length != 1)
            {
                sb.append(0);
                continue;
            }
            for(char c : arr)
            {
                if(c == 'X')
                    numX++;
            }

            char xStop = numX == 0 ? '0' : '9';

            for(char alpha = '0'; alpha <= xStop ;  alpha++)
            {
                dfs(arr, 0, alpha);
            }

            sb.append(count);

        }

        System.out.println(sb);
    }

    void dfs(char arr[], int idx, char xVal)
    {
        if(idx == arr.length)
        {
            if(check(arr))
                count++;
            return;
        }

        if(arr[idx] == 'X')
        {
            if(xVal == '0' && idx == 0)
                return;

            arr[idx] = xVal;
            dfs(arr, idx+1, xVal);
            arr[idx] = 'X';
        }
        else if(arr[idx] == '_')
        {
            char start = idx ==0 ? '1' : '0';
            for(char curr = start; curr <= '9'; curr++)
            {
                arr[idx] = curr;
                dfs(arr, idx+1, xVal);
                arr[idx] = '_';
            }
        }
        else
        {
            dfs(arr, idx+1, xVal);
        }
    }

    boolean check(char arr[])
    {
        //System.out.println("AT CHECK  "+Arrays.toString(arr));
        int temp = 0;
        for(int i = 0; i<arr.length; i++)
        {
            int num = arr[i] - '0';
            temp = temp * 10 + num;
        }

        return(temp % 25 == 0);
    }
}

// -----------------------------------      Duniya Madarchod Hai       -----------------------------------

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

public class Main
 {

/*

    public String wrd() throws IOException{return(read.next());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}
    public int[] ai(int n) throws IOException{int arr[] = new int[n];for(int i = 0; i<n; i++)arr[i] = read.nextInt();return(arr);}
    public double[] ad(int n) throws IOException
    {double arr[] = new double[n];for(int i = 0; i<n; i++)arr[i] = read.nextDouble();return(arr);}
    public long[] al(int n) throws IOException
    {long arr[] = new long[n];for(int i = 0; i<n; i++)arr[i] = read.nextLong();return(arr);}

    class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    InputStream inputStream = new FileInputStream("input.txt");
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                     br = new BufferedReader(inputStreamReader);
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
        }

    String next(){while (st == null || !st.hasMoreElements()){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());}
    String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}}

*/

    class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            if (System.getProperty("ONLINE_JUDGE") == null)
            {
                 try
                {
                    din = new DataInputStream(new FileInputStream("input.txt"));
                    System.setOut(new PrintStream(new FileOutputStream("output.txt")));
                }
               catch (Exception e)
               {
                e.printStackTrace();
               }
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    }
                    else {
                        continue;
                    }
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0,
                                BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
public String readLine() throws IOException{return(read.readLine());}
    public int ni() throws IOException{return(read.nextInt());}
    public double nd() throws IOException{return(read.nextDouble());}
    public long nl() throws IOException{return(read.nextLong());}

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

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

    long getSum(long arr[], int start, int end)
    {
        if(start == 0)
            return arr[end];
        return(arr[end] - arr[start-1]);
    }
    long MODULO = 1000*1000l*1000l + 7l;
    StringBuilder sb;
    Reader read;
    //FastReader read;

    int count = 0;
    public void solve() throws IOException
    {
        //Scanner sn = new Scanner(System.in);
        sb = new StringBuilder();
        //read = new FastReader();
        read = new Reader();
        int tt = 1;

        for(int tk = 0; tk < tt; tk++)
        {
            String s  = read.readLine();
            s = s.substring(0, s.length()-1);
            char arr[] = s.toCharArray();
            int numX = 0;
            if(arr[0] == '0')
            {
                sb.append(0);
                continue;
            }
            for(char c : arr)
            {
                if(c == 'X')
                    numX++;
            }

            char xStop = numX == 0 ? '0' : '9';

            for(char alpha = '0'; alpha <= xStop ;  alpha++)
            {
                dfs(arr, 0, alpha);
            }

            sb.append(count);

        }

        System.out.println(sb);
    }

    void dfs(char arr[], int idx, char xVal)
    {
        if(idx == arr.length)
        {
            if(check(arr))
                count++;
            return;
        }

        if(arr[idx] == 'X')
        {
            if(xVal == '0' && idx == 0)
                return;

            arr[idx] = xVal;
            dfs(arr, idx+1, xVal);
            arr[idx] = 'X';
        }
        else if(arr[idx] == '_')
        {
            char start = idx ==0 ? '1' : '0';
            for(char curr = start; curr <= '9'; curr++)
            {
                arr[idx] = curr;
                dfs(arr, idx+1, xVal);
                arr[idx] = '_';
            }
        }
        else
        {
            dfs(arr, idx+1, xVal);
        }
    }

    boolean check(char arr[])
    {
        //System.out.println("AT CHECK  "+Arrays.toString(arr));
        int temp = 0;
        for(int i = 0; i<arr.length; i++)
        {
            int num = arr[i] - '0';
            temp = temp * 10 + num;
        }

        return(temp % 25 == 0);
    }
}

import java.util.*;

import java.io.*;
import java.math.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;

public class Main {
	 private static class MyScanner {
	        private static final int BUF_SIZE = 2048;
	        BufferedReader br;

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

	        private boolean isSpace(char c) {
	            return c == '\n' || c == '\r' || c == ' ';
	        }

	        String next() {
	            try {
	                StringBuilder sb = new StringBuilder();
	                int r;
	                while ((r = br.read()) != -1 && isSpace((char)r));
	                if (r == -1) {
	                    return null;
	                }

	                sb.append((char) r);
	                while ((r = br.read()) != -1 && !isSpace((char)r)) {
	                    sb.append((char)r);
	                }
	                return sb.toString();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return null;
	        }

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

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

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

			BufferedReader br;
			StringTokenizer st;
			public Reader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			String next()
		    {
		        while (st == null || !st.hasMoreElements())
		        {
		            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());
		    }

		    String nextLine()
		    {
		        String str = "";
		        try
		        {
		            str = br.readLine();
		        }
		        catch (IOException e)
		        {
		            e.printStackTrace();
		        }
		        return str;
		    }
		}

	  static long mod = (long)(1e9 + 7);

	static void sort(long[] arr ) {
		 ArrayList<Long> al = new ArrayList<>();
		 for(long e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }
	static void sort(int[] arr ) {
		 ArrayList<Integer> al = new ArrayList<>();
		 for(int e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }

	static void sort(char[] arr) {
		ArrayList<Character> al = new ArrayList<Character>();
		for(char cc:arr) al.add(cc);
		Collections.sort(al);
		for(int i = 0 ;i<arr.length ;i++) arr[i] = al.get(i);
	}

	static long mod_mul(  long... a) {
		long ans = a[0]%mod;
		for(int i = 1 ; i<a.length ; i++) {
			ans = (ans * (a[i]%mod))%mod;
		}

		return ans;
	}
	static long mod_sum( long... a) {
		long ans = 0;
		for(long e:a) {
			ans = (ans + e)%mod;
		}
		return ans;
	}
	 static long gcd(long a, long b)
	  {
	     if (b == 0)
	        return a;
	     return gcd(b, a % b);
	  }
	 static boolean[] prime(int num) {
			boolean[] bool = new boolean[num];

		      for (int i = 0; i< bool.length; i++) {
		         bool[i] = true;
		      }
		      for (int i = 2; i< Math.sqrt(num); i++) {
		         if(bool[i] == true) {
		            for(int j = (i*i); j<num; j = j+i) {
		               bool[j] = false;
		            }
		         }
		      }
		      if(num >= 0) {
		    	  bool[0] = false;
		    	  bool[1] = false;
		      }

		      return bool;
		}

	 static long modInverse(long a, long m)
	    {
	        long g = gcd(a, m);

	          return   power(a, m - 2, m);

	    }
	   static long lcm(long a , long b) {
		   return (a*b)/gcd(a, b);
	   }
	   static int lcm(int a , int b) {
		   return (int)((a*b)/gcd(a, b));
	   }
	 static long power(long x, long y, long m){
	        if (y == 0) return 1; long p = power(x, y / 2, m) % m; p = (int)((p * (long)p) % m);
	        if (y % 2 == 0) return p; else return (int)((x * (long)p) % m); }

     static class Combinations{
	    	 private long[] z;
	    	 private long[] z1;
	    	 private long[] z2;
	    	 private long mod;
	    	  public Combinations(long N , long mod) {
	    		  this.mod = mod;
				z = new long[(int)N+1];
				z1 = new long[(int)N+1];
				z[0] = 1;
				for(int i =1 ; i<=N ; i++) z[i] = (z[i-1]*i)%mod;
			     z2 = new long[(int)N+1];
				z2[0] = z2[1] = 1;
			    for (int i = 2; i <= N; i++)
			        z2[i] = z2[(int)(mod % i)] * (mod - mod / i) % mod;

			    z1[0] = z1[1] = 1;

			    for (int i = 2; i <= N; i++)
			        z1[i] = (z2[i] * z1[i - 1]) % mod;
			}
	    	  long fac(long n) {
	    		  return z[(int)n];
	    	  }
	    	  long invrsNum(long n) {
	    		  return z2[(int)n];
	    	  }
	    	  long invrsFac(long n) {
	    		  return invrsFac((int)n);
	    	  }
	    	  long ncr(long N, long R)
	    	  {		if(R<0 || R>N ) return 0;
	    		    long ans = ((z[(int)N] * z1[(int)R])
	    		              % mod * z1[(int)(N - R)])
	    		             % mod;
	    		    return ans;
	    		}
	      }
	      static class DisjointUnionSets {
			    int[] rank, parent;
			    int n;

			    public DisjointUnionSets(int n)
			    {
			        rank = new int[n];
			        parent = new int[n];
			        this.n = n;
			        makeSet();
			    }

			    void makeSet()
			    {
			        for (int i = 0; i < n; i++) {

			            parent[i] = i;
			        }
			    }

			    int find(int x)
			    {
			        if (parent[x] != x) {

			            parent[x] = find(parent[x]);

			        }

			        return parent[x];
			    }

			    void union(int x, int y)
			    {
			        int xRoot = find(x), yRoot = find(y);

			        if (xRoot == yRoot)
			            return;

			        if (rank[xRoot] < rank[yRoot])

			            parent[xRoot] = yRoot;

			        else if (rank[yRoot] < rank[xRoot])

			            parent[yRoot] = xRoot;

			        else
			        {
			            parent[yRoot] = xRoot;

			            rank[xRoot] = rank[xRoot] + 1;
			        }
			    }
			}
	      static int max(int... a ) {
	    	  int max = a[0];
	    	  for(int e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static long max(long... a ) {
	    	  long max = a[0];
	    	  for(long e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static int min(int... a ) {
	    	  int min = a[0];
	    	  for(int e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static long min(long... a ) {
	    	  long min = a[0];
	    	  for(long e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static int[] KMP(String str) {
	    	  int n = str.length();
	    	  int[] kmp = new int[n];
	    	  for(int i = 1 ; i<n ; i++) {
	    		  int j = kmp[i-1];
	    		  while(j>0 && str.charAt(i) != str.charAt(j)) {
	    			  j = kmp[j-1];
	    		  }
	    		  if(str.charAt(i) == str.charAt(j)) j++;
	    		  kmp[i] = j;
	    	  }

	    	  return kmp;
	      }

/************************************************ Query **************************************************************************************/

/***************************************** 		Sparse Table	********************************************************/
	      static class SparseTable{

	    		private long[][] st;

	    		SparseTable(long[] arr){
	    			int n = arr.length;
	    			st = new long[n][25];
	    			log = new int[n+2];
	    			build_log(n+1);
	    			build(arr);
	    		}

	    		private void build(long[] arr) {
	    			int n = arr.length;

	    			for(int i = n-1 ; i>=0 ; i--) {
	    				for(int j = 0 ; j<25 ; j++) {
	    					int r = i + (1<<j)-1;
	    					if(r>=n) break;
	    					if(j == 0 ) st[i][j] = arr[i];
	    					else st[i][j] = Math.min(st[i][j-1] , st[ i + ( 1 << (j-1) ) ][ j-1 ] );
	    				}
	    			}
	    		}
	    		public long gcd(long a  ,long b) {
	    			if(a == 0) return b;
	    			return gcd(b%a , a);
	    		}
	    		public long query(int l ,int r) {
	    			int w = r-l+1;
	    			int power = log[w];
	    			return Math.min(st[l][power],st[r - (1<<power) + 1][power]);
	    		}
	    		private int[] log;
	    		void build_log(int n) {
	    			log[1] = 0;
	    			for(int i = 2 ; i<=n ; i++) {
	    				log[i] = 1 + log[i/2];
	    			}
	    		}
	    	}

/********************************************************	Segement Tree	*****************************************************/
/**
	 	 static class SegmentTree{
			 long[] tree;
			 long[] arr;
			 int n;
			 SegmentTree(long[] arr){
				 this.n = arr.length;
				 tree = new long[4*n+1];
				 this.arr = arr;
				 buildTree(0, n-1, 1);
			 }

			  void buildTree(int s ,int e  ,int index ) {
					if(s == e) {
						tree[index] = arr[s];
						return;
					}

					int mid = (s+e)/2;

					buildTree( s,  mid, 2*index);
					buildTree( mid+1, e, 2*index+1);

					tree[index] = Math.min(tree[2*index] , tree[2*index+1]);
				}

			 long query(int si ,int ei) {
				 return query(0 ,n-1 , si ,ei , 1   );
			 }
			 private long query( int ss ,int se ,int qs , int qe,int index) {

					if(ss>=qs && se<=qe) return tree[index];

					if(qe<ss || se<qs) return (long)(1e17);

					int mid = (ss + se)/2;
					long left = query( ss , mid , qs ,qe , 2*index);
					long right= query(mid + 1 , se , qs ,qe , 2*index+1);
					return Math.min(left, right);
				}
			 public void update(int index , int val) {
				 arr[index] = val;
				 for(long e:arr) System.out.print(e+" ");
				 update(index , 0 , n-1 , 1);
			 }
			 private void update(int id ,int si , int ei , int index) {
				 if(id < si || id>ei) return;
				 if(si == ei ) {
					 tree[index] = arr[id];
					 return;
				 }
				 if(si > ei) return;
				 int mid = (ei + si)/2;

					update( id,  si, mid , 2*index);
					update( id , mid+1, ei , 2*index+1);

					tree[index] = Math.min(tree[2*index] ,tree[2*index+1]);
			 }

		 }
		 */

/* ***************************************************************************************************************************************************/

//	      static MyScanner sc = new MyScanner(); // only in case of less memory
	      static Reader sc = new Reader();
	 static StringBuilder sb = new StringBuilder();
	 public static void main(String args[]) throws IOException {

		 int tc = 1;
//		  tc = sc.nextInt();

		 for(int i = 1 ; i<=tc ; i++) {

//			 sb.append("Case #" + i + ": "  );	// During KickStart && HackerCup
			 TEST_CASE();

		 }
		 System.out.print(sb);
	 }
	 static void TEST_CASE() {
		char[] arr = sc.next().toCharArray();

		int n = arr.length;
		if(n == 1) {
			if(arr[0] == '0' || arr[0] == '_' || arr[0] == 'X' ) sb.append("1\n");
			else sb.append("0\n");
			return;
		}
		if(arr[0] == '0') {
			sb.append("0\n");
			return;
		}
		boolean bool = false;
		for(char cc:arr) {
			if(cc == 'X') {
				bool = true;
				break;
			}
		}
		long tot = 0;
		if(bool) {

			for(int i = 0 ; i<10;  i++) {
				char[] temp = new char[n];
				for(int j = 0 ; j<n ; j++)
					temp[j] = arr[j];
				if(temp[0] == 'X' && i == 0) continue;
				for(int j = 0 ; j<n ; j++) {
					if(temp[j] == 'X') {
						temp[j] = (char)(i + '0');
					}
				}

				// we have arr without X
				long back = back(temp);
				long pre = 1;
				for(int j = 0 ; j<n-2 ; j++) {
					if(temp[j] == '_') {
						if(j == 0) pre *= 9;
						else pre *= 10;
					}
				}
				tot += pre*back;
				if(pre == 1 && back == 4) {
					tot--;
				}
			}
		}else {
			long back = back(arr);
			long pre = 1;
			for(int j = 0 ;j<n-2 ; j++) {
				if(arr[j] == '_') {
					if(j == 0) pre *= 9;
					else pre *= 10;
				}
			}
			tot += pre*back;
			if(pre == 1 && back == 4) {
				tot--;
			}
		}
		boolean flag = false;
		sb.append(tot+"\n");

	 }
	 static long back(char[] arr ) {
//		 System.out.println(String.valueOf(arr));
		 long tot = 0;
		 int n = arr.length;
		 if(fnc(arr, n-1) && fnc(arr , n-2)) {
			 long num = Long.parseLong(""+arr[n-2] + arr[n-1]);
			 if(num%25 == 0) return 1;
			 else return 0;
		 }else if(arr[n-1] == '_' && arr[n-2] == '_') {
			 return 4;
		 }else if(arr[n-1] == '_' ) {
			 if(arr[n-2] == '2' || arr[n-2] == '0' || arr[n-2] == '7' || arr[n-2] == '5')
				 return 1;
			 else return 0;
		 }else {
			 if(arr[n-1] == '0' || arr[n-1] == '5')
				 return 2;
			 else return 0;
		 }
		 }
	 static boolean fnc(char[] arr , int i) {
		 return arr[i] != '_' ;
	 }
}
/*******************************************************************************************************************************************************/

/**

 */

import java.util.*;

import java.io.*;
import java.math.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;

public class Main {
	 private static class MyScanner {
	        private static final int BUF_SIZE = 2048;
	        BufferedReader br;

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

	        private boolean isSpace(char c) {
	            return c == '\n' || c == '\r' || c == ' ';
	        }

	        String next() {
	            try {
	                StringBuilder sb = new StringBuilder();
	                int r;
	                while ((r = br.read()) != -1 && isSpace((char)r));
	                if (r == -1) {
	                    return null;
	                }

	                sb.append((char) r);
	                while ((r = br.read()) != -1 && !isSpace((char)r)) {
	                    sb.append((char)r);
	                }
	                return sb.toString();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return null;
	        }

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

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

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

			BufferedReader br;
			StringTokenizer st;
			public Reader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			String next()
		    {
		        while (st == null || !st.hasMoreElements())
		        {
		            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());
		    }

		    String nextLine()
		    {
		        String str = "";
		        try
		        {
		            str = br.readLine();
		        }
		        catch (IOException e)
		        {
		            e.printStackTrace();
		        }
		        return str;
		    }
		}

	  static long mod = (long)(1e9 + 7);

	static void sort(long[] arr ) {
		 ArrayList<Long> al = new ArrayList<>();
		 for(long e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }
	static void sort(int[] arr ) {
		 ArrayList<Integer> al = new ArrayList<>();
		 for(int e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }

	static void sort(char[] arr) {
		ArrayList<Character> al = new ArrayList<Character>();
		for(char cc:arr) al.add(cc);
		Collections.sort(al);
		for(int i = 0 ;i<arr.length ;i++) arr[i] = al.get(i);
	}

	static long mod_mul(  long... a) {
		long ans = a[0]%mod;
		for(int i = 1 ; i<a.length ; i++) {
			ans = (ans * (a[i]%mod))%mod;
		}

		return ans;
	}
	static long mod_sum( long... a) {
		long ans = 0;
		for(long e:a) {
			ans = (ans + e)%mod;
		}
		return ans;
	}
	 static long gcd(long a, long b)
	  {
	     if (b == 0)
	        return a;
	     return gcd(b, a % b);
	  }
	 static boolean[] prime(int num) {
			boolean[] bool = new boolean[num];

		      for (int i = 0; i< bool.length; i++) {
		         bool[i] = true;
		      }
		      for (int i = 2; i< Math.sqrt(num); i++) {
		         if(bool[i] == true) {
		            for(int j = (i*i); j<num; j = j+i) {
		               bool[j] = false;
		            }
		         }
		      }
		      if(num >= 0) {
		    	  bool[0] = false;
		    	  bool[1] = false;
		      }

		      return bool;
		}

	 static long modInverse(long a, long m)
	    {
	        long g = gcd(a, m);

	          return   power(a, m - 2, m);

	    }
	   static long lcm(long a , long b) {
		   return (a*b)/gcd(a, b);
	   }
	   static int lcm(int a , int b) {
		   return (int)((a*b)/gcd(a, b));
	   }
	 static long power(long x, long y, long m){
	        if (y == 0) return 1; long p = power(x, y / 2, m) % m; p = (int)((p * (long)p) % m);
	        if (y % 2 == 0) return p; else return (int)((x * (long)p) % m); }

     static class Combinations{
	    	 private long[] z;
	    	 private long[] z1;
	    	 private long[] z2;
	    	 private long mod;
	    	  public Combinations(long N , long mod) {
	    		  this.mod = mod;
				z = new long[(int)N+1];
				z1 = new long[(int)N+1];
				z[0] = 1;
				for(int i =1 ; i<=N ; i++) z[i] = (z[i-1]*i)%mod;
			     z2 = new long[(int)N+1];
				z2[0] = z2[1] = 1;
			    for (int i = 2; i <= N; i++)
			        z2[i] = z2[(int)(mod % i)] * (mod - mod / i) % mod;

			    z1[0] = z1[1] = 1;

			    for (int i = 2; i <= N; i++)
			        z1[i] = (z2[i] * z1[i - 1]) % mod;
			}
	    	  long fac(long n) {
	    		  return z[(int)n];
	    	  }
	    	  long invrsNum(long n) {
	    		  return z2[(int)n];
	    	  }
	    	  long invrsFac(long n) {
	    		  return invrsFac((int)n);
	    	  }
	    	  long ncr(long N, long R)
	    	  {		if(R<0 || R>N ) return 0;
	    		    long ans = ((z[(int)N] * z1[(int)R])
	    		              % mod * z1[(int)(N - R)])
	    		             % mod;
	    		    return ans;
	    		}
	      }
	      static class DisjointUnionSets {
			    int[] rank, parent;
			    int n;

			    public DisjointUnionSets(int n)
			    {
			        rank = new int[n];
			        parent = new int[n];
			        this.n = n;
			        makeSet();
			    }

			    void makeSet()
			    {
			        for (int i = 0; i < n; i++) {

			            parent[i] = i;
			        }
			    }

			    int find(int x)
			    {
			        if (parent[x] != x) {

			            parent[x] = find(parent[x]);

			        }

			        return parent[x];
			    }

			    void union(int x, int y)
			    {
			        int xRoot = find(x), yRoot = find(y);

			        if (xRoot == yRoot)
			            return;

			        if (rank[xRoot] < rank[yRoot])

			            parent[xRoot] = yRoot;

			        else if (rank[yRoot] < rank[xRoot])

			            parent[yRoot] = xRoot;

			        else
			        {
			            parent[yRoot] = xRoot;

			            rank[xRoot] = rank[xRoot] + 1;
			        }
			    }
			}
	      static int max(int... a ) {
	    	  int max = a[0];
	    	  for(int e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static long max(long... a ) {
	    	  long max = a[0];
	    	  for(long e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static int min(int... a ) {
	    	  int min = a[0];
	    	  for(int e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static long min(long... a ) {
	    	  long min = a[0];
	    	  for(long e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static int[] KMP(String str) {
	    	  int n = str.length();
	    	  int[] kmp = new int[n];
	    	  for(int i = 1 ; i<n ; i++) {
	    		  int j = kmp[i-1];
	    		  while(j>0 && str.charAt(i) != str.charAt(j)) {
	    			  j = kmp[j-1];
	    		  }
	    		  if(str.charAt(i) == str.charAt(j)) j++;
	    		  kmp[i] = j;
	    	  }

	    	  return kmp;
	      }

/************************************************ Query **************************************************************************************/

/***************************************** 		Sparse Table	********************************************************/
	      static class SparseTable{

	    		private long[][] st;

	    		SparseTable(long[] arr){
	    			int n = arr.length;
	    			st = new long[n][25];
	    			log = new int[n+2];
	    			build_log(n+1);
	    			build(arr);
	    		}

	    		private void build(long[] arr) {
	    			int n = arr.length;

	    			for(int i = n-1 ; i>=0 ; i--) {
	    				for(int j = 0 ; j<25 ; j++) {
	    					int r = i + (1<<j)-1;
	    					if(r>=n) break;
	    					if(j == 0 ) st[i][j] = arr[i];
	    					else st[i][j] = Math.min(st[i][j-1] , st[ i + ( 1 << (j-1) ) ][ j-1 ] );
	    				}
	    			}
	    		}
	    		public long gcd(long a  ,long b) {
	    			if(a == 0) return b;
	    			return gcd(b%a , a);
	    		}
	    		public long query(int l ,int r) {
	    			int w = r-l+1;
	    			int power = log[w];
	    			return Math.min(st[l][power],st[r - (1<<power) + 1][power]);
	    		}
	    		private int[] log;
	    		void build_log(int n) {
	    			log[1] = 0;
	    			for(int i = 2 ; i<=n ; i++) {
	    				log[i] = 1 + log[i/2];
	    			}
	    		}
	    	}

/********************************************************	Segement Tree	*****************************************************/
/**
	 	 static class SegmentTree{
			 long[] tree;
			 long[] arr;
			 int n;
			 SegmentTree(long[] arr){
				 this.n = arr.length;
				 tree = new long[4*n+1];
				 this.arr = arr;
				 buildTree(0, n-1, 1);
			 }

			  void buildTree(int s ,int e  ,int index ) {
					if(s == e) {
						tree[index] = arr[s];
						return;
					}

					int mid = (s+e)/2;

					buildTree( s,  mid, 2*index);
					buildTree( mid+1, e, 2*index+1);

					tree[index] = Math.min(tree[2*index] , tree[2*index+1]);
				}

			 long query(int si ,int ei) {
				 return query(0 ,n-1 , si ,ei , 1   );
			 }
			 private long query( int ss ,int se ,int qs , int qe,int index) {

					if(ss>=qs && se<=qe) return tree[index];

					if(qe<ss || se<qs) return (long)(1e17);

					int mid = (ss + se)/2;
					long left = query( ss , mid , qs ,qe , 2*index);
					long right= query(mid + 1 , se , qs ,qe , 2*index+1);
					return Math.min(left, right);
				}
			 public void update(int index , int val) {
				 arr[index] = val;
				 for(long e:arr) System.out.print(e+" ");
				 update(index , 0 , n-1 , 1);
			 }
			 private void update(int id ,int si , int ei , int index) {
				 if(id < si || id>ei) return;
				 if(si == ei ) {
					 tree[index] = arr[id];
					 return;
				 }
				 if(si > ei) return;
				 int mid = (ei + si)/2;

					update( id,  si, mid , 2*index);
					update( id , mid+1, ei , 2*index+1);

					tree[index] = Math.min(tree[2*index] ,tree[2*index+1]);
			 }

		 }
		 */

/* ***************************************************************************************************************************************************/

//	      static MyScanner sc = new MyScanner(); // only in case of less memory
	      static Reader sc = new Reader();
	 static StringBuilder sb = new StringBuilder();
	 public static void main(String args[]) throws IOException {

		 int tc = 1;
//		  tc = sc.nextInt();

		 for(int i = 1 ; i<=tc ; i++) {

//			 sb.append("Case #" + i + ": "  );	// During KickStart && HackerCup
			 TEST_CASE();

		 }
		 System.out.print(sb);
	 }
	 static void TEST_CASE() {
		char[] arr = sc.next().toCharArray();

		int n = arr.length;
		if(n == 1) {
			if(arr[0] == '0' || arr[0] == '_' || arr[0] == 'X' ) sb.append("1\n");
			else sb.append("0\n");
			return;
		}
		if(arr[0] == '0') {
			sb.append("0\n");
			return;
		}
		boolean bool = false;
		for(char cc:arr) {
			if(cc == 'X') {
				bool = true;
				break;
			}
		}
		long tot = 0;
		if(bool) {

			for(int i = 0 ; i<10;  i++) {
				char[] temp = new char[n];
				for(int j = 0 ; j<n ; j++)
					temp[j] = arr[j];
				if(temp[0] == 'X' && i == 0) continue;
				for(int j = 0 ; j<n ; j++) {
					if(temp[j] == 'X') {
						temp[j] = (char)(i + '0');
					}
				}

				// we have arr without X
				long back = back(temp);
				long pre = 1;
				for(int j = 0 ; j<n-2 ; j++) {
					if(temp[j] == '_') {
						if(j == 0) pre *= 9;
						else pre *= 10;
					}
				}
				tot += pre*back;
			}
		}else {
			long back = back(arr);
			long pre = 1;
			for(int j = 0 ;j<n-2 ; j++) {
				if(arr[j] == '_') {
					if(j == 0) pre *= 9;
					else pre *= 10;
				}
			}
			tot += pre*back;
		}
		sb.append(tot+"\n");

	 }
	 static long back(char[] arr ) {
//		 System.out.println(String.valueOf(arr));
		 long tot = 0;
		 int n = arr.length;
		 if(fnc(arr, n-1) && fnc(arr , n-2)) {
			 long num = Long.parseLong(""+arr[n-2] + arr[n-1]);
			 if(num%25 == 0) return 1;
			 else return 0;
		 }else if(arr[n-1] == '_' && arr[n-2] == '_') {
			 return 4;
		 }else if(arr[n-1] == '_' ) {
			 if(arr[n-2] == '2' || arr[n-2] == '0' || arr[n-2] == '7' || arr[n-2] == '5')
				 return 1;
			 else return 0;
		 }else {
			 if(arr[n-1] == '0' || arr[n-1] == '5')
				 return 2;
			 else return 0;
		 }
		 }
	 static boolean fnc(char[] arr , int i) {
		 return arr[i] != '_' ;
	 }
}
/*******************************************************************************************************************************************************/

/**

 */

import java.util.*;

import java.io.*;
import java.math.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;

public class Main {
	 private static class MyScanner {
	        private static final int BUF_SIZE = 2048;
	        BufferedReader br;

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

	        private boolean isSpace(char c) {
	            return c == '\n' || c == '\r' || c == ' ';
	        }

	        String next() {
	            try {
	                StringBuilder sb = new StringBuilder();
	                int r;
	                while ((r = br.read()) != -1 && isSpace((char)r));
	                if (r == -1) {
	                    return null;
	                }

	                sb.append((char) r);
	                while ((r = br.read()) != -1 && !isSpace((char)r)) {
	                    sb.append((char)r);
	                }
	                return sb.toString();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return null;
	        }

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

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

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

			BufferedReader br;
			StringTokenizer st;
			public Reader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			String next()
		    {
		        while (st == null || !st.hasMoreElements())
		        {
		            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());
		    }

		    String nextLine()
		    {
		        String str = "";
		        try
		        {
		            str = br.readLine();
		        }
		        catch (IOException e)
		        {
		            e.printStackTrace();
		        }
		        return str;
		    }
		}

	  static long mod = (long)(1e9 + 7);

	static void sort(long[] arr ) {
		 ArrayList<Long> al = new ArrayList<>();
		 for(long e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }
	static void sort(int[] arr ) {
		 ArrayList<Integer> al = new ArrayList<>();
		 for(int e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }

	static void sort(char[] arr) {
		ArrayList<Character> al = new ArrayList<Character>();
		for(char cc:arr) al.add(cc);
		Collections.sort(al);
		for(int i = 0 ;i<arr.length ;i++) arr[i] = al.get(i);
	}

	static long mod_mul(  long... a) {
		long ans = a[0]%mod;
		for(int i = 1 ; i<a.length ; i++) {
			ans = (ans * (a[i]%mod))%mod;
		}

		return ans;
	}
	static long mod_sum( long... a) {
		long ans = 0;
		for(long e:a) {
			ans = (ans + e)%mod;
		}
		return ans;
	}
	 static long gcd(long a, long b)
	  {
	     if (b == 0)
	        return a;
	     return gcd(b, a % b);
	  }
	 static boolean[] prime(int num) {
			boolean[] bool = new boolean[num];

		      for (int i = 0; i< bool.length; i++) {
		         bool[i] = true;
		      }
		      for (int i = 2; i< Math.sqrt(num); i++) {
		         if(bool[i] == true) {
		            for(int j = (i*i); j<num; j = j+i) {
		               bool[j] = false;
		            }
		         }
		      }
		      if(num >= 0) {
		    	  bool[0] = false;
		    	  bool[1] = false;
		      }

		      return bool;
		}

	 static long modInverse(long a, long m)
	    {
	        long g = gcd(a, m);

	          return   power(a, m - 2, m);

	    }
	   static long lcm(long a , long b) {
		   return (a*b)/gcd(a, b);
	   }
	   static int lcm(int a , int b) {
		   return (int)((a*b)/gcd(a, b));
	   }
	 static long power(long x, long y, long m){
	        if (y == 0) return 1; long p = power(x, y / 2, m) % m; p = (int)((p * (long)p) % m);
	        if (y % 2 == 0) return p; else return (int)((x * (long)p) % m); }

     static class Combinations{
	    	 private long[] z;
	    	 private long[] z1;
	    	 private long[] z2;
	    	 private long mod;
	    	  public Combinations(long N , long mod) {
	    		  this.mod = mod;
				z = new long[(int)N+1];
				z1 = new long[(int)N+1];
				z[0] = 1;
				for(int i =1 ; i<=N ; i++) z[i] = (z[i-1]*i)%mod;
			     z2 = new long[(int)N+1];
				z2[0] = z2[1] = 1;
			    for (int i = 2; i <= N; i++)
			        z2[i] = z2[(int)(mod % i)] * (mod - mod / i) % mod;

			    z1[0] = z1[1] = 1;

			    for (int i = 2; i <= N; i++)
			        z1[i] = (z2[i] * z1[i - 1]) % mod;
			}
	    	  long fac(long n) {
	    		  return z[(int)n];
	    	  }
	    	  long invrsNum(long n) {
	    		  return z2[(int)n];
	    	  }
	    	  long invrsFac(long n) {
	    		  return invrsFac((int)n);
	    	  }
	    	  long ncr(long N, long R)
	    	  {		if(R<0 || R>N ) return 0;
	    		    long ans = ((z[(int)N] * z1[(int)R])
	    		              % mod * z1[(int)(N - R)])
	    		             % mod;
	    		    return ans;
	    		}
	      }
	      static class DisjointUnionSets {
			    int[] rank, parent;
			    int n;

			    public DisjointUnionSets(int n)
			    {
			        rank = new int[n];
			        parent = new int[n];
			        this.n = n;
			        makeSet();
			    }

			    void makeSet()
			    {
			        for (int i = 0; i < n; i++) {

			            parent[i] = i;
			        }
			    }

			    int find(int x)
			    {
			        if (parent[x] != x) {

			            parent[x] = find(parent[x]);

			        }

			        return parent[x];
			    }

			    void union(int x, int y)
			    {
			        int xRoot = find(x), yRoot = find(y);

			        if (xRoot == yRoot)
			            return;

			        if (rank[xRoot] < rank[yRoot])

			            parent[xRoot] = yRoot;

			        else if (rank[yRoot] < rank[xRoot])

			            parent[yRoot] = xRoot;

			        else
			        {
			            parent[yRoot] = xRoot;

			            rank[xRoot] = rank[xRoot] + 1;
			        }
			    }
			}
	      static int max(int... a ) {
	    	  int max = a[0];
	    	  for(int e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static long max(long... a ) {
	    	  long max = a[0];
	    	  for(long e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static int min(int... a ) {
	    	  int min = a[0];
	    	  for(int e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static long min(long... a ) {
	    	  long min = a[0];
	    	  for(long e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static int[] KMP(String str) {
	    	  int n = str.length();
	    	  int[] kmp = new int[n];
	    	  for(int i = 1 ; i<n ; i++) {
	    		  int j = kmp[i-1];
	    		  while(j>0 && str.charAt(i) != str.charAt(j)) {
	    			  j = kmp[j-1];
	    		  }
	    		  if(str.charAt(i) == str.charAt(j)) j++;
	    		  kmp[i] = j;
	    	  }

	    	  return kmp;
	      }

/************************************************ Query **************************************************************************************/

/***************************************** 		Sparse Table	********************************************************/
	      static class SparseTable{

	    		private long[][] st;

	    		SparseTable(long[] arr){
	    			int n = arr.length;
	    			st = new long[n][25];
	    			log = new int[n+2];
	    			build_log(n+1);
	    			build(arr);
	    		}

	    		private void build(long[] arr) {
	    			int n = arr.length;

	    			for(int i = n-1 ; i>=0 ; i--) {
	    				for(int j = 0 ; j<25 ; j++) {
	    					int r = i + (1<<j)-1;
	    					if(r>=n) break;
	    					if(j == 0 ) st[i][j] = arr[i];
	    					else st[i][j] = Math.min(st[i][j-1] , st[ i + ( 1 << (j-1) ) ][ j-1 ] );
	    				}
	    			}
	    		}
	    		public long gcd(long a  ,long b) {
	    			if(a == 0) return b;
	    			return gcd(b%a , a);
	    		}
	    		public long query(int l ,int r) {
	    			int w = r-l+1;
	    			int power = log[w];
	    			return Math.min(st[l][power],st[r - (1<<power) + 1][power]);
	    		}
	    		private int[] log;
	    		void build_log(int n) {
	    			log[1] = 0;
	    			for(int i = 2 ; i<=n ; i++) {
	    				log[i] = 1 + log[i/2];
	    			}
	    		}
	    	}

/********************************************************	Segement Tree	*****************************************************/
/**
	 	 static class SegmentTree{
			 long[] tree;
			 long[] arr;
			 int n;
			 SegmentTree(long[] arr){
				 this.n = arr.length;
				 tree = new long[4*n+1];
				 this.arr = arr;
				 buildTree(0, n-1, 1);
			 }

			  void buildTree(int s ,int e  ,int index ) {
					if(s == e) {
						tree[index] = arr[s];
						return;
					}

					int mid = (s+e)/2;

					buildTree( s,  mid, 2*index);
					buildTree( mid+1, e, 2*index+1);

					tree[index] = Math.min(tree[2*index] , tree[2*index+1]);
				}

			 long query(int si ,int ei) {
				 return query(0 ,n-1 , si ,ei , 1   );
			 }
			 private long query( int ss ,int se ,int qs , int qe,int index) {

					if(ss>=qs && se<=qe) return tree[index];

					if(qe<ss || se<qs) return (long)(1e17);

					int mid = (ss + se)/2;
					long left = query( ss , mid , qs ,qe , 2*index);
					long right= query(mid + 1 , se , qs ,qe , 2*index+1);
					return Math.min(left, right);
				}
			 public void update(int index , int val) {
				 arr[index] = val;
				 for(long e:arr) System.out.print(e+" ");
				 update(index , 0 , n-1 , 1);
			 }
			 private void update(int id ,int si , int ei , int index) {
				 if(id < si || id>ei) return;
				 if(si == ei ) {
					 tree[index] = arr[id];
					 return;
				 }
				 if(si > ei) return;
				 int mid = (ei + si)/2;

					update( id,  si, mid , 2*index);
					update( id , mid+1, ei , 2*index+1);

					tree[index] = Math.min(tree[2*index] ,tree[2*index+1]);
			 }

		 }
		 */

/* ***************************************************************************************************************************************************/

//	      static MyScanner sc = new MyScanner(); // only in case of less memory
	      static Reader sc = new Reader();
	 static StringBuilder sb = new StringBuilder();
	 public static void main(String args[]) throws IOException {

		 int tc = 1;
//		  tc = sc.nextInt();

		 for(int i = 1 ; i<=tc ; i++) {

//			 sb.append("Case #" + i + ": "  );	// During KickStart && HackerCup
			 TEST_CASE();

		 }
		 System.out.print(sb);
	 }
	 static void TEST_CASE() {
		char[] arr = sc.next().toCharArray();

		int n = arr.length;
		if(n == 1) {
			if(arr[0] == '0' ) sb.append("1\n");
			else sb.append("0\n");
			return;
		}
		if(arr[0] == '0') {
			sb.append("0\n");
			return;
		}
		boolean bool = false;
		for(char cc:arr) {
			if(cc == 'X') {
				bool = true;
				break;
			}
		}
		long tot = 0;
		if(bool) {

			for(int i = 0 ; i<10;  i++) {
				char[] temp = new char[n];
				for(int j = 0 ; j<n ; j++)
					temp[j] = arr[j];
				if(temp[0] == 'X' && i == 0) continue;
				for(int j = 0 ; j<n ; j++) {
					if(temp[j] == 'X') {
						temp[j] = (char)(i + '0');
					}
				}

				// we have arr without X
				long back = back(temp);
				long pre = 1;
				for(int j = 0 ; j<n-2 ; j++) {
					if(temp[j] == '_') {
						if(j == 0) pre *= 9;
						else pre *= 10;
					}
				}
				tot += pre*back;
			}
		}else {
			long back = back(arr);
			long pre = 1;
			for(int j = 0 ;j<n-2 ; j++) {
				if(arr[j] == '_') {
					if(j == 0) pre *= 9;
					else pre *= 10;
				}
			}
			tot += pre*back;
		}
		sb.append(tot+"\n");

	 }
	 static long back(char[] arr ) {
//		 System.out.println(String.valueOf(arr));
		 long tot = 0;
		 int n = arr.length;
		 if(fnc(arr, n-1) && fnc(arr , n-2)) {
			 long num = Long.parseLong(""+arr[n-2] + arr[n-1]);
			 if(num%25 == 0) return 1;
			 else return 0;
		 }else if(arr[n-1] == '_' && arr[n-2] == '_') {
			 return 4;
		 }else if(arr[n-1] == '_' ) {
			 if(arr[n-2] == '2' || arr[n-2] == '0' || arr[n-2] == '7' || arr[n-2] == '5')
				 return 1;
			 else return 0;
		 }else {
			 if(arr[n-1] == '0' || arr[n-1] == '5')
				 return 2;
			 else return 0;
		 }
		 }
	 static boolean fnc(char[] arr , int i) {
		 return arr[i] != '_' ;
	 }
}
/*******************************************************************************************************************************************************/

/**

 */

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

public class Main {

	static AReader scan = new AReader();
	static char[] cs;
	static int res = 0;
	static int X = 0;
	static int n;

	static void dfs(int u,int s){
		if(u >= n){
			if(s % 25 == 0) res++;
			return;
		}
		int t = cs[u] - '0';
		if(t>=0 && t <= 9) dfs(u+1,s*10+t);
		else if(cs[u] == 'X') dfs(u+1,s*10+X);
		else {
			if (u == n - 1) {
				dfs(u + 1, s * 10 + 5);
				dfs(u + 1, s * 10);
			} else {
				for (int i = 0; i < 10; i++) {
					if (i == 0 && u == 0) continue;
					dfs(u + 1, s * 10 + i);
				}
			}
		}
	}

	static void solve() {
		cs = scan.next().toCharArray();
		n = cs.length;
		boolean flag = false;
		for(char c:cs){
			if(c == 'X'){
				flag = true;
				break;
			}
		}
		if(cs[0] == '0' && n != 1){
			System.out.println(0);
			return;
		}
		if(flag){
		for(int i = 0;i<10;i++) {
			X = i;
			dfs(0,0);
		}
		}else dfs(0,0);
		System.out.println(res);
	}

	public static void main(String[] args)  {
		//int T = scan.nextInt();
		//while (T-- > 0) {
		solve();
		//}
		//System.out.print(sb.toString());
	}
}

class AReader {
	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private StringTokenizer tokenizer = new StringTokenizer("");

	private String innerNextLine() {
		try {
			return reader.readLine();
		} catch (IOException ex) {
			return null;
		}
	}

	public boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String nextLine = innerNextLine();
			if (nextLine == null) {
				return false;
			}
			tokenizer = new StringTokenizer(nextLine);
		}
		return true;
	}

	public String nextLine() {
		tokenizer = new StringTokenizer("");
		return innerNextLine();
	}

	public String next() {
		hasNext();
		return tokenizer.nextToken();
	}

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

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

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

class Pair {
	int x,y;

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

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

public class Main {

	static AReader scan = new AReader();
	static char[] cs;
	static int res = 0;
	static int X = 0;
	static int n;

	static void dfs(int u,int s){
		if(u >= n){
			if(s % 25 == 0) res++;
			return;
		}
		int t = cs[u] - '0';
		if(t>=0 && t <= 9) dfs(u+1,s*10+t);
		else if(cs[u] == 'X') dfs(u+1,s*10+X);
		else {
			if (u == n - 1) {
				dfs(u + 1, s * 10 + 5);
				dfs(u + 1, s * 10);
			} else {
				for (int i = 0; i < 10; i++) {
					if (i == 0 && u == 0) continue;
					dfs(u + 1, s * 10 + i);
				}
			}
		}
	}

	static void solve() {
		cs = scan.next().toCharArray();
		n = cs.length;
		boolean flag = false;
		for(char c:cs){
			if(c == 'X'){
				flag = true;
				break;
			}
		}
		if(cs[0] == '0'){
			System.out.println(0);
			return;
		}
		if(flag){
		for(int i = 0;i<10;i++) {
			X = i;
			dfs(0,0);
		}
		}else dfs(0,0);
		System.out.println(res);
	}

	public static void main(String[] args)  {
		//int T = scan.nextInt();
		//while (T-- > 0) {
		solve();
		//}
		//System.out.print(sb.toString());
	}
}

class AReader {
	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private StringTokenizer tokenizer = new StringTokenizer("");

	private String innerNextLine() {
		try {
			return reader.readLine();
		} catch (IOException ex) {
			return null;
		}
	}

	public boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String nextLine = innerNextLine();
			if (nextLine == null) {
				return false;
			}
			tokenizer = new StringTokenizer(nextLine);
		}
		return true;
	}

	public String nextLine() {
		tokenizer = new StringTokenizer("");
		return innerNextLine();
	}

	public String next() {
		hasNext();
		return tokenizer.nextToken();
	}

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

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

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

class Pair {
	int x,y;

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

import java.io.*;
import java.util.*;
// Problem Link: https://codeforces.com/problemset/problem/1575/D
public class div25 {
    public static char[] str;
    public static int S;
    public static void main (String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().toCharArray();
        S = str.length;
        int ans = 0;
        if (S==1) {
            if (str[0]=='X' || str[0] == '_' || Integer.parseInt(String.valueOf(str[0])) == 0) ans = 1;
        }
        else {
            ans += count_possibilities(2, 5);
            ans += count_possibilities(5, 0);
            ans += count_possibilities(7, 5);
            ans += count_possibilities(0, 0); }
        System.out.println(ans);

    }
    static int count_possibilities(int end1, int end2) {
        //System.out.println(end1 + " " + end2);
        int X_val = -1;
        if (str[S-2]=='X') X_val = end1;
        else {
            if (str[S-2]!='_') {
                if (value(S-2) != end1) return 0; } }
        //System.out.println("reached here");
        if (str[S-1]=='X') {
            if (X_val != -1 && end2 != X_val) return 0;
            else X_val = end2; }
        else {
            if (str[S-1]!='_') {
                if (value(S-1) != end2) return 0; } }
        //System.out.println("reached HERE");
        int total = 1;
        for (int i=0;i<S-2;i++) {
//            System.out.println(total);
//            System.out.println(X_val);
//            System.out.println(i + " " + str[i]);
            if (i==0) {
                if (str[i]=='X' && X_val==0) return 0;
                if (value(0) == 0) return 0; }
            if (str[i]=='_') {
                if (i==0) total *= 9;
                else total *= 10; }
            if (str[i]=='X') {
                if (X_val != -1) continue;
                else {
                    X_val = 10; // represents that X can be any integer from 0 to 9 (or possibly 1 to 9)
                    if (i==0) total *= 9;
                    else total *= 10;
                }
            }
        }
        //System.out.println(total);
        return total;
    }

    static boolean isDigit(int pos) {
        if (str[pos]=='_' || str[pos]=='X') return false;
        else return true;
    }

    static int value(int pos) {
        if (!isDigit(pos)) return -1;
        return Integer.parseInt(String.valueOf(str[pos]));
    }
}

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

public class P1575D {
    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.nextToken().toCharArray();
        int ans = 0;

        if (s.length == 1) {
            if (s[0] == '0' || s[0] == '_' || s[0] == 'X') {
                ans = 1;
            }
        } else {
            int n = s.length;
            if (!(s[n - 1] == 'X' && s[n - 2] == 'X')) {
                // put 25
                if (canPut(s, n - 1, '5') && canPut(s, n - 2, '2')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '5');
                    put(s1, n - 2, '2');
                    ans += possible(s1);
                }
                // put 50
                if (canPut(s, n - 1, '0') && canPut(s, n - 2, '5')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '0');
                    put(s1, n - 2, '5');
                    ans += possible(s1);
                }
                // put 75
                if (canPut(s, n - 1, '5') && canPut(s, n - 2, '7')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '5');
                    put(s1, n - 2, '7');
                    ans += possible(s1);
                }
            }
            // put 00
            if (s[n - 1] == 'X' && s[n - 2] == 'X') {
                char[] s1 = Arrays.copyOf(s, n);
                put(s1, n - 1, '0');
                ans += possible(s1);
            } else if (canPut(s, n - 1, '0') && canPut(s, n - 2, '0')) {
                char[] s1 = Arrays.copyOf(s, n);
                put(s1, n - 1, '0');
                put(s1, n - 2, '0');
                ans += possible(s1);
            }
        }
        writer.println(ans);

        writer.flush();
    }

    private static boolean canPut(char[] s, int p, char d) {
        if (s[p] == 'X' || s[p] == '_') {
            return true;
        }
        return s[p] == d;
    }

    private static void put(char[] s, int p, char d) {
        if (s[p] == 'X') {
            replace(s, d);
        } else {
            s[p] = d;
        }
    }

    private static void replace(char[] s, char d) {
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'X') {
                s[i] = d;
            }
        }
    }

    private static int possible(char[] s) {
        int p = 1;

        if (s[0] == '0') {
            return 0;
        }
        if (s[0] == '_') {
            p *= 9;
        }
        for (int i = 1; i < s.length; i++) {
            if (s[i] == '_') {
                p *= 10;
            }
        }

        return p;
    }

    private static class MyScanner {
        private BufferedReader reader;
        private StringTokenizer st;

        public MyScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

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