#include <bits/stdc++.h>
using namespace std;
void printarr(int arr[], int n) {
  for (int i = 0; i < n; ++i) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int xnow = 0;
  int ynow = 0;
  int xprev = 0;
  int yprev = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (xnow == ynow && ynow - yprev == 1) {
      xprev = xnow;
      yprev = ynow;
      if (s[i] == 'U') {
        ++ynow;
        ++ans;
      } else
        ++xnow;
    } else if (xnow == ynow && xnow - xprev == 1) {
      xprev = xnow;
      yprev = ynow;
      if (s[i] == 'R') {
        ++xnow;
        ++ans;
      } else
        ++ynow;
    } else {
      xprev = xnow;
      yprev = ynow;
      if (s[i] == 'R')
        ++xnow;
      else
        ++ynow;
    }
  }
  cout << ans << endl;
}
