description: Mr. Chanek has an integer represented by a string s. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, meaning they're the same digit.
  
  Mr. Chanek wants to count the number of possible integer s, where s is divisible by 25. Of course, s must not contain any leading zero. He can replace the character _ with any digit. He can also replace the character X with any digit, but it must be the same for every character X.
  
  As a note, a leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example, 0025 has two leading zeroes. An exception is the integer zero, (0 has no leading zero, but 0000 has three leading zeroes).
  
  Input
  
  One line containing the string s (1 ≤ |s| ≤ 8). The string s consists of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, _, and X.
  
  Output
  
  Output an integer denoting the number of possible integer s.
  
  Examples
  
  Input
  
  
  25
  
  
  Output
  
  
  1
  
  
  Input
  
  
  _00
  
  
  Output
  
  
  9
  
  
  Input
  
  
  _XX
  
  
  Output
  
  
  9
  
  
  Input
  
  
  0
  
  
  Output
  
  
  1
  
  
  Input
  
  
  0_25
  
  
  Output
  
  
  0
  
  Note
  
  In the first example, the only possible s is 25.
  
  In the second and third example, s ∈ \{100, 200,300,400,500,600,700,800,900\}.
  
  In the fifth example, all possible s will have at least one leading zero.
solution: 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));
      }
  }
  