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