loop do
    dir = gets.strip.gsub(/north|west/, "north" => "n", "west" => "w")
    break if dir == "\#"
    a = dir[dir.size-1] == "n" ? 0 : 90
    (dir.size-2).downto(0) do |i|
        t = 90.0 / (2**(dir.size-i-1)).to_f
        case dir[i]
        when "n"
            a = a - t
        when "w"
            a = a + t
        end
    end
    if a == a.to_i
        puts a.to_i
    else
        den = 1
        while a != a.to_i
            a *= 2
            den *= 2
        end
        puts "#{a.to_i}/#{den}"
    end
end