#include <bits/stdc++.h>
using namespace std;
char a[100010];
int d[100010];
int main() {
  int n, i, x, y, ge = 0;
  memset(a, 0, sizeof(a));
  memset(d, 0, sizeof(d));
  scanf("%d", &n);
  getchar();
  gets(a);
  x = 0, y = 0;
  d[0] = 0;
  for (i = 0; i <= n - 1; i++) {
    if (i == 0) {
      if (a[0] == 'U') {
        y += 1;
        d[1] = 1;
      }
      if (a[0] == 'R') {
        x += 1;
        d[1] = 2;
      }
    } else if (i == 1) {
      if (a[i] == 'R') {
        x += 1;
        if (x == y)
          d[i + 1] = 0;
        else
          d[i + 1] = d[i];
      }
      if (a[i] == 'U') {
        y += 1;
        if (x == y)
          d[i + 1] = 0;
        else
          d[i + 1] = d[i];
      }
    } else {
      if (a[i] == 'R') {
        x += 1;
        if (d[i - 1] == 1) {
          if (d[i] == 0 && x > y) {
            ge++;
            d[i + 1] = 2;
          } else {
            if (x == y)
              d[i + 1] = 0;
            else
              d[i + 1] = 1;
          }
        }
        if (d[i - 1] == 2) {
          d[i + 1] = 2;
        }
      }
      if (a[i] == 'U') {
        y += 1;
        if (d[i - 1] == 1) {
          d[i + 1] = 1;
        }
        if (d[i - 1] == 2) {
          if (d[i] == 0 && y > x) {
            ge++;
            d[i + 1] = 1;
          } else {
            if (x == y)
              d[i + 1] = 0;
            else
              d[i + 1] = 2;
          }
        }
      }
    }
  }
  printf("%d\n", ge);
  return 0;
}
