#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, y = 0, pos = 0, coin = 0;
  if (s[0] == 'R')
    x++;
  else
    y++;
  if (y > x) pos = 2;
  if (x > y) pos = 1;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == 'R')
      x++;
    else
      y++;
    int npos = 0;
    if (y > x) npos = 2;
    if (x > y) npos = 1;
    if (npos != 0 && npos != pos) {
      coin++;
      pos = npos;
    }
  }
  cout << coin;
}
