#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.size() % 2 == 1)
    printf("-1");
  else {
    int up = 0, down = 0, right = 0, left = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'U')
        up++;
      else if (s[i] == 'D')
        down++;
      else if (s[i] == 'L')
        left++;
      else if (s[i] == 'R')
        right++;
    }
    int n1 = abs(up - down);
    int n2 = abs(right - left);
    if (n1 % 2 == 0 && n2 % 2 == 0)
      printf("%d", (n1 + n2) / 2);
    else if (n1 % 2 == 1 && n2 % 2 == 1)
      printf("%d", (n1 / 2 + n2 / 2) + 1);
    else
      printf("-1");
  }
  return 0;
}
