Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.

The world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. 

Fafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). 

Fafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. 


-----Input-----

The first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.

The second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.


-----Output-----

On a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.


-----Examples-----
Input
1
U

Output
0

Input
6
RURUUR

Output
1

Input
7
URRRUUU

Output
2



-----Note-----

The figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]

Difficulty: interview

Starter code:

Solutions:
n = int(input())
s = input()
x = 0
y = 0
ans = 0
pred = -1
for c in s:
    if c == 'U':
        y += 1
    else:
        x += 1
    if x == y:
        continue
    if x > y:
        cur = 0
    else:
        cur = 1
    if cur != pred and pred != -1:
        ans += 1
    pred = cur
print(ans)


N = int(input())
moves = input()

# print(N)
# print(moves)

pos_x, pos_y = 0, 0
coins = 0
kingdom = None
for m in moves:
    if m == "R":
        pos_x += 1
    else:
        pos_y += 1
    if pos_x < pos_y:
        if kingdom == "lower":
            coins += 1
        kingdom = "upper"
    if pos_x > pos_y:
        if kingdom == "upper":
            coins += 1
        kingdom = "lower"

print(coins)


n = int(input())
s = input()
bal = 0
last = 0
ans = 0
for i in s:
    if i == 'U':
        bal += 1
    else:
        bal -= 1
    if bal == 0:
        continue
    if last * bal < 0:
        ans += 1
    last = bal
print(ans)

n = int (input())
s = input()

place = 0
res = 0
prev_place = 0

for c  in s:
    if c == "U":
        place += 1
    else:
        place -= 1
    if place != 0 :
        if place *prev_place <0:
            res += 1
        prev_place = place

print(res)



n=int(input())
s=input()
x=0
y=0
ans=0
for i in range(n-1):
    if s[i]=='U':
        y+=1
    else:
        x+=1
    if y==x and s[i+1]==s[i]:
        ans+=1
print(ans)


n = int(input())
st = input()
isUp = st[0] == 'U'
x = 0
y = 0
if st[0] == 'U':
	y += 1
else:
	x += 1
c = 0
for i in range(1,n):
	if isUp and x == y and st[i] == 'R':
		c += 1
		isUp = False
	elif not isUp and x == y and st[i] == 'U':
		c += 1
		isUp = True
	if st[i] == 'U':
		y += 1
	else:
		x += 1
print(c)

def getCoord(x, y, t):
	if t == 'U':
		return (x, y + 1)
	return (x + 1, y)

n = int(input())
s = input()
x, y = getCoord(0, 0, s[0])
t = 1
if x < y:
	t = 0
ans = 0
for ch in s[1:]:
	x, y = getCoord(x, y, ch)
	if x == y:
		continue
	nt = 1
	if x < y:
		nt = 0
	if t != nt:
		t = nt
		ans += 1
print(ans)

n = int(input())
s = input()
r = 0
u = 0
cst = 0
if s[0] == 'R': r+=1
else: u += 1
for i in range(1,n-1):
    if s[i] == 'R': r+=1
    else: u+=1
    if u == r and s[i]==s[i+1]:
        cst += 1
print(cst)


def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

n = ii()
S = input().strip()
x = y = c = 0
k = None
for s in S:
    if s == 'U':
        y += 1
    else:
        x += 1
    if y > x:
        if k == 'D': c += 1
        k = 'U'
    elif x > y:
        if k == 'U': c += 1
        k = 'D'
        
print(c)

import sys, math

#f = open('input/input_2', 'r')
f = sys.stdin

N = int(f.readline())
S = f.readline().strip()

kingdom = 0
x = 0
y = 0
ans = 0
for action in S:
  if x == y and \
    ((kingdom == 1 and action == 'U') or
     (kingdom == 2 and action == 'R')):
     ans += 1

  if action == 'U':
    y += 1
  elif action == 'R':
    x += 1

  if x > y:
    kingdom = 1
  elif x < y:
    kingdom = 2

print(ans)


def sgn(x):
  if x == 0:
    return 0
  return 1 if x > 0 else -1

n = int(input())
x = 0
y = 0
res = 0
last = 0
for ch in input().strip():
  if ch == 'U':
    y += 1
  else:
    x += 1
  if sgn(x-y) * last < 0:
    res += 1
  if x != y:
    last = sgn(x-y)

print(res)


n = int(input())
s = input()
count = 0
kindom = 0
x, y = 0, 0
for i in s:
    if i == 'U':
        y += 1
    elif i == 'R':
        x += 1
    if x > y:
        if kindom == 2:
            count += 1
        kindom = 1
    if x < y:
        if kindom == 1:
            count += 1
        kindom = 2
print(count)


import math
n = int(input())
ans = 0
nr = 0
nu = 0
side = 0


mm = list(input())
fm = mm[0]
mm = mm[1:]

if fm == "U":
    side = 1
    nu = 1
else:
    side = -1
    nr = 1



for m in  mm:
    if nu==nr:

        if m =="U" and side == -1:
            ans +=1
            side = 1
        elif m == "R" and side == 1:
            ans += 1
            side = -1

    if m == "U":
        nu += 1
    else:
        nr +=1


print(ans)



n = int(input())

s = input()

x = 0
y = 0

k = 0
for i in range(len(s) - 1):
    if s[i] == 'U':
        y += 1
    else:
        x += 1
    if x == y:
        if s[i] == s[i + 1]:
            k += 1

print(k)


n = int(input())
s = list(input())

cur = [0,0]
f  = 0
c = 0
for i in s:
	if i=='U':
		cur[1]+=1
	else:
		cur[0]+=1
	if cur[0]>cur[1]:
		if f==2:
			c+=1
		f = 1
	elif cur[1]>cur[0]:
		if f==1:
			c+=1
		f = 2
print (c)

n = input()
s = list(input())

x, y = 0, 0
k = 0

cc = 0

for m in s:
    nk = k
    if m == 'U':
        y += 1
    elif m == 'R':
        x += 1
    if y > x:
        nk = 1
    elif y < x:
        nk = -1
    if nk * k == -1:
        cc += 1
    k = nk

print(cc)






input()
x=y=0
l=[]
s=input()
for ele in s:
  if ele=='U':
    y+=1
  else:
    x+=1
  if x>y:
    l.append(1)
  if x==y:
    l.append(l[-1])
  if x<y:
    l.append(0)
cnt=0
for i in range(1,len(l)):
  if l[i]!=l[i-1]:
    cnt+=1
print(cnt)


n=int(input())
x=0
y=0
s=input()
l=[]
for i in range(0,len(s)):
    if s[i]=='R':
        x+=1
    else:
        y+=1
    l.append(x-y)
if n<=2:
    print(0)
else:
    c=0
    for j in range(1,n-1):
        if l[j]==0 and l[j-1]*l[j+1]<0:
            c+=1
    print(c)



n = int(input())
s = input()
x = y = 0
p = 0
l = 'X'
lx = ly = -1
for c in s:
    if c == 'U':
        y += 1
    elif c == 'R':
        x += 1
    if lx == ly and l == c:
        p += 1
    l = c
    lx = x
    ly = y
print(p)

n = int(input())
S = input()

c = ([0, 1], [1, 0])[S[0] == 'R']
f = c[0] == 1

ans = 0
for el in S[1:]:
    if el == 'R':
        c[0] += 1

        if not f and c[0] - c[1] == 1:
            ans += 1
            f = not f

    elif el == 'U':
        c[1] += 1

        if f and c[1] - c[0] == 1:
            ans += 1
            f = not f

    else:
        exit(100500)

print(ans)


#This code sucks, you know it and I know it.  
#Move on and call me an idiot later.

n = int(input())
s = input()
x = 0; y = 0
cnt = 0
for i in range(n):
    if s[i] == "U":
        y += 1
    else:
        x += 1
    if x == y and i+1 < n:
        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):
            cnt += 1
print(cnt)

n = int(input())
s = input()
cnt = 0
p = True
x = 0
y = 0
for i in s:
    if not (x == 0 and y == 0):
        if p and x == y and i == 'R':
            cnt += 1
            p = False
        elif not p and x == y and i == 'U':
            cnt += 1
            p = True
    elif i == 'R':
        p = False
    else:
        p = True

    if i == 'R':
        x += 1
    if i == 'U':
        y += 1
print(cnt)


n = int(input())
s = input()
ind = "U"
ans = 0
if s[0] == "R":
	ind = "R"
countr = 0
countu = 0
for i in s:
	if i == "R":
		countr += 1
	else:
		countu += 1
	if ind == "U" and countr > countu:
		ind = "R"
		countr, countu = 1, 0
		ans += 1
	elif ind == "R"	and countu > countr:
		ind = "U"
		countu, countr = 1, 0
		ans += 1
print(ans)		





N=int(input())
s=input()

now=0
root=[]

for c in s:
	if c=='R':
		now+=1
	else:
		now-=1
	root.append(now)


ans=0
for i in range(1,N-1):
	if root[i]==0:
		if (root[i+1]>0) != (root[i-1]>0):
			ans+=1


print(ans)