#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin >> n; char steps[n]; int valleys=0; int height[n+2]; height[0] = 0; height[n+1] = 0; for(int i=0;i> steps[i]; if (steps[i]=='U') { height[i+1] = height[i]+1; } else if (steps[i]=='D') { height[i+1] = height[i]-1; } } for(int i=0;i