#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int a, aa, b, bb;
  a = 0, aa = 0, b = 0, bb = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') a++;
    if (s[i] == 'L') aa++;
    if (s[i] == 'U') b++;
    if (s[i] == 'D') bb++;
  }
  int sum = 0;
  if (s.size() % 2 == 1) {
    printf("-1\n");
  } else {
    a = abs(a - aa);
    b = abs(b - bb);
    printf("%d\n", (a + b) / 2);
  }
}
