class Dice
  def initialize
    @top = 1
    @near = 2
    @right = 3
  end

  def north
    @top, @near = @near, 7-@top
  end

  def east
    @top, @right = 7-@right, @top
  end

  def west
    @top, @right = @right, 7-@top
  end

  def south
    @top, @near = 7-@near, @top
  end

  def right
    @near, @right = @right, 7-@near
  end

  def left
    @near, @right = 7-@right, @near
  end

  attr_reader :top
end

loop do
  count = STDIN.readline.to_i
  break if count == 0

  dice = Dice.new
  ans = dice.top

  count.times do
    command = STDIN.readline
    dice.send(command.chomp.downcase)
    ans += dice.top
  end

  puts ans
end