"""
 *
 * Author:  <NAME>(coderemite)
 * Email: <EMAIL>
 *
 """
a=input()
x=abs(a.count('U')-a.count('D'))
x+=abs(a.count('R')-a.count('L'))
print([x//2,-1][x%2])
"""
 *
 * Author:  <NAME>(coderemite)
 * Email: <EMAIL>
 *
 """
a=input()
x=abs(a.count('U')-a.count('D'))
x+=abs(a.count('R')-a.count('L'))
print([x//2,-1][x%2])
*  * Author:  <NAME>(coderemite)  * Email: <EMAIL>  *