#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  long long f_true = 0;
  long long f_num = 1;
  long long ans = 0;
  stack<long long> v1;
  stack<long long> v2;
  for (long long z = 0; z < t; z++) {
    string a;
    cin >> a;
    if (a[0] == 'a') {
      ans++;
    } else if (a[0] == 'f') {
      long long b;
      cin >> b;
      v1.push(b);
      v2.push(ans);
    } else {
      long long x = v1.top();
      long long y = v2.top();
      long long p = ans - y;
      ans += (x - 1) * p;
      v1.pop();
      v2.pop();
    }
    if (ans >= 4294967296) {
      cout << "OVERFLOW!!!";
      return 0;
    }
  }
  cout << ans;
  return 0;
}
