#include <bits/stdc++.h>
using namespace std;
int n, top, res;
string s[600010];
int st[600010], ordered[600010];
void enter() {
  cin >> n;
  n *= 2;
  cin.ignore(1);
  for (int i = 1; i <= n; i++) {
    getline(cin, s[i]);
  }
}
void solve() {
  int val, current;
  top = 0;
  res = 0;
  current = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i][0] == 'a') {
      val = stoi(s[i].substr(4, (s[i].size() - 4)));
      st[++top] = val;
      ordered[top] = 0;
    } else {
      if ((ordered[top] != 1) && (st[top] != current)) {
        res++;
        ordered[--top] = 1;
        current++;
        continue;
      }
      if (ordered[top] == 1) {
        ordered[--top] = 1;
        current++;
        continue;
      }
      current++;
      --top;
    }
  }
  cout << res;
}
int main() {
  enter();
  solve();
}
