#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::string NumberToString(T Number) {
  std::ostringstream ss;
  ss << Number;
  return ss.str();
}
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  int n;
  string str;
  cin >> n;
  cin >> str;
  int x = 0, y = 0, cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    char ch = str[i];
    if (ch == 'U') {
      y = y + 1;
    } else if (ch == 'R') {
      x = x + 1;
    }
    if (x == y) {
      if (ch == 'R') {
        if (str[i + 1] == 'R') {
          cnt++;
        }
      } else if (ch == 'U') {
        if (str[i + 1] == 'U') cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}
