#include #include using namespace std; int pos( int i ) { if ( i < 0 ) { i += 4; } return i % 4; } const int north = 0; const int south = 1; const int east = 2; const int west = 3; void process( int n ) { int h[4] = { 1, 3, 6, 4 }; int v[4] = { 1, 5, 6, 2 }; int hpos = 0; int vpos = 0; for ( int i = 0; i < n; i++ ) { string s; cin >> s; if ( s == "north" ) { vpos = pos( vpos + 1 ); h[hpos] = v[vpos]; h[pos( hpos + 2 )] = 7 - v[vpos]; } else if ( s == "south" ) { vpos = pos( vpos - 1 ); h[hpos] = v[vpos]; h[pos( hpos + 2 )] = 7 - v[vpos]; } else if ( s == "east" ) { hpos = pos( hpos + 1 ); v[vpos] = h[hpos]; v[pos( vpos + 2 )] = 7 - h[hpos]; } else if ( s == "west" ) { hpos = pos( hpos - 1 ); v[vpos] = h[hpos]; v[pos( vpos + 2 )] = 7 - h[hpos]; } } cout << h[hpos] << endl; return; } int main() { int n = 0; while ( cin >> n && n ) { process( n ); } return 0; }