#include <bits/stdc++.h>
using namespace std;
class MagicStack {
 public:
  void add(int n);
  void remove();
  int get_ans() { return ans; }

 public:
  int pop_mark = 0;
  int ans = 0;
  set<int> u;
  vector<int> s;
};
void MagicStack::add(int n) { s.push_back(n); }
void MagicStack::remove() {
  pop_mark++;
  if (s.size() && s.back() == pop_mark) {
    s.pop_back();
  } else if (s.size()) {
    ans++;
    u.insert(s.begin(), s.end());
    s.clear();
    u.erase(pop_mark);
  } else {
    u.erase(pop_mark);
  }
}
int main(int argc, char *argv[]) {
  int num;
  cin >> num;
  string cmd;
  int n;
  MagicStack ms;
  ms.s.reserve(num);
  for (int i = 0; i < 2 * num; i++) {
    cin >> cmd;
    if (cmd[0] == 'a') {
      cin >> n;
      ms.add(n);
    } else {
      ms.remove();
    }
  }
  cout << ms.get_ans() << endl;
  return 0;
}
