#include using namespace std; const int N = 1e6 + 7; int n,sm,i,f1,ans,f; char s[N]; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ scanf("%d%s",&n,s); for(i = 0 ; i < n ; i++) { sm = sm + (s[i] == 'U' ? 1 : -1); if( sm == 0 && s[i] == 'U') ans++; } printf("%d",ans); return 0; }