//Author: Koppu #include #include int calc_stats(char *a, int n) { int i; int cur_pos = 0; int mnt_cnt = 0; int val_cnt = 0; for(i = 0; i < n; i++) { if(a[i] == 'U') { cur_pos++; if(cur_pos == 0) val_cnt++; } else if(a[i] == 'D') { cur_pos--; if(cur_pos == 0) mnt_cnt++; } else continue; } return val_cnt; } int main(void) { int n; scanf("%d", &n); char a[n]; scanf("%s", a); printf("%d",calc_stats(a, n)); return 0; }