#include <bits/stdc++.h>
using namespace ::std;
int main() {
  int n, u = 0, r = 0, sum = 0;
  char c, prev = 'Y';
  cin >> n;
  for (int i = 0; i < n; ++i) {
    if (i != 0) {
      prev = c;
    }
    cin >> c;
    if (c == 'U') {
      u++;
    } else {
      r++;
    }
    if ((u == r + 1 && c == prev && c == 'U') ||
        ((r == u + 1) && c == prev && c == 'R'))
      sum++;
  }
  cout << sum;
}
