#include #include #include #include #define MAX 250000 #define IS 0 #define W 1 int stk[MAX][2]; int top=0; char line[MAX]; int main(void) { while(fgets(line,MAX,stdin)) { for (int index=strlen(line)-1;index>=0;index--) { int c=line[index]; if (isupper(c)) { switch(c) { case 'V': stk[top][IS]=1; stk[top][W]=1; top++; break; case 'U': stk[top-2][IS]+=stk[top-1][IS]; if (stk[top-1][W] > stk[top-2][W]) stk[top-2][W]=stk[top-1][W]; top--; break; case 'C': int tmp=stk[top-1][W]; stk[top-1][W]=stk[top-1][IS]; stk[top-1][IS]=tmp; break; } } } printf("%d\n", stk[top-1][IS]); top=0; } return 0; }