#include #include #include using namespace std; typedef long long LL; int T[1024]; LL year[1024]; bool keep[1024]; int dp[1024][1024]; const int oo = 1000000; LL toLL(string t) { int n = t.size(); for (int i=0; i> mo >> da >> ho >> mi; LL ret = mo; ret *= 32; ret += da; ret *= 25; ret += ho; ret *= 61; ret += mi; return ret; } int main() { freopen("economic.in", "r", stdin); int n; while (cin >> n, n) { for (int i=0; i> t >> tmp >> k; T[i] = toLL(t); keep[i] = (k == "+"); } year[n-1] = 1023; for (int i=n-2; i>=0; i--) year[i] = (T[i] < T[i+1] ? year[i+1] : year[i+1]-1); for (int i=0; i<1024; i++) for (int j=0; j=0; i--) { if (year[i] != 1023) break; dp[i][1023] = 1; if (keep[i]) break; } int res = 0; for (int i=n-1; i>=0; i--) { if (keep[i]) { for (int j=i+1; j?= dp[i][year[i]]; } else { for (int j=i+1; j