#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1, n, m, i, j, k;
  while (T-- > 0) {
    cin >> m;
    long long stk[m + 1];
    string second;
    long long ans = 0;
    k = 1;
    stk[0] = 1;
    for (i = 0; i < m; i++) {
      cin >> second;
      if (second == "for") {
        cin >> n;
        stk[k] = stk[k - 1] * n;
        if (stk[k] > UINT32_MAX or stk[k] < 0) stk[k] = -1;
        k++;
      } else if (second == "end") {
        k--;
      } else {
        if (stk[k - 1] < 0 or ans + stk[k - 1] > UINT_MAX) {
          cout << "OVERFLOW!!!";
          return 0;
        }
        ans += stk[k - 1];
      }
    }
    cout << ans;
  }
}
