#include <bits/stdc++.h>
using namespace std;
long long n, x, ans;
string s;
stack<pair<long long, long long> > S;
bool check(long long x) {
  if (x < 0 || x >= (1ll << 32)) return 0;
  return 1;
}
void solve() {
  cin >> n;
  for (__typeof((n + 1)) i = (1); i < (n + 1); i++) {
    cin >> s;
    if (s == "add") {
      if (!(long long)S.size())
        ans++;
      else {
        pair<long long, long long> p = S.top();
        S.pop();
        p.first++;
        S.push(p);
      }
    } else if (s == "for") {
      cin >> x;
      S.push({0, x});
    } else if (s == "end") {
      pair<long long, long long> p = S.top();
      S.pop();
      if (!(long long)S.size())
        ans += p.first * p.second;
      else {
        pair<long long, long long> q = S.top();
        S.pop();
        q.first += p.first * p.second;
        if (!check(q.first)) {
          cout << "OVERFLOW!!!"
               << "\n";
          return;
        };
        S.push(q);
      }
    }
    if (!check(ans)) {
      cout << "OVERFLOW!!!"
           << "\n";
      return;
    };
  }
  {
    cout << ans << "\n";
    return;
  };
}
void prep() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  prep();
  cout << fixed << setprecision(12);
  while (t--) solve();
  return 0;
}
