#include <bits/stdc++.h>
using namespace std;
long long MAX = 4294967295;
void run_prog(vector<pair<string, int> > prog, int n) {
  unsigned long long pw = 1, num = 0, prev = 1, lvl = 0;
  bool go_for = false, add = true;
  map<int, unsigned long long> add_value, start_for;
  for (int i(0); i < n; ++i) {
    if (prog[i].first == "for") {
      lvl++;
      add_value[lvl] = 0;
      if (lvl > 1) {
        start_for[lvl] = prog[i].second * start_for[lvl - 1];
      } else {
        start_for[lvl] = prog[i].second;
      }
    } else if (prog[i].first == "add") {
      add_value[lvl]++;
    } else if (prog[i].first == "end") {
      if (!start_for[lvl] and add_value[lvl]) {
        num += MAX + 1;
        break;
      } else {
        num += start_for[lvl] * add_value[lvl];
      }
      lvl--;
    }
  }
  num += add_value[0];
  if (num > MAX) {
    cout << "OVERFLOW!!!\n";
  } else {
    cout << num << endl;
  }
}
int main() {
  int n;
  cin >> n;
  vector<pair<string, int> > prog(n);
  string tmp;
  int num;
  for (int i(0); i < n; ++i) {
    cin >> tmp;
    if (tmp == "for") {
      cin >> num;
      prog[i].first = tmp;
      prog[i].second = num;
    } else {
      prog[i].first = tmp;
    }
  }
  run_prog(prog, n);
  return 0;
}
