#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long i, j, c = 0, k, n, x = 0, y = 0;
  char ch;
  string s;
  cin >> n;
  cin >> s;
  for (i = 0; i < n - 1; i++) {
    if (s[i] == 'U') {
      y = y + 1;
    }
    if (s[i] == 'R') {
      x = x + 1;
    }
    if (x == y) {
      ch = s[i];
      if (s[i + 1] == ch) {
        c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}
