#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 998244353;
double eps = 1e-12;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int coins = 0;
  int x, y;
  if (s[0] == 'U') {
    x = 0;
    y = 1;
  } else {
    x = 1;
    y = 0;
  }
  for (int i = 1; i < n; i++) {
    if (s[i] == 'U') {
      if (x == y) {
        if (s[i - 1] == 'U') coins++;
      }
      y++;
    } else {
      if (x == y) {
        if (s[i - 1] == 'R') coins++;
      }
      x++;
    }
  }
  cout << coins;
  return 0;
}
