#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count1 = 0;
  bool flag = 0;
  cin >> n;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    if (ch == 'R') x++;
    if (ch == 'U') y++;
    if (i != 0) {
      if (x == y + 1 && flag) {
        count1++;
        flag = 0;
      }
      if (x + 1 == y && !flag) {
        count1++;
        flag = 1;
      }
    } else if (ch == 'U')
      flag = 1;
  }
  cout << count1;
}
