#include <bits/stdc++.h>
using namespace std;
struct Node {
  int t;
  int v;
};
int l;
Node comm[500005];
const long long INF = (1LL << 32) - 1;
int main() {
  char s[100];
  while (scanf("%d", &l) != EOF) {
    for (int i = 0; i < l; ++i) {
      scanf("%s", s);
      if ('a' == s[0]) {
        comm[i].t = 1;
      } else if ('f' == s[0]) {
        comm[i].t = 2;
        scanf("%d", &(comm[i].v));
      } else if ('e' == s[0]) {
        comm[i].t = 3;
      } else {
        printf("ERROR\n");
      }
    }
    long long x = 0;
    int p = 0;
    stack<int> q;
    stack<long long> value;
    stack<long long> yv;
    value.push(0);
    while (p < l) {
      long long y = value.top();
      value.pop();
      while (p < l && 1 == comm[p].t) {
        ++y;
        ++p;
      }
      if (p == l) value.push(y);
      if (2 == comm[p].t) {
        yv.push(y);
        value.push(0);
        q.push(comm[p].v);
        ++p;
      } else if (3 == comm[p].t) {
        long long vt = y * q.top();
        q.pop();
        vt += yv.top();
        yv.pop();
        value.push(vt);
        ++p;
      }
      if (value.top() > INF) {
        x = -1;
        break;
      }
    }
    if (value.top() > INF) x = -1;
    if (-1 == x) {
      printf("OVERFLOW!!!\n");
    } else {
      x = value.top();
      printf("%I64d\n", x);
    }
  }
}
