#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[100005];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, y = 0, cnt = 0;
  int pos = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U') {
      y++;
    } else if (s[i] == 'R') {
      x++;
    }
    mp[x][y] = 1;
    if (x - y == 1) {
      if (mp[x - 1][y] && mp[x - 2][y]) cnt++, pos = 0;
    } else if (y - x == 1) {
      if (mp[x][y - 1] && mp[x][y - 2]) cnt++, pos = 1;
    }
  }
  cout << cnt << endl;
}
