#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, count = 0, countu = 0, countr = 0;
  string s;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if ((i > 0) && (countu == countr) && (s[i - 1] == s[i])) count++;
    if (s[i] == 'U')
      countu++;
    else if (s[i] == 'R')
      countr++;
  }
  cout << count << endl;
  return 0;
}
