#include <iostream>
#include <string>
using namespace std;

typedef pair<int, int> P;

int pow(int n) {
  int p = 1;
  for (int i = 0; i < n; i++) {
    p *= 2;
  }
  return p;
}

int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "#") return 0;

    int i, count, len, slen;
    P a;

    i = 0;
    len = 0;
    slen = 0;
    while (s[i] != '\0') {
      if (s[i] == 'n') {
	i += 5;
	slen += 5;
      } else {
	i += 4;
	slen += 4;
      }
      len++;
    }

    a.second = pow(len - 1);
    
    slen--;
    i = slen;

    if (s[i] == 'h') {
      a.first = 0;
      i -= 5;
    } else {
      a.first = 90 * pow(len - 1);
      i -= 4;
    }

    count = 1;
    while (i > 0) {
      if (s[i] == 'h') {
	a.first -= 90 * pow(len - 1 - count);
	i -= 5;
      } else {
	a.first += 90 * pow(len - 1 - count);
	i -= 4;
      }
      count++;
    }

    while (a.second > 1 && a.first % 2 == 0) {
      a.first /= 2;
      a.second /= 2;
    }
    
    if (a.second == 1)
      cout << a.first << endl;
    else
      cout << a.first << '/' << a.second << endl;
  }
}