#include <bits/stdc++.h>
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cout << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cout.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
using namespace std;
int to_ll(string s) {
  int i, ret = 0, p = 1;
  for (i = (int)s.length() - 1; i >= 0; i--) ret += (s[i] - '0') * p, p *= 10LL;
  return ret;
}
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int pwr(int base, int expo, int m) {
  if (base == 0) return 0LL;
  if (expo == 0) return (1LL % m);
  if ((expo & 1) == 0) {
    int temp = pwr(base, expo >> 1, m);
    return (temp * temp) % m;
  }
  return ((base % m) * pwr(base, expo - 1, m)) % m;
}
int n;
set<int> st;
deque<int> dq;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int i, j = 1, val, cnt = 0;
  string s;
  cin >> n;
  n = n * 2;
  for (i = 0; i < n; i++) {
    cin >> s;
    if (s[0] == 'a') {
      cin >> val;
      dq.push_back(val);
    } else {
      if (dq.empty()) {
        int mn = *st.begin();
        j++;
        st.erase(mn);
      } else {
        if (dq.back() == j) {
          dq.pop_back();
          j++;
        } else {
          while (!dq.empty()) {
            st.insert(dq.back());
            dq.pop_back();
          }
          int mn = *st.begin();
          j++;
          st.erase(mn);
          cnt++;
        }
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}
