#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <string> using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin>>n; string x; cin>>x; int count=0,valley=0,mountain=0; //cout<<x.substr(0,1).compare("U")<<endl; for(int i=0; i<n;i++){ if(x.substr(i,1).compare("U")==0){ count++; } else if(x.substr(i,1).compare("D")==0){ count--; } if(count==0 && x.substr(i,1).compare("U")==0){ valley++; } else if(count==0 && x.substr(i,1).compare("D")==0){ mountain++; } } cout<<valley<<endl; return 0; }