#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin >> n; //cout << n; char str[n]; for(int i = 0; i < n; i++){ cin >> str[i]; } int count = 0; int i = 0; while(n){ int cu = 0; int cd = 0; if(str[i] == 'U'){ while(cu!= cd || (cu ==0 && cd == 0)){ if(str[i] == 'U') cu++; else cd++; i++; n--; } } else{ while(cu!= cd || (cu ==0 && cd == 0)){ if(str[i] == 'U') cu++; else cd++; i++; n--; } count++; } } cout << count; //return 0; }