#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
void debugdp(vector<vector<long long>> a) {
  for (auto it = (a).begin(); it != (a).end(); it++) {
    for (auto i = (*it).begin(); i != (*it).end(); i++) cout << *i << " ";
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  string s;
  cin >> n >> s;
  long long ans = 0;
  long long x = 0, y = 0, prex = 0, prey = 0, region = 0;
  if (s[0] == 'U') {
    y++;
    region = 1;
  } else {
    x++;
    region = 0;
  }
  for (long long i = 1; i < n; i++) {
    if (x == y && s[i] == 'U' && region == 0) {
      region = 1;
      ans++;
    } else if (x == y && s[i] == 'R' && region == 1) {
      region = 0;
      ans++;
    }
    if (s[i] == 'U')
      y++;
    else
      x++;
  }
  cout << ans << endl;
  return 0;
}
