def countingValleys(steps, path):
    # Write your code here
    result = 0
    check = 0
    
    for p in path:
        if p == 'U':
            if check + 1 == 0:
                result += 1
            check += 1
        else:
            check -= 1   
    
    return result