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