#include using namespace std; int n, res, lv, cnt; char dir; int main() { cin >> n; for(int i = 1; i <= n; i++) { cin >> dir; if(dir == 'D') lv--; if(dir == 'U') { lv++; if(!lv) res++; } } cout << res; return 0; }