#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

bool NG ;
string s;
int p,num[100009];

int bnf1();

int bnf(){

  int r=0;
  if(s[p]=='-')p++,r=bnf()*(-1);
  else if(s[p]=='(')p++,r=bnf1(),p++;
  else while(isdigit(s[p]))r=(r*10)+(s[p++]-'0');
  //cout<<r<<endl;
  return r;
}

int bnf10(){
  int res=bnf();
  while( num[p]==10 ){
    int c=s[p++];
    if(c=='+') res+= bnf();
    if(c=='-') res-= bnf();
    if(c=='*') res*= bnf();
    if(c=='/'){
      int X=bnf();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf9(){
  int res=bnf10();
  while( num[p]==9 ){
    int c=s[p++];
    if(c=='+') res+= bnf10();
    if(c=='-') res-= bnf10();
    if(c=='*') res*= bnf10();
    if(c=='/'){
      int X=bnf10();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf8(){
  int res=bnf9();
  while( num[p]==8 ){
    int c=s[p++];
    if(c=='+') res+= bnf9();
    if(c=='-') res-= bnf9();
    if(c=='*') res*= bnf9();
    if(c=='/'){
      int X=bnf9();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf7(){
  int res=bnf8();
  while( num[p]==7 ){
    int c=s[p++];
    if(c=='+') res+= bnf8();
    if(c=='-') res-= bnf8();
    if(c=='*') res*= bnf8();
    if(c=='/'){
      int X=bnf8();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf6(){
  int res=bnf7();
  while( num[p]==6 ){
    int c=s[p++];
    if(c=='+') res+= bnf7();
    if(c=='-') res-= bnf7();
    if(c=='*') res*= bnf7();
    if(c=='/'){
      int X=bnf7();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf5(){
  int res=bnf6();
  while( num[p]==5 ){
    int c=s[p++];
    if(c=='+') res+= bnf6();
    if(c=='-') res-= bnf6();
    if(c=='*') res*= bnf6();
    if(c=='/'){
      int X=bnf6();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf4(){
  int res=bnf5();
  while( num[p]==4 ){
    int c=s[p++];
    if(c=='+') res+= bnf5();
    if(c=='-') res-= bnf5();
    if(c=='*') res*= bnf5();
    if(c=='/'){
      int X=bnf5();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf3(){
  int res=bnf4();
  while( num[p]==3 ){
    int c=s[p++];
    if(c=='+') res+= bnf4();
    if(c=='-') res-= bnf4();
    if(c=='*') res*= bnf4();
    if(c=='/'){
      int X=bnf4();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf2(){
  int res=bnf3();
  while( num[p]==2 ){
    int c=s[p++];
    if(c=='+') res+= bnf3();
    if(c=='-') res-= bnf3();
    if(c=='*') res*= bnf3();
    if(c=='/'){
      int X=bnf3();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

int bnf1(){

  int res=bnf2();
  while( num[p]==1 ){
    int c=s[p++];
    if(c=='+') res+= bnf2();
    if(c=='-') res-= bnf2();
    if(c=='*') res*= bnf2();
    if(c=='/'){
      int X=bnf2();
      if(X)res /= X;
      else NG=1;
    }
  }
  return res;
}

signed main(){

  vector<int>v;

  while(cin>>s){
    v.clear();
    memset(num,0,sizeof(num));

    if(s=="#")break;

    r(i,s.size()){
      if(s[i]=='+') v.push_back(i);
      if(s[i]=='-') v.push_back(i);
      if(s[i]=='*') v.push_back(i);
      if(s[i]=='/') v.push_back(i);
    }

    set<int>sum;

    do{
      int T=1; p=0; NG=0;

      r(i,v.size()){
        num[v[i]]=T++;
      }
      //cout<<T<<endl;

      int ans=bnf1();
      //cout<<ans<<endl;
      if(!NG)sum.insert(ans);

      //cout<<T<<endl;

    }while(next_permutation(v.begin(),v.end()));

    cout<<sum.size()<<endl;
    //exit(0);
  }
}


Measured memory_bytes: 4024