#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, y = 0;
  int state = -1;
  if (s[0] == 'R')
    state = 0;
  else
    state = 1;
  int res = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R') {
      x++;
    } else if (s[i] == 'U') {
      y++;
    }
    if (y < x && state == 1) {
      res++;
      state = 0;
    } else if (y > x && state == 0) {
      res++;
      state = 1;
    }
  }
  cout << res << endl;
  return 0;
}
