#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

ll gcd(ll a,ll b){
  ll r=a%b;
  while(r>0){a=b;b=r;r=a%b;}return b;
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
pair<ll,ll> dfs(string s,ll dep){
  if(s.size()==1){
    if(s[0] == 'n')
      return mp(0,1);
    else return mp(90,1);
  }
  string s2 = "";
  for(int i=1;i<s.size();i++)
    s2+=s[i];
  pair<ll,ll>sum = dfs(s2,dep-1);
  pair<ll,ll>now = mp(90,pow(2,dep));
  ll hoge = lcm(sum.S,now.S);

  if(s[0] == 'n'){
    ll dir = sum.F*hoge/sum.S-now.F*hoge/now.S;
    ll GCD = gcd(dir,hoge);
    return mp(dir/GCD,hoge/GCD);
  }else{
    ll dir = sum.F*hoge/sum.S+now.F*hoge/now.S;
    ll GCD = gcd(dir,hoge);
    return mp(dir/GCD,hoge/GCD);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin>>s,s!="#"){
    string ss = "";
    for(int i=0;i<s.size();i++){
      ss+=s[i];
      if(s[i] == 'n')i+=4;
      else i+=3;
    }
    //reverse(ALL(ss));
    pair<ll,ll>ans = dfs(ss,ss.size()-1);
    if(ans.S == 1)cout<<ans.F<<endl;
    else cout<<ans.F<<"/"<<ans.S<<endl;
  }
  return 0;
}

