#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, pay = 0, kd;
  int U = 0, R = 0;
  char c;
  cin >> n;
  cin >> c;
  if (c == 'U') {
    kd = 1;
    U++;
  } else {
    kd = 0;
    R++;
  }
  for (int i = 1; i < n; i++) {
    cin >> c;
    if (c == 'U')
      U++;
    else if (c == 'R')
      R++;
    if (kd == 0 && R < U) {
      pay++;
      kd = 1;
    } else if (kd && R > U) {
      pay++;
      kd = 0;
    }
  }
  cout << pay;
  return 0;
}
