# Enter your code here. Read input from STDIN. Print output to STDOUT #!/bin/python n = int(raw_input().strip()) height = list(raw_input()) count = 0 valley = 0 for i in height: if i == "U": count += 1 else: if count == 0: count -= 1 valley += 1 else: count -=1 print valley