#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n;
  cin >> n;
  cin >> s;
  int state, nowstate;
  int u = 0, r = 0, cnt = 0;
  state = s[0] == 'U' ? 1 : 0;
  if (s[0] == 'U')
    u++;
  else
    r++;
  for (int i = 1; i < n; i++) {
    if (s[i] == 'U')
      u++;
    else
      r++;
    if (u > r)
      nowstate = 1;
    else if (u < r)
      nowstate = 0;
    else
      continue;
    if (nowstate != state) {
      cnt++;
      state = nowstate;
    }
  }
  cout << cnt << endl;
  return 0;
}
