#include <bits/stdc++.h>
int main() {
  int n, i, x = 0, y = 0, c = 0;
  scanf("%d", &n);
  char s[n];
  scanf("%s", s);
  for (i = 0; i < n; i++) {
    if (s[i] == 'U') {
      y = y + 1;
      if (x == y && s[i + 1] == 'U') c++;
    } else if (s[i] == 'R') {
      x = x + 1;
      if (x == y && s[i + 1] == 'R') c++;
    }
  }
  printf("%d\n", c);
  return 0;
}
