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