#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, count, x = 0, y = 0, count1 = 1, cost = 0;
  cin >> n;
  string s = {};
  cin >> s;
  if (s[0] == 'R')
    count = 1;
  else
    count = 2;
  for (i = 0; i < n; i++) {
    if (s[i] == 'U')
      y++;
    else
      x++;
    count1 = count;
    if (y > x) {
      count = 2;
      if (count1 != count) {
        cost++;
        count1 = 2;
      }
    } else if (x > y) {
      count = 1;
      if (count1 != count) {
        cost++;
        count1 = 1;
      }
    }
  }
  cout << cost;
  return 0;
}
