#include <bits/stdc++.h>
using namespace std;
char c[10];
int a[3500002], date[3500002], size, lastSorted = -1, ans;
int main() {
  int n, cur, toRemove = 1;
  cin >> n;
  for (int i = 0; i < 2 * n; ++i) {
    cin >> c;
    if (c[0] == 'a') {
      cin >> cur;
      a[size++] = cur;
      date[cur] = i;
    } else {
      if (a[size - 1] == toRemove) {
        size--;
      } else if (size == 0 && date[toRemove] <= lastSorted) {
      } else {
        lastSorted = i;
        size = 0;
        ans++;
      }
      toRemove++;
    }
  }
  cout << ans << endl;
  return 0;
}
