#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e5 + 10;
int n;
string s;
int x;
stack<int> q;
int main() {
  scanf("%d", &n);
  int ans = 2 * n;
  int now = 1;
  int sum = 0;
  while (ans--) {
    cin >> s;
    if (s[0] == 'a') {
      scanf("%d", &x);
      q.push(x);
    } else {
      if (q.empty()) {
        now++;
        continue;
      }
      int k = q.top();
      if (k == now) {
        now++;
        q.pop();
      } else {
        sum++;
        while (!q.empty()) q.pop();
        now++;
      }
    }
  }
  printf("%d\n", sum);
}
