#include <bits/stdc++.h>
bool debug = true;
typedef struct ParseState {
  int pos;
  int len;
  std::string str;
  std::deque<int> stack;
  bool isEOF() { return pos >= len; }
  bool isNotEOF() { return pos < len; }
  void eat(char ch) {
    assert(pos < len && str[pos] == ch);
    pos++;
  }
  char getCh() {
    assert(pos < len);
    return pos < len ? str[pos++] : -1;
  }
  char seek() { return pos < len ? str[pos] : -1; }
  char seek(int offset) {
    return (pos + offset) < len ? str[pos + offset] : -1;
  }
  void setBacktrack() { stack.push_front(pos); }
  void delBacktrack() {
    assert(!stack.empty());
    stack.pop_front();
  }
  void backtrack() {
    assert(!stack.empty());
    pos = stack.front();
    stack.pop_front();
  }
  bool isDigit() { return isDigit(0); }
  bool isDigit(int offset) {
    char c = seek(offset);
    return c >= '0' && c <= '9';
  }
  bool isUpperAlpha() { return isUpperAlpha(0); }
  bool isUpperAlpha(int offset) {
    char c = seek(offset);
    return c >= 'A' && c <= 'Z';
  }
  bool isLowerAlpha() { return isLowerAlpha(0); }
  bool isLowerAlpha(int offset) {
    char c = seek(offset);
    return c >= 'a' && c <= 'z';
  }
  bool isAlpha() { return isLowerAlpha(0) || isUpperAlpha(0); }
  bool isAlpha(int offset) {
    return isLowerAlpha(offset) || isUpperAlpha(offset);
  }
  bool isAlphaNum() { return isLowerAlpha(0) || isUpperAlpha(0) || isDigit(0); }
  bool isAlphaNum(int offset) {
    return isLowerAlpha(offset) || isUpperAlpha(offset) || isDigit(offset);
  }
} State;
bool parseQ(State* s);
std::pair<bool, int> parseE(State* s);
std::pair<bool, int> parseT(State* s);
std::pair<bool, int> parseF(State* s);
std::pair<bool, int> parseN(State* s);
bool parseQ(State* s) {
  std::pair<bool, int> eres1 = parseE(s);
  if (!eres1.first || s->seek() != '=') return false;
  s->eat('=');
  std::pair<bool, int> eres2 = parseE(s);
  if (!eres2.first || s->isNotEOF()) return false;
  return eres1.second == eres2.second;
}
std::pair<bool, int> parseE(State* s) {
  std::pair<bool, int> tres = parseT(s);
  if (!tres.first) return tres;
  int ans = tres.second;
  while (s->seek() == '+' || s->seek() == '-') {
    char op = s->getCh();
    tres = parseT(s);
    if (!tres.first) return tres;
    ans += (op == '+' ? 1 : -1) * tres.second;
  }
  return std::make_pair(true, ans);
}
std::pair<bool, int> parseT(State* s) {
  std::pair<bool, int> fres = parseF(s);
  if (!fres.first) return fres;
  int ans = fres.second;
  while (s->seek() == '*') {
    s->eat('*');
    fres = parseF(s);
    if (!fres.first) return fres;
    ans *= fres.second;
  }
  return std::make_pair(true, ans);
}
std::pair<bool, int> parseF(State* s) {
  char c = s->seek();
  if (c == '0' || c == '1') return parseN(s);
  if (c == '-') {
    s->eat('-');
    auto fres = parseF(s);
    fres.second *= -1;
    return fres;
  }
  if (c == '(') {
    s->eat('(');
    auto eres = parseE(s);
    if (!eres.first || s->seek() != ')') {
      return std::make_pair(false, 0);
    }
    s->eat(')');
    return eres;
  }
  return std::make_pair(false, 0);
}
std::pair<bool, int> parseN(State* s) {
  if (s->seek() == '0' && (s->seek(1) == '0' || s->seek(1) == '1')) {
    return std::make_pair(false, 0);
  }
  int v = 0;
  while (s->isNotEOF()) {
    char c = s->seek();
    if (c != '0' && c != '1') {
      break;
    }
    s->getCh();
    v = (v << 1) + (int)(c - '0');
  }
  return std::make_pair(true, v);
}
int main() {
  std::string input;
  std::cin >> input;
  int input_size = input.size();
  std::vector<char> symbol{{'0', '1', '+', '-', '*', '(', ')', '='}};
  std::sort((symbol).begin(), (symbol).end());
  std::string chars = input;
  std::sort((chars).begin(), chars.end()),
      chars.erase(std::unique((chars).begin(), chars.end()), chars.end());
  ;
  int chars_size = chars.size();
  int ans = 0;
  std::set<std::map<char, char> > pattern;
  do {
    std::map<char, char> map;
    for (long i = 0; i < (chars_size); ++i) {
      map[chars[i]] = symbol[i];
    }
    if (pattern.count(map) > 0) continue;
    pattern.insert(map);
    std::string str = input;
    for (long i = 0; i < (input_size); ++i) {
      str[i] = map[str[i]];
    }
    State state = State{0, input_size, str};
    if (parseQ(&state)) {
      std::cout << str << std::endl;
      ans++;
    }
  } while (std::next_permutation((symbol).begin(), symbol.end()));
  std::cout << ans << std::endl;
}
