#include <bits/stdc++.h>
using namespace std;
inline void getint(int& x) {
  int f = 1;
  x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline void getll(long long& x) {
  long long f = 1;
  x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline void writeint(int& x) {
  if (!x) {
    printf("0");
    return;
  } else if (x < 0)
    printf("-");
  int tmp = x < 0 ? -x : x, digit[17] = {0};
  while (tmp) {
    digit[++digit[0]] = tmp % 10;
    tmp /= 10;
  }
  for (int(i) = (digit[0]); (i) >= (1); --(i)) printf("%d", digit[i]);
}
inline void writell(long long& x) {
  if (!x) {
    printf("0");
    return;
  } else if (x < 0)
    printf("-");
  long long tmp = x < 0 ? -x : x;
  int digit[27] = {0};
  while (tmp) {
    digit[++digit[0]] = tmp % 10;
    tmp /= 10;
  }
  for (int(i) = (digit[0]); (i) >= (1); --(i)) printf("%d", digit[i]);
}
int n, curx, cury, ans;
string s;
int main() {
  getint(n);
  cin >> s;
  for (int(i) = (0); (i) <= (n - 1); ++(i))
    curx += (s[i] == 'R'), cury += (s[i] == 'U'),
        ans += (curx == cury && s[i + 1] == s[i]);
  writeint(ans);
  return 0;
}
