//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
struct Init { Init(){
    cin.tie(0); ios::sync_with_stdio(false);
} } init;
//}}}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    string s2;
    for(auto& c : s){
        s2 += c;
        int n2 = s2.size();
        if(n2 >= 3 && s2[n2 - 3] == 'f' && s2[n2 - 2] == 'o' && s2[n2 - 1] == 'x'){
            for(int i = 0; i < 3; i++){
                s2.pop_back();
            }
        }
    }
    cout << s2.size() << '\n';
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,N; cin>>N;
  string S,kariS; cin>>S;
  int Q; cin>>Q;
  int T[300005],A[300005],B[300005];
  for(i=0;i<Q;i++) cin>>T[i]>>A[i]>>B[i];

  string S1,S2;
  S1=S.substr(0,N);
  S2=S.substr(N);
  
  for(i=0;i<Q;i++){
    if(2==T[i]){
      swap(S1,S2);
    }
    if(1==T[i]){
      if(B[i]<=N) swap(S1[A[i]-1],S1[B[i]-1]);
      else if(A[i]>N)
        swap(S2[A[i]-N-1],S2[B[i]-N-1]);
      else swap(S1[A[i]-1],S2[B[i]-N-1]);
    }
  }
  
  cout<<S1+S2;
}