#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l, c = 0, d = 0, t = 0;
  cin >> n;
  string s;
  cin >> s;
  for (l = 0; l < s.length() - 1; l++) {
    if (s[l] == 'R') c++;
    if (s[l] == 'U') d++;
    if (c == d) {
      if (s[l] == s[l + 1]) t++;
    }
  }
  cout << t;
}
