cube = [nil, [5, 3, 2, 4], [3, 6, 4, 1], [6, 2, 1, 5], [1, 2, 6, 5], [3, 1, 4, 6], [2, 3, 5, 4]]
roll = {'North' => 0, 'East' => 1, 'South' => 2, 'West' => 3}
turn = {'Left' => -1, 'Right' => 1}
until (n = gets.to_i) == 0
  eye = 1
  round = 0
  puts n.times.map {
    r = cube[eye]
    case op = gets.chomp
    when 'Left', 'Right'
      round += turn[op]
    else
      dir = roll[op]
      before_eye = eye
      eye = cube[before_eye][(dir + 2 - round) % 4]
      round = (dir - cube[eye].index(before_eye)) % 4
    end
    eye
  }.reduce(1, :+)
end