Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left.  An 'R' indicates he should move one unit right.  A 'U' indicates he should move one unit up.  A 'D' indicates he should move one unit down.

But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.


-----Input-----

The first and only line contains the string s (1 ≤ |s| ≤ 100 000) — the instructions Memory is given.


-----Output-----

If there is a string satisfying the conditions, output a single integer — the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.


-----Examples-----
Input
RRU

Output
-1

Input
UDUR

Output
1

Input
RUUR

Output
2



-----Note-----

In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.

In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin.

Difficulty: interview

Starter code:

Solutions:
s = input()
li = s.count("L")
ri = s.count("R")
ui = s.count("U")
di = s.count("D")
n = len(s)
if n % 2 != 0:
    print(-1)
else:
    print((abs(li-ri)+abs(di-ui))//2)


# You lost the game.
s = str(input())
n = len(s)
r = 0
if n % 2:
    print(-1)
else:
    U = D = L = R = 0
    for i in range(n):
        if s[i] == "L":
            L += 1
        elif s[i] == "R":
            R += 1
        elif s[i] == "U":
            U += 1
        else:
            D += 1
    if (U + D) % 2:
        r = 1
        if U > D:
            D += 1
            if R > L:
                R -= 1
            else:
                L -= 1
        else:
            U += 1
            if R > L:
                R -= 1
            else:
                L -= 1
    print(r+abs(U-D)//2+abs(R-L)//2)
    



r,l,u,d = 0,0,0,0
for c in input():
    if(c=='R'):
        r += 1
    elif(c=='L'):
        l += 1
    elif(c=='U'):
        u += 1
    elif(c=='D'):
        d += 1
c = abs(r-l)+abs(u-d)
if(c%2==0):
    print(c//2)
else:
    print(-1)

s = input()

if len(s) % 2 == 1:
    print(-1)
    return

horizontal = 0
vertical = 0

for k in s:
    if k == 'L':
        horizontal += 1
    elif k == 'R':
        horizontal -= 1
    elif k == 'U':
        vertical += 1
    elif k == 'D':
        vertical -= 1

horizontal = abs(horizontal)
vertical = abs(vertical)

print((horizontal+vertical)//2)

import sys, math
a = input()
n = len(a)
if n % 2 == 1:
    print(-1)
else:
    U = a.count('U')
    D = a.count('D')
    L = a.count('L')
    R = a.count('R')
    print(int(math.fabs(U - D) + math.fabs(L - R)) // 2)

'''
def main():
    from sys import stdin,stdout
def __starting_point():
    main()
'''
#10/9/22016-370.2
#2
def main():
    from sys import stdin,stdout
    s=stdin.readline().strip().lower()
    if len(s) & 1:
        stdout.write('-1')
    else:
        x=0
        y=0
        for i in s:
            if i=='l':
                x-=1
            elif i=='r':
                x+=1
            elif i=='u':
                y+=1
            elif i=='d':
                y-=1
        stdout.write(str((abs(x)+abs(y))//2))
            
def __starting_point():
    main()

__starting_point()

s = input()
if len(s) % 2:
    print(-1)
    return
x = 0
y = 0
for i in s:
    if i == 'L':
        x -= 1
    if i == 'R':
        x += 1
    if i == 'U':
        y += 1
    if i == 'D':
        y -= 1
x = abs(x)
y = abs(y)
print(x // 2 + y // 2 + max(x % 2, y % 2))

a = input()
L, R, U, D = 0, 0, 0, 0
for i in a:
    if i == 'L':
        L += 1
    elif i == 'R':
        R += 1
    elif i == 'U':
        U += 1
    elif i == 'D':
        D += 1
UD = abs(U - D)
LR = abs(L - R)
if len(a) % 2 != 0:
    print("-1")
elif UD == 0 and LR == 0:
    print('0')
else:
    x = UD + LR
    if x % 2 != 0:
        print("-1")
    else:
        print(x // 2)

commands = input()

nl = commands.count('L')
nr = commands.count('R')
nu = commands.count('U')
nd = commands.count('D')

if len(commands) % 2 != 0:
    print(-1)
else:
    dh = abs(nl - nr)
    dv = abs(nu - nd)
    if dh + dv == 0:
        print(0)
    elif dh % 2 == 0:
        print(dh // 2 + dv // 2)
    else:
        if dh < dv:
            dh, dv = dv, dh
        print((dh - 1) // 2 + (dv - 1) // 2 + 1)


s = input()
ans = 0

if len(s) % 2 != 0:
    print(-1)
else:
    u = s.count('U')
    d = s.count('D')
    r = s.count('R')
    l = s.count('L')
    if abs(u - d) % 2 == 0 and abs(r-l) % 2 == 0:
        ans = abs(u - d) // 2 + abs(r-l) // 2
    else:
        ans = abs(u - d) // 2 + abs(r-l) // 2 + 1
    print(ans)

s = input()
x = 0
y = 0
for i in range(len(s)):
    if (s[i] == 'R'):
        x += 1
    if (s[i] == 'L'):
        x -= 1
    if (s[i] == 'U'):
        y += 1
    if (s[i] == 'D'):
        y -= 1
if (abs(x) % 2 == 1 and abs(y) % 2 == 1):
    print(abs(x) // 2 + abs(y) // 2 + 1)
elif (abs(x) % 2 == 1):
    print(-1)
elif abs(y) % 2 == 1:
    print(-1)
else:
    print(abs(x) // 2 + abs(y) // 2)


s=input()
l,r,u,d=s.count('l'),s.count('r'),s.count('u'),s.count('d'),
x,y=s.count('L')-s.count('R'),s.count('U')-s.count('D'),
r=abs(x)//2+abs(y)//2
if abs(x)%2==abs(y)%2==0:
    print(r)
elif abs(x)%2==abs(y)%2==1:
    print(r+1)
else:
    print('-1')

R, L, U, D = 0, 0, 0, 0

for c in input():
    if c == 'R':
        R += 1
    elif c == 'L':
        L += 1
    elif c == 'U':
        U += 1
    elif c == 'D':
        D += 1

diff_RL = abs(R-L)
diff_UD = abs(U-D)

if (diff_RL % 2 == 0 and diff_UD % 2 == 0) or (diff_RL % 2 == 1 and diff_UD % 2 == 1):
    print((diff_RL+diff_UD) // 2)
else:
    print(-1)

s = input()
if len(s)%2==1: print('-1')
else:
  L = s.count('L')
  R = s.count('R')
  U = s.count('U')
  D = s.count('D')
  print(int(abs(L-R)/2+abs(U-D)/2))

s = input()

ans = -1

if len(s) % 2 == 0:
	UD = abs(s.count("U")-s.count("D"))
	LR = abs(s.count("L")-s.count("R"))
	
	ans = (UD+LR)//2

print(ans)

s = input()
n = len(s)
ans = 0
if n % 2 == 1:
    print("-1")
else:
    p = 0
    q = 0
    for i in range(0, n):
        if s[i] == "R":
            p += 1
        elif s[i] == "U":
            q += 1
        elif s[i] == "L":
            p -= 1
        elif s[i] == "D":
            q -= 1
    if p % 2 == 0:
        ans = abs(p // 2) + abs(q // 2)
    else:
        ans1 = min(abs(p - 1), abs(p + 1))
        ans2 = min(abs(q - 1), abs(q + 1))
        ans = (ans1 + ans2) // 2 + 1
    print(ans)


3

s = input()

if len(s) % 2 != 0:
    print(-1)
else:
    dy = s.count('U') - s.count('D')
    dx = s.count('R') - s.count('L')
    print((abs(dx) + abs(dy)) // 2)


s = input()
x, y = 0, 0
for ch in s:
	if ch == 'L':
		x = x - 1
	elif ch == 'R':
		x = x + 1
	elif ch == 'U':
		y = y - 1
	elif ch == 'D':
		y = y + 1
x = abs(x)
y = abs(y)
if x % 2 == y % 2:
	steps = x // 2 + y // 2
	if x % 2 == 1:
		steps = steps + 1
else:
	steps = -1	
print(steps)


import collections

def main():
    s = input()

    if len(s) % 2 == 1:
        print(-1)
        return

    ct = collections.Counter(s)
    print( (abs(ct['L'] - ct['R']) + abs(ct['U'] - ct['D']))//2 )

main()


line = input()
if len(line) % 2:
    print(-1)
else:
    x = abs(line.count('U')-line.count('D'))
    y = abs(line.count('R')-line.count('L'))
    print((x + y) // 2)

import math

s = input()
ans = 0
u = 0
d = 0
l = 0
r = 0
if len(s)%2!=0:
    print('-1')
else:
    for i in s:
        # print(i)
        if i == 'D':
            d += 1
        elif i == 'U':
            u += 1
        elif i == 'L':
            l += 1
        elif i == 'R':
            r += 1
    # print(u)
    # print(d)
    # print(r)
    # print(l)
    # print(abs(r-l))
    # print(abs(u-d))
    print(int((abs(r-l)+abs(u-d))/2))

s=list(input())
d=s.count('D')
l=s.count('L')
r=s.count('R')
u=s.count('U')
if(len(s)%2!=0):
    print('-1')
else:
    print(int(abs(l-r)/2+abs(u-d)/2))


s = input()
l = [0]*2
for el in s:
    if el == 'L':
        l[0]+=1
    if el == 'R':
        l[0]-=1
    if el == 'U':
        l[1]+=1  
    if el == 'D':
        l[1]-=1       
l[0] = abs(l[0])
l[1] = abs(l[1])
if sum(l)%2!=0:
    print(-1)
else:
    print(sum(l)//2)
        


s = input()
x = 0
y = 0
for i in s:
    if i == 'U':
        y+= 1
    elif i == 'D':
        y-= 1
    elif i == 'R':
        x+= 1
    else:
        x-= 1
if (abs(x)+abs(y))%2 == 1:
    print(-1)
else:
    print(int((abs(x)+abs(y))/2))