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