1#include <bits/stdc++.h>
2using namespace std;
3
4int main() {
5 int n,updown = 0,res = 0;
6 char c;
7 cin >> n;
8
9 for(int i = 0; i++ < n;){
10 cin >> c;
11 if(c == 'U')updown++;
12 else updown--;
13 if(updown == 0 && c == 'U')res++;
14 }
15 cout << res << endl;
16 return 0;
17}