#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  string s = "";
  cin >> s;
  int x = 0, y = 0, iCnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'U')
      y++;
    else
      x++;
    if (x == y && i != s.length() - 1) {
      if (s[i] == 'R' && s[i + 1] == 'R' || s[i] == 'U' && s[i + 1] == 'U')
        iCnt++;
    }
  }
  cout << iCnt << "\n";
  return 0;
}
