#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, unsigned long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x;
    }
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int powermod(long long int x, unsigned long long int y,
                       long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  stack<long long int> v;
  long long int ans = 0;
  long long int po = 1LL << 32;
  long long int idx = -1;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    string s;
    cin >> s;
    if (s == "for") {
      long long int l;
      cin >> l;
      if (!v.empty()) l *= v.top();
      v.push(min(po, l));
    } else if (s == "end") {
      v.pop();
    } else {
      long long int c = 1;
      if (!v.empty()) c *= v.top();
      ans += c;
    }
  }
  if (ans >= po) ans = -1;
  if (ans == -1)
    cout << "OVERFLOW!!!\n";
  else
    cout << ans << "\n";
  return 0;
}
