class Dice
  attr_reader :count

  def self.chain(*args)
    return args.reduce((0..5).to_a){|state, rep|@@order[rep].map{|face|state[face]}}
  end

  def self.setup
    @@order = {:north => [1,5,2,0,4,3], :right => [0,2,3,4,1,5]}
    @@order[:south] = chain(:north, :north, :north)
    @@order[:east] = chain(:north, :right, :south)
    @@order[:west] = chain(:east, :east, :east)
    @@order[:left] = chain(:right, :right, :right)
  end
  
  
  def initialize
    @state = [1,2,3,5,4,6]
    @count = 1
  end

  def rot(order)
    @state = @@order[order].map{|face|@state[face]}
    @count += @state[0]
  end
end
def main(input = STDIN)
  Dice.setup
  while 0 != n = input.gets.to_i
    dice = Dice.new
    n.times do
      dice.rot(input.gets.chomp.downcase.to_sym)
    end
    puts dice.count
  end
end
main