#include <bits/stdc++.h>
using namespace std;
int cnt;
int n;
int ppx, ppy, px, py, x, y;
char s[100005];
int main() {
  int i, j;
  scanf("%d", &n);
  scanf(" %s", s);
  for (i = 0; i < n; i++) {
    ppx = px, ppy = py;
    px = x, py = y;
    switch (s[i]) {
      case 'R':
        x++;
        break;
      case 'U':
        y++;
        break;
    }
    if (i > 1) {
      if (px == py && (px - ppx) == (x - px)) {
        cnt++;
      }
    }
  }
  printf("%d", cnt);
  return 0;
}
