#include <bits/stdc++.h>
using namespace std;
int main() {
  int l;
  long long ans = 0;
  int last = 0;
  long long ml = 1;
  cin >> l;
  stack<long long> a;
  a.push(1);
  while (l--) {
    string s;
    cin >> s;
    long long t;
    if (s == "for") {
      cin >> t;
      a.push(min(t * a.top(), 1ll << 32));
    } else if (s == "end") {
      if (a.size() > 0) a.pop();
    } else if (s == "add") {
      long long mul = 1;
      if (ans == -1) {
        continue;
      }
      mul = a.top();
      if (mul == -1) {
        ans = -1;
      } else
        ans += mul;
      if (ans >= pow(2, 32)) ans = -1;
    }
  }
  if (ans != -1) {
    cout << ans;
  } else {
    cout << "OVERFLOW!!!";
  }
  return 0;
}
