#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int MX1 = 1e5 + 5;
const int MX2 = 1e6 + 5;
const long long int inf = 4e18;
const long long int mod = 1e9 + 7;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b % 2) res = (res * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return res;
}
long long int mmi(long long int a) { return power(a, mod - 2); }
long long int cntbit(long long int n) {
  long long int cnt = 0;
  while (n) {
    n &= (n - 1);
    cnt++;
  }
  return cnt;
}
int n;
char c[MX1];
void solve() {
  cin >> n;
  int x, y;
  x = y = 0;
  int ans = 0;
  c[n + 1] = '*';
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] == 'U')
      y++;
    else
      x++;
    if (x == y) {
      if (c[i] == 'U' and c[i + 1] == 'U') ans++;
      if (c[i] == 'R' and c[i + 1] == 'R') ans++;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
