#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j = 1, x = 0, y = 0, a, c = 0, b;
  cin >> n;
  char s[n];
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == 82)
      x++;
    else
      y++;
    a = x;
    b = y;
    j = 0;
    while (j != 2 && i > 1) {
      if (s[i - j] == 82)
        a = a - 1;
      else
        b = b - 1;
      j++;
    }
    if ((x > y && a < b) || (x < y && a > b)) c++;
  }
  cout << c;
  return 0;
}
