#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c, pos, x, y;
  string ch;
  cin >> n >> ch;
  c = 0;
  x = 0;
  y = 0;
  pos = 0;
  if (ch[0] == 'R') {
    pos = 0;
    x += 1;
  } else {
    pos = 1;
    y += 1;
  }
  for (int i = 1; i < ch.length(); i++) {
    if (ch[i] == 'R') {
      if (x == y && pos == 1) {
        c += 1;
        pos = 0;
      }
      x += 1;
    }
    if (ch[i] == 'U') {
      if (x == y && pos == 0) {
        c += 1;
        pos = 1;
      }
      y += 1;
    }
  }
  cout << c;
  return 0;
}
