#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXQ = 100000;
const long long INF = 1LL << 32;
int nq;
char qkind[MAXQ][10];
int qpar[MAXQ];
long long solve() {
  long long ret = 0;
  vector<long long> stck;
  stck.push_back(1LL);
  for (int i = (0); i < (nq); ++i) {
    if (strcmp(qkind[i], "add") == 0) {
      ret += stck.back();
      if (ret >= INF) return -1;
    }
    if (strcmp(qkind[i], "for") == 0) {
      long long nval = min(INF, stck.back() * qpar[i]);
      stck.push_back(nval);
    }
    if (strcmp(qkind[i], "end") == 0) {
      stck.pop_back();
    }
  }
  return ret;
}
void run() {
  scanf("%d", &nq);
  for (int i = (0); i < (nq); ++i) {
    scanf("%s", qkind[i]);
    if (strcmp(qkind[i], "for") == 0) scanf("%d", &qpar[i]);
  }
  long long ans = solve();
  if (ans == -1)
    printf("OVERFLOW!!!\n");
  else
    printf("%lld\n", ans);
}
int main() {
  run();
  return 0;
}
