Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

blockquote {
font-family: Menlo, Monaco, "Courier New", monospace;
color: #333333;
display: block;
padding: 8.5px;
margin: 0 0 9px;
font-size: 12px;
line-height: 18px;
background-color: #f5f5f5;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
white-space: pre;
white-space: pre-wrap;
word-break: break-all;
word-wrap: break-word;
}

Problem Statement

We can describe detailed direction by repeating the directional names: north, south, east and west. For example, northwest is the direction halfway between north and west, and northnorthwest is between north and northwest.

In this problem, we describe more detailed direction between north and west as follows.

"north" means $0$ degrees.

"west" means $90$ degrees.

If the direction $dir$ means $a$ degrees and the sum of the occurrences of "north" and "west" in $dir$ is $n$ ($\geq$ 1),
"north"$dir$ (the concatenation of "north" and $dir$) means $a - \frac{90}{2^n}$ degrees and "west"$dir$ means $a + \frac{90}{2^n}$ degrees.

Your task is to calculate the angle in degrees described by the given direction.

Input

The input contains several datasets. The number of datasets does not exceed $100$.

Each dataset is described by a single line that contains a string denoting a direction.
You may assume the given string can be obtained by concatenating some "north" and "west",
the sum of the occurrences of "north" and "west" in the given string is between $1$ and $20$, inclusive,
and the angle denoted by the given direction is between $0$ and $90$, inclusive.
The final dataset is followed by a single line containing only a single "#".

Output

For each dataset, print an integer if the angle described by the given direction can be represented as an integer, otherwise print it as an irreducible fraction. Follow the format of the sample output.

Sample Input

north
west
northwest
northnorthwest
westwestwestnorth
#

Output for the Sample Input

0
90
45
45/2
315/4

Solution in C++11 (judge verdict: Time Limit Exceeded)

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
/*
90/8 + 90/4 + 90/2


*/
void mainmain(){
	string s;
	while(cin>>s,s!="#"){
		ll a=0,b=1;
		ll c=1;
		if(s.size()==5){
			cout<<0<<endl;
			continue;
		}
		while(s.size()){
			// cout<<a<<" "<<b<<endl;
			if(s[s.size()-1]=='h'){
				if(c==1){
					s=s.substr(0,s.size()-5);
					c*=2;
					continue;
				}
				a=c*a-b*90;
				b*=c;
				s=s.substr(0,s.size()-5);
			}
			else{
				a=c*a+b*90;
				b*=c;
				s=s.substr(0,s.size()-4);	
			}
			c*=2;
			ll m=min(a,b);
			if(m<=1) continue;
			for(int i=2;i*i<=m;i++){
				while(a%i==0&&b%i==0){
					a/=i;
					b/=i;
				}
			}
		}
		if(b==1){
			cout<<a<<endl;
		}
		else{
			cout<<a<<"/"<<b<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}