#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  string s;
  cin >> n >> s;
  long long int curx = (s[0] == 'R'), cury = 1 - curx, cur = (s[0] == 'U'),
                ans = 0;
  for (long long int i = 1; i < n; i++) {
    if (curx == cury && (cur == 1 ? s[i] == 'R' : s[i] == 'U'))
      ans++, cur = 1 - cur;
    curx += s[i] == 'R';
    cury += s[i] == 'U';
  }
  cout << ans;
  return 0;
}
