#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 998244353;
string s;
long long a[N], b[N];
int main() {
  int n, now = 1, tmp;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    if (s == "add")
      a[now]++;
    else if (s == "for") {
      cin >> tmp;
      b[now] = tmp;
      now++;
    } else {
      a[now - 1] += b[now - 1] * a[now];
      if (a[now - 1] > (1ll << 32) - 1) {
        puts("OVERFLOW!!!");
        return 0;
      }
      a[now] = 0;
      now--;
    }
  }
  if (a[1] <= (1ll << 32) - 1)
    cout << a[1] << endl;
  else
    puts("OVERFLOW!!!");
  return 0;
}
