#include #include #include #include int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int N; scanf("%d",&N); int count=0; int sealevel=0; int level = 0; for(int i = 0; i0) sealevel=1; else if(level==0) sealevel=0; } else if(direction == 'D') { if(level==0 && sealevel==0){ count++; } level-=1; if(level<0) sealevel=-1; else if(level==0) sealevel=0; } } printf("%d",count); return 0; }