#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, T, ti;
long long MX = 4294967295;
long long temp;
long long loop(int n) {
  long long ret = 0;
  string str;
  int rn;
  cin >> str;
  m--;
  while (str != "end") {
    if (str == "add") {
      ret++;
    } else if (str == "for") {
      cin >> rn;
      temp = loop(rn);
      if (temp == -1) break;
      ret += temp;
    } else {
      cerr << "WOW " << str << endl;
    }
    if (m == 0) break;
    cin >> str;
    m--;
  }
  if (temp == -1) return -1;
  if (ret * n > MX) {
    return -1;
  }
  return ret * n;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> m;
  temp = 0;
  temp = loop(1);
  if (temp == -1) {
    cout << "OVERFLOW!!!" << endl;
  } else {
    cout << temp << endl;
  }
  return 0;
}
