#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int N = 1e6 + 5;   const int K = (1 << 17) + 10;   const long long int INF = 2e18 + 500;   const int inf = 0x7fffffff;   const int SQRT = 500;   const int lgN = 20;   int main(int argc, char const *argv[]) {     cin.sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     stack<int> S;     int ans = 0;     int req = 0;     for (int i = 0; i < 2 * n; i++) {       string s;       cin >> s;       if (s[0] ==  a ) {         int x;         cin >> x;         S.push(x);       } else {         req += 1;         if (S.size() == 0) {           continue;         } else {           int x = S.top();           if (x == req) {             S.pop();           } else {             ans += 1;             S = stack<int>();           }         }       }     }     cout << ans << endl;     return 0;   }   