#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, count = 0, xl = 0, yl = 0, xll = 0, yll = 0, xp, yp;
  string s;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U') {
      xp = xl;
      yp = yl + 1;
    } else if (s[i] == 'R') {
      xp = xl + 1;
      yp = yl;
    }
    if (((yll - xll > 0 && yp - xp < 0) || (yll - xll < 0 && yp - xp > 0)))
      count++;
    xll = xl;
    yll = yl;
    xl = xp;
    yl = yp;
  }
  cout << count << endl;
  return 0;
}
