#include #include #include #include #include using namespace std; int to_depth(char s) { return s == 'D' ? -1 : 1; } int main() { int n; cin >> n; int depth= 0; int valleys= 0; for (int i= 0; i < n; ++i) { char s; cin >> s; depth+= s == 'D' ? -1 : 1; if (depth == -1 && s == 'D') valleys++; } cout << valleys << endl; /* Enter your code here. Read input from STDIN. Print output to STDOUT */ return 0; }