#include <bits/stdc++.h>
using namespace std;
bool perfect(int n) {
  if (n >= 0) {
    int x = sqrt(n);
    if (x * x == n)
      return true;
    else
      return false;
  }
  return false;
}
int nod(int n) {
  int cm = sqrt(n);
  int cnt = 0;
  for (int i = 1; i <= cm; i++) {
    if (n % i == 0) cnt += 2;
  }
  if (true == perfect(n)) cnt--;
  return cnt;
}
int main() {
  int i, j, k = 0, n, x = 0, y = 0;
  string str;
  cin >> n;
  cin >> str;
  for (i = 0; i < str.size(); i++) {
    if (str[i] == 'U') y++;
    if (str[i] == 'R') x++;
    if (x == y and str[i] == str[i + 1]) k++;
  }
  cout << k << endl;
  return 0;
}
