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