#include <bits/stdc++.h>
using namespace std;
long long p = 1000000007ll;
int main(void) {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > loops;
  long long tmp = 0;
  for (long long i = (0); i < (n); ++i) {
    string com;
    cin >> com;
    if (com == "for") {
      long long x;
      cin >> x;
      loops.emplace_back(x, tmp);
      tmp = 0;
    } else if (com == "end") {
      tmp = tmp * loops.back().first + loops.back().second;
      if (tmp >= (1ll << 32)) {
        cout << "OVERFLOW!!!" << endl;
        return 0;
      }
      loops.pop_back();
    } else {
      ++tmp;
    }
  }
  if (tmp >= (1ll << 32)) {
    cout << "OVERFLOW!!!" << endl;
    return 0;
  }
  cout << tmp << endl;
  return 0;
}
