#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  pair<int, int> cur;
  cur.first = 0;
  cur.second = 0;
  vector<char> v, k;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') cur.first++;
    if (s[i] == 'U') cur.second++;
    if (cur.second < cur.first) {
      v.push_back('B');
    }
    if (cur.second > cur.first) {
      v.push_back('A');
    } else {
      v.push_back('O');
    }
  }
  for (int i = 0; i < v.size(); i++) {
    if (v[i] != 'O') {
      k.push_back(v[i]);
    }
  }
  int c = 0;
  for (int i = 0; i < k.size() - 1; i++) {
    if (k[i] != k[i + 1]) {
      c++;
    }
  }
  cout << c << endl;
}
