#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

string expr;
string oprs = "+-*/";

int to_int(int s, int t){
    int res = 0;
    int x = 1;
    for(int i=t-1; i>=s; i--){
        if('0'<=expr[i] && expr[i]<='9')
            res += x * (expr[i]-'0');
        else
            return -1;
        x *= 10;
    }
    
    return res;
}

vector<int> dfs(int s, int t){
    vector<int> res;
    
    int x = to_int(s, t);
    if(x >= 0){
        res.push_back(x);
        return res;
    }
    
    if(expr[s] == '(' && expr[t-1] == ')'){
        int i;
        int count = 0;
        for(i=s; i<t; i++){
            if(expr[i] == '(')
                count++;
            else if(expr[i] == ')')
                count--;
            if(count == 0)
                break;
        }
        if(i == t-1)
            return dfs(s+1, t-1);
    }
    
    int count = 0;
    for(int i=s; i<t; i++){
        char &c = expr[i];
        if(c == '('){
            count++;
        }else if(c == ')'){
            count--;
        }else if(c == '+'){
            if(count) continue;
                
            vector<int> v1 = dfs(s, i);
            vector<int> v2 = dfs(i+1, t);
            
            for(auto x1: v1)
                for(auto x2: v2)
                    res.push_back(x1+x2);
        
        }else if(c == '-'){
            if(count) continue;
            
            vector<int> v1 = dfs(s, i);
            vector<int> v2 = dfs(i+1, t);
            
            for(auto x1: v1)
                for(auto x2: v2)
                    res.push_back(x1-x2);
    
        }else if(c == '*'){
            if(count) continue;
            
            vector<int> v1 = dfs(s, i);
            vector<int> v2 = dfs(i+1, t);
            
            for(auto x1: v1)
                for(auto x2: v2)
                    res.push_back(x1*x2);
        
        }else if(c == '/'){
            if(count) continue;
            
            vector<int> v1 = dfs(s, i);
            vector<int> v2 = dfs(i+1, t);
            
            for(auto x1: v1)
                for(auto x2: v2) if(x2 != 0)
                    res.push_back(x1/x2);
        
        }else{
            //??°???
        }
            
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    
    return res;
}

void solve(){
    vector<int> res = dfs(0, expr.length());
    
    cout << res.size() << endl;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    while(cin>>expr, expr!="#")
        solve();
    
    return 0;
}

Measured memory_bytes: 1228