#include <bits/stdc++.h>
using namespace std;
set<int> s;
set<int>::iterator it;
int n;
int st[300005], top;
signed main() {
  scanf("%d", &n);
  char ss[10];
  int ans = 0;
  bool flag = 0;
  int now = 0;
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%s", ss);
    if (ss[0] == 'a') {
      int tmp;
      scanf("%d", &tmp);
      st[++top] = tmp;
      if (s.size()) {
        it = s.begin();
        if ((*it) < tmp) flag = 1;
      }
      s.insert(tmp);
    } else {
      now++;
      if (top && st[top] == now) {
        top--;
      } else {
        if (flag) ans++, flag = 0, top = 0;
      }
      it = s.begin();
      s.erase(it);
    }
  }
  printf("%d\n", ans);
  return 0;
}
