#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int A[100000];
int main() {
  int n;
  string s;
  scanf("%d", &n);
  cin >> s;
  char now;
  char prev;
  int nowX, nowY;
  nowX = nowY = 0;
  int cnt = 0;
  if (s[0] == 'U') {
    now = 'U';
    nowY++;
  } else {
    nowX++;
    now = 'D';
  }
  bool flag = false;
  for (long long i = (1); i <= (n - 1); ++i) {
    if (s[i] == 'U') {
      nowY++;
    } else {
      nowX++;
    }
    if (nowY > nowX)
      now = 'U';
    else if (nowY < nowX)
      now = 'D';
    if (flag) {
      flag = false;
      if (now != prev) cnt++;
    }
    if (nowX == nowY) {
      prev = now;
      flag = true;
      continue;
    }
    prev = now;
  }
  printf("%d", cnt);
  printf("\n");
  return 0;
}
