#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int i = 0;
  int cnt = 0;
  int cnt1 = 0;
  int cnt3 = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == 'R') {
      cnt++;
    } else if (s[i] == 'U') {
      cnt1++;
    }
    if ((s[i] == s[i + 1]) && cnt == cnt1) {
      cnt3++;
    }
  }
  cout << cnt3 << endl;
  return 0;
}
