#include #include #include #include #include using namespace std; int main() { int n; cin >> n; string s; cin >> s; char flag = '0'; char hill='0',valley='0'; int up_count = 0, down_count = 0; int i=0; int ans=0; while(s[i] != '\0'){ if(flag == '0'){ if(s[i] == 'U'){ hill = '1'; up_count++; } else{ valley = '1'; down_count++; } flag = '1'; } if(hill == '1'){ while(up_count != down_count){ if(s[++i] == 'U') up_count++; else down_count++; } hill = '0'; up_count = 0; down_count = 0; flag = '0'; i++; } else if(valley == '1'){ while(up_count != down_count){ if(s[++i] == 'U') up_count++; else down_count++; } ans++; valley = '0'; up_count = 0; down_count = 0; flag = '0'; i++; } } cout << ans << endl; return 0; }