#include <bits/stdc++.h>
using namespace std;
char s[200000];
int x, y;
int tot, n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'U')
      y++;
    else if (s[i] == 'R')
      x++;
    if (x == y && s[i] == s[i + 1]) tot++;
  }
  cout << tot;
}
