#include <bits/stdc++.h>
using namespace std;
int n, nowx, nowy, sum;
string s;
map<int, int> cnt;
int main() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]]++;
    if (cnt['U'] == cnt['R']) {
      if (s[i + 1] == s[i]) sum++;
    }
  }
  cout << sum;
  return false;
}
