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