#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Expr {
  int kind = -1;
  int val = 0;
};
set<int> st;
string str = "#+-*/()";
void calc(vector<Expr> exp) {
  if((int)(exp.size()) == 1) {
    assert(exp[0].kind == 0);
    st.insert(exp[0].val);
    return;
  }
  for(int i=0;i<(int)(exp.size());++i) {
    if(i < (int)(exp.size())-2 && exp[i].kind == 5 && exp[i+2].kind == 6) {
      exp.erase(exp.begin() + i);
      exp.erase(exp.begin() + (i+1));
      calc(exp);
      return;
    }
  }
  for(int i=1;i<(int)(exp.size())-1;++i) {
    if(!(exp[i-1].kind == 0 && exp[i+1].kind == 0)) continue;
    if(exp[i].kind == 1) {
      int v1 = exp[i-1].val, v2 = exp[i+1].val;
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v1 + v2});
      calc(exp);
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v2});
      exp.insert(exp.begin() + (i-1), {1, -1});
      exp.insert(exp.begin() + (i-1), {0, v1});
    } else if(exp[i].kind == 2) {
      int v1 = exp[i-1].val, v2 = exp[i+1].val;
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v1 - v2});
      calc(exp);
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v2});
      exp.insert(exp.begin() + (i-1), {2, -1});
      exp.insert(exp.begin() + (i-1), {0, v1});
    } else if(exp[i].kind == 3) {
      int v1 = exp[i-1].val, v2 = exp[i+1].val;
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v1 * v2});
      calc(exp);
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v2});
      exp.insert(exp.begin() + (i-1), {3, -1});
      exp.insert(exp.begin() + (i-1), {0, v1});
    } else if(exp[i].kind == 4) {
      int v1 = exp[i-1].val, v2 = exp[i+1].val;
      if(v2 == 0) continue;
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v1 / v2});
      calc(exp);
      exp.erase(exp.begin() + (i-1));
      exp.insert(exp.begin() + (i-1), {0, v2});
      exp.insert(exp.begin() + (i-1), {4, -1});
      exp.insert(exp.begin() + (i-1), {0, v1});
    }
  }
}
void solve(string &s) {
  vector<Expr> exp;
  int n = (int)(s.size());
  int now = 0;
  for(int i=0;i<n;++i) {
    if('0' <= s[i] && s[i] <= '9') {
      now *= 10;
      now += s[i] - '0';
    } else if(now > 0) {
      exp.push_back({0, now});
      now = 0;
    }
    if(s[i] == '+') {
      exp.push_back({1, -1});
    } else if(s[i] == '-') {
      exp.push_back({2, -1});
    } else if(s[i] == '*') {
      exp.push_back({3, -1});
    } else if(s[i] == '/') {
      exp.push_back({4, -1});
    } else if(s[i] == '(') {
      exp.push_back({5, -1});
    } else if(s[i] == ')') {
      exp.push_back({6, -1});
    }
  }
  if(now > 0) {
    exp.push_back({0, now});
  }
  calc(exp);
  cout << (int)(st.size()) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    string s; cin >> s;
    if(s == "#") break;
    st.clear();
    solve(s);
  }
}



Measured memory_bytes: 3188