#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n];
  int x = 0, y = 0, z = 0;
  vector<int> b;
  vector<int> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 'U') {
      x = x;
      y = y + 1;
      c.push_back(y);
      b.push_back(x);
    }
    if (a[i] == 'R') {
      x = x + 1;
      y = y;
      b.push_back(x);
      c.push_back(y);
    }
  }
  for (int i = 1; i < b.size(); i++) {
    if ((b[i] == c[i]) && (b[i] != 0) && (c[i] != 0)) {
      if (((b[i + 1] - b[i - 1] == 2) && (c[i + 1] == c[i - 1])) ||
          ((b[i + 1] == b[i - 1]) && (c[i + 1] - c[i - 1] == 2))) {
        z++;
      }
    }
  }
  cout << z << endl;
}
