#include <bits/stdc++.h>
using namespace std;
int _I() {
  int x;
  scanf("%d", &x);
  return x;
}
struct node {
  int r, c;
  node() {}
  node(int x, int y) {
    r = x;
    c = y;
  }
  bool operator<(const node &R) { return r < R.r; }
};
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
vector<int> g[10001];
int vis[10001];
int pr[10001];
int f = 0;
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  int sz = g[u].size();
  for (int i = 0; i < sz; i++) {
    int x = g[u][i];
    dfs(x);
    pr[u] += g[x].size() == 0;
  }
  if (pr[u] < 3 && g[u].size()) f = 1;
}
void solve() {
  int n = _I();
  string s;
  cin >> s;
  int x = 0;
  int y = 0;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    int l = x;
    int r = y;
    if (s[i] == 'U') y++;
    if (s[i] == 'R') x++;
    if (s[i] == s[i + 1] && x == y) ans++;
  }
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}
