#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x = 0, y = 0;
  char a = 'L', b = 'R', c = 'U', d = 'D';
  string str;
  cin >> str;
  n = str.length();
  if (n % 2 != 0) {
    cout << "-1";
  }
  if (n % 2 == 0) {
    for (auto i = str.begin(); i < str.end(); i++) {
      if (a == *i) x = x - 1;
      if (b == *i) x = x + 1;
      if (d == *i) y = y - 1;
      if (c == *i) y = y + 1;
    }
    cout << (abs(x) + abs(y)) / 2;
  }
  return 0;
}
