#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0, i, flag = 1;
  cin >> n;
  char s[n + 1], c;
  cin >> s;
  int l = 0, r = 0;
  l++;
  for (i = 1; i < n; i++) {
    c = s[i];
    if (c == s[0])
      l++;
    else
      r++;
    if (r > l && flag == 1) {
      flag = 0;
      count++;
    }
    if (r < l && flag == 0) {
      flag = 1;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
