#include #include #include #include #include using namespace std; int main() { int n; cin >> n; int level = 0; int nValleys = 0; string s; cin >> s; for(string::size_type i = 0; i < s.size(); ++i) { int prevLevel = level; if (s[i] == 'D') level--; else level++; if (prevLevel == -1 && level == 0) nValleys++; } cout << nValleys << endl; return 0; }