#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = 0;
  int y = 0;
  string d;
  cin >> d;
  int loc = -1;
  int ans = 0;
  if (d[0] == 'U') {
    y = 1;
    loc = 1;
  } else {
    x = 1;
    loc = 0;
  }
  for (int i = 1; i < n; i++) {
    if (d[i] == 'R') {
      x += 1;
    } else {
      y += 1;
    }
    if (x > y && loc == 1) {
      ans++;
      loc = 0;
    } else if (y > x && loc == 0) {
      ans++;
      loc = 1;
    }
  }
  cout << ans << endl;
}
