#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
long long T, n, m;
char s[maxn];
int main() {
  cin >> n;
  cin >> s + 1;
  int sign = 0, x = 0, y = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'U')
      y++;
    else if (s[i] == 'R')
      x++;
    if (y > x) {
      if (sign == -1) ans++;
      sign = 1;
    } else if (y < x) {
      if (sign == 1) ans++;
      sign = -1;
    }
  }
  cout << ans << endl;
  return 0;
}
