#include <bits/stdc++.h>
const long long N = 2e6 + 1;
using namespace std;
long long n, x, y, cnt;
bool f, t;
char c;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> c;
  if (c == 'U')
    f = true, x++;
  else if (c == 'R')
    t = true, y++;
  for (int i = 1; i < n; i++) {
    cin >> c;
    if (c == 'U')
      x++;
    else if (c == 'R')
      y++;
    if (f == true && y > x)
      cnt++, f = false, t = true;
    else if (t == true && y < x)
      cnt++, f = true, t = false;
  }
  cout << cnt;
}
