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