#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int sum = 0, x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U') y++;
    if (s[i] == 'R') x++;
    if (x == y) {
      if (s[i] == s[i + 1]) sum++;
    }
  }
  cout << sum;
}
