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