while n = gets.to_i
  break if n == 0
  d = [1, 2, 3, 4, 5, 6]
  n.times do
    case gets.chomp
    when 'north'
      d = [d[4], d[0], d[2], d[3], d[5], d[1]]
    when 'south'
      d = [d[1], d[5], d[2], d[3], d[0], d[4]]
    when 'east'
      d = [d[2], d[1], d[5], d[0], d[4], d[3]]
    when 'west'
      d = [d[3], d[1], d[0], d[5], d[4], d[2]]
    end
  end
  p d[0]
end