#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 1;
string s;
long long n, ans, x, y, cnt;
bool rig = false, up = false;
int main() {
  cin >> n >> s;
  if (s[0] == 'U')
    up = true;
  else
    rig = true;
  x = y = 1;
  n++;
  while (n--) {
    if (up and y > x)
      ans++, up = false, rig = true;
    else if (rig and x > y)
      ans++, up = true, rig = false;
    if (s[cnt] == 'U') x++;
    if (s[cnt] == 'R') y++;
    cnt++;
  }
  cout << ans;
}
