#include <bits/stdc++.h>
using namespace std;
const int maxN = 200 * 1000 + 20;
int n, cnt, x, y;
string s;
int main() {
  cin >> n >> s;
  s += '.';
  for (int i = 0; i < n; i++) {
    int xx = x;
    int yy = y;
    if (s[i] == 'U')
      y++;
    else
      x++;
    int xxx = x;
    int yyy = y;
    if (s[i + 1] == 'U')
      yyy++;
    else if (s[i + 1] == 'R')
      xxx++;
    if ((xx > yy && x == y && xxx < yyy) || (xx < yy && x == y && xxx > yyy))
      cnt++;
  }
  cout << cnt;
  return 0;
}
