#include <bits/stdc++.h>
using namespace std;
class ParseError {};
struct Edge {
  int from, to, cost;
  bool operator<(Edge e) { return cost < e.cost; }
};
bool isB(string &str, map<char, char> &m, string::const_iterator &state,
         string::const_iterator end) {
  if (state == end) return true;
  if (m[*state] == '0' || m[*state] == '1') {
    state++;
    return isB(str, m, state, end);
  } else {
    return false;
  }
}
bool isN(string &str, map<char, char> &m, string::const_iterator &state,
         string::const_iterator end) {
  if (state == end) return false;
  if (m[*state] == '0') {
    state++;
    if (state == end)
      return true;
    else
      return false;
  } else if (m[*state] == '1') {
    state++;
    return isB(str, m, state, end);
  } else
    return false;
}
bool isE(string &str, map<char, char> &m, string::const_iterator &state,
         string::const_iterator end);
bool isF(string &str, map<char, char> &m, string::const_iterator &state,
         string::const_iterator end) {
  if (state == end) return false;
  if (m[*state] == '-') {
    state++;
    return isF(str, m, state, end);
  } else if (m[*state] == '(') {
    state++;
    if (state == end) return false;
    end--;
    if (isE(str, m, state, end)) {
      state++;
      return true;
    } else {
      state++;
      return false;
    }
  } else {
    return isN(str, m, state, end);
  }
}
bool isT(string &str, map<char, char> &m, string::const_iterator &state,
         string::const_iterator end) {
  if (state == end) return false;
  string::const_iterator tmp = state;
  int paren = 0;
  if (m[*state] == '(') paren = 1;
  while (++state != end) {
    if (m[*state] == '*') {
      if (paren > 0) continue;
      if (!isF(str, m, tmp, state)) {
        return false;
      }
      tmp = state + 1;
    } else if (m[*state] == '(') {
      paren++;
    } else if (m[*state] == ')') {
      paren--;
    }
  }
  if (!isF(str, m, tmp, state)) {
    return false;
  }
  return true;
}
bool isE(string &str, map<char, char> &m, string::const_iterator &state,
         string::const_iterator end) {
  if (state == end) return false;
  string::const_iterator tmp = state;
  int paren = 0;
  if (m[*state] == '(') paren++;
  bool prod = false;
  while (++state != end) {
    if (m[*state] == '+' || m[*state] == '-') {
      if (paren > 0) continue;
      if (prod) {
        prod = false;
        continue;
      }
      prod = false;
      if (!isT(str, m, tmp, state)) {
        return false;
      }
      tmp = state + 1;
    } else if (m[*state] == '(') {
      prod = false;
      paren++;
    } else if (m[*state] == ')') {
      prod = false;
      paren--;
    } else if (m[*state] == '*') {
      prod = true;
    } else {
      prod = false;
    }
  }
  if (!isT(str, m, tmp, state)) {
    return false;
  }
  return true;
}
bool isQ(string str, map<char, char> &m) {
  int index = -1;
  for (int i = (int)(0); i < (int)(str.size()); i++) {
    if (m[str[i]] == '=') {
      if (index != -1) return false;
      index = i;
    }
  }
  if (index == -1) return false;
  int num = 0;
  for (int i = (int)(0); i < (int)(index); i++) {
    if (m[str[i]] == '(')
      num++;
    else if (m[str[i]] == ')')
      num--;
    if (num < 0) return false;
  }
  if (num != 0) return false;
  for (int i = (int)(index + 1); i < (int)(str.size()); i++) {
    if (m[str[i]] == '(')
      num++;
    else if (m[str[i]] == ')')
      num--;
    if (num < 0) return false;
  }
  if (num != 0) return false;
  for (int i = (int)(0); i < (int)(str.size()); i++) {
    if (m[str[i]] == '+') {
      if (i == 0 || !(m[str[i - 1]] == '0' || m[str[i - 1]] == '1' ||
                      m[str[i - 1]] == ')'))
        return false;
    }
  }
  string tmp = "";
  vector<char> charr(str.size());
  for (int i = (int)(0); i < (int)(str.size()); i++) {
    charr[i] = str[i];
  }
  for (int i = (int)(0); i < (int)(charr.size() - 1); i++) {
    if (m[charr[i]] == '-' && m[charr[i + 1]] == '-') {
      charr[i + 1] = '+';
    } else if (m[charr[i]] == '+' && m[charr[i + 1]] == '-') {
      charr[i + 1] = '-';
    } else {
      if (tmp.size() == 0 && charr[i] == '+') {
        continue;
      } else if (tmp.size() > 0 && m[tmp[tmp.size() - 1]] == '=' &&
                 charr[i] == '+') {
        continue;
      }
      tmp += charr[i];
    }
  }
  tmp += charr[charr.size() - 1];
  for (int i = (int)(0); i < (int)(tmp.size()); i++) {
    if (m[tmp[i]] == '=') {
      index = i;
      break;
    }
  }
  string::const_iterator state = tmp.begin();
  if (!isE(tmp, m, state, state + index)) return false;
  state++;
  if (!isE(tmp, m, state, tmp.end())) return false;
  return true;
}
int N(string &str, map<char, char> &m, string::const_iterator &state,
      string::const_iterator end) {
  int val = 0;
  while (state != end) {
    val <<= 1;
    if (m[*state] == '1') {
      val += 1;
    }
    state++;
  }
  return val;
}
int E(string &str, map<char, char> &m, string::const_iterator &state,
      string::const_iterator end);
int F(string &str, map<char, char> &m, string::const_iterator &state,
      string::const_iterator end) {
  if (state == end) return false;
  if (m[*state] == '-') {
    state++;
    return -F(str, m, state, end);
  } else if (m[*state] == '(') {
    state++;
    if (state == end) return false;
    end--;
    int val = E(str, m, state, end);
    state++;
    return val;
  } else {
    return N(str, m, state, end);
  }
}
int T(string &str, map<char, char> &m, string::const_iterator &state,
      string::const_iterator end) {
  if (state == end) return false;
  string::const_iterator tmp = state;
  int val = 1;
  int paren = 0;
  if (m[*state] == '(') paren = 1;
  while (++state != end) {
    if (m[*state] == '*') {
      if (paren > 0) continue;
      val *= F(str, m, tmp, state);
      tmp = state + 1;
    } else if (m[*state] == '(') {
      paren++;
    } else if (m[*state] == ')') {
      paren--;
    }
  }
  val *= F(str, m, tmp, state);
  return val;
}
int E(string &str, map<char, char> &m, string::const_iterator &state,
      string::const_iterator end) {
  string::const_iterator tmp = state;
  int val = 0;
  bool plus = true;
  int paren = 0;
  if (m[*state] == '(') paren = 1;
  bool prod = false;
  while (++state != end) {
    if (m[*state] == '+') {
      if (paren > 0) continue;
      if (prod) {
        prod = false;
        continue;
      }
      if (plus) {
        val += T(str, m, tmp, state);
      } else {
        val -= T(str, m, tmp, state);
      }
      prod = false;
      plus = true;
      tmp = state + 1;
    } else if (m[*state] == '-') {
      if (paren > 0) continue;
      if (prod) {
        prod = false;
        continue;
      }
      prod = false;
      if (plus) {
        val += T(str, m, tmp, state);
      } else {
        val -= T(str, m, tmp, state);
      }
      plus = false;
      tmp = state + 1;
    } else if (m[*state] == '(') {
      prod = false;
      paren++;
    } else if (m[*state] == ')') {
      prod = false;
      paren--;
    } else if (m[*state] == '*') {
      prod = true;
    } else {
      prod = false;
    }
  }
  if (plus) {
    val += T(str, m, tmp, state);
  } else {
    val -= T(str, m, tmp, state);
  }
  return val;
}
bool check(string str, map<char, char> &m) {
  string tmp = "";
  vector<char> charr(str.size());
  for (int i = (int)(0); i < (int)(str.size()); i++) {
    charr[i] = str[i];
  }
  for (int i = (int)(0); i < (int)(charr.size() - 1); i++) {
    if (m[charr[i]] == '-' && m[charr[i + 1]] == '-') {
      charr[i + 1] = '+';
    } else if (m[charr[i]] == '+' && m[charr[i + 1]] == '-') {
      charr[i + 1] = '-';
    } else {
      if (tmp.size() == 0 && charr[i] == '+') {
        continue;
      } else if (tmp.size() > 0 && m[tmp[tmp.size() - 1]] == '=' &&
                 charr[i] == '+') {
        continue;
      }
      tmp += charr[i];
    }
  }
  tmp += charr[charr.size() - 1];
  int index = -1;
  for (int i = (int)(0); i < (int)(tmp.size()); i++) {
    if (m[tmp[i]] == '=') {
      index = i;
      break;
    }
  }
  int lhs = 0, rhs = 0;
  string::const_iterator state = tmp.begin();
  lhs = E(tmp, m, state, state + index);
  state++;
  rhs = E(tmp, m, state, tmp.end());
  return lhs == rhs;
}
int main(void) {
  string str;
  cin >> str;
  vector<char> ch;
  set<char> st;
  for (char c : str) {
    if (c == '0' || c == '1' || c == '+' || c == '-' || c == '*' || c == '(' ||
        c == ')' || c == '=')
      continue;
    if (st.find(c) == st.end()) {
      st.insert(c);
      ch.push_back(c);
    }
  }
  if (ch.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  char simbol[] = {'0', '1', '+', '-', '*', '(', ')', '='};
  vector<int> perm(8);
  for (int i = (int)(0); i < (int)(8); i++) perm[i] = i;
  map<char, char> m;
  m['0'] = '0';
  m['1'] = '1';
  m['+'] = '+';
  m['-'] = '-';
  m['*'] = '*';
  m['('] = '(';
  m[')'] = ')';
  m['='] = '=';
  int count = 0;
  int ans = 0;
  do {
    for (int i = (int)(0); i < (int)(ch.size()); i++) {
      m[ch[i]] = simbol[perm[i]];
    }
    if (isQ(str, m)) {
      if (check(str, m)) {
        ans++;
      }
    }
  } while (next_permutation(perm.begin(), perm.end()));
  for (int i = (int)(1); i < (int)(9 - ch.size()); i++) {
    ans /= i;
  }
  cout << ans << endl;
  return 0;
}
