#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'U') {
      y++;
    } else {
      x++;
    }
    if (a[i] == 'U' && x == y && a[i + 1] == 'U') {
      ans++;
    } else if (a[i] == 'R' && x == y && a[i + 1] == 'R') {
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
