#include <bits/stdc++.h>
using namespace std;
const int M = 300000;
bool flag[M + 5];
int stk[M + 5];
int main() {
  int n;
  cin >> n;
  string s;
  int x = -1, y = 1, ans = 0, top = 0;
  for (int i = 0; i < n * 2; i++) {
    cin >> s;
    if (s == "add") {
      cin >> x;
      flag[x] = 1;
      stk[++top] = x;
    } else if (s == "remove") {
      if (!flag[y]) {
        puts("???");
        return 0;
      }
      if (top) top--;
      if (x != y) {
        top = 0;
        ans++;
        x = ++y;
      } else if (top) {
        y++;
        x = stk[top];
      } else
        x = ++y;
    } else
      puts("???");
  }
  printf("%d\n", ans);
  return 0;
}
