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