s = ""
ans = 0
slen = 0
d = {}
u = {
    "+": False,
    "-": False,
    "*": False,
    "0": False,
    "1": False,
    "=": False,
    "(": False,
    ")": False
}

def dfs(p):
    global slen, ans, s
    if p == slen:
        tmp = ""
        cnte = 0
        for i in s:
            if i in d:
                tmp = tmp + d[i]
                if d[i] == "=":
                    cnte = cnte + 1
            else:
                tmp = tmp + i
                if i == "=":
                    cnte = cnte + 1

        if cnte != 1:
            return
        if tmp[0] == "=" or tmp[slen - 1] == "=":
            return
        if tmp[0] == "+":
            return
        for i in range(1, slen):
            if tmp[i] == tmp[i - 1] and tmp[i] == "*":
                return
            if tmp[i] == "+" and tmp[i - 1] == "-":
                return
            if tmp[i] == "+" and tmp[i - 1] == "+":
                return
            if tmp[i] == "+" and tmp[i - 1] == "*":
                return
            if tmp[i] == "+" and tmp[i - 1] == "=":
                return
            if tmp[i] == "+" and tmp[i - 1] == "(":
                return

        lst = 2
        for i in range(slen):
            if tmp[i] == "0" or tmp[i] == "1":
                if lst == 0:
                    return
                if lst == 2 and tmp[i] == "0":
                    lst = 0
                else: lst = 1
            else: lst = 2

        tt = ""
        lastnum = False
        for i in tmp:
            if i == "0" or i == "1":
                if lastnum == False:
                    tt = tt + "0b"
                lastnum = True
            else: lastnum = False
            tt = tt + i

        try:
            (le, re) = tt.split("=")
            if eval(le) == eval(re):
                ans = ans + 1
        except Exception as e:
            pass
        return

    flag = False
    for (key, value) in u.items():
        if s[p] == key:
            flag = True
            break

    if flag or s[p] in d:
        dfs(p + 1)
    else:
        for (key, value) in u.items():
            if not value:
                d[s[p]] = key
                u[key] = True
                dfs(p + 1)
                del d[s[p]]
                u[key] = False

s = input()
slen = len(s)
dfs(0)
print(ans)