#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const double eln = 2.718281828459045235360287471352;
string itos(long long n, int radix) {
  string ans;
  while (n > 0) {
    ans = (char)(n % radix + '0') + ans;
    n /= radix;
  }
  return ans;
}
int main(int argc, char* argv[]) {
  string s;
  cin >> s;
  int len = s.length();
  if (len % 2 != 0) {
    cout << "-1" << endl;
  } else {
    int u = 0, l = 0;
    for (typeof(len) i = 0; i < len; i++) {
      if (s[i] == 'L') l++;
      if (s[i] == 'R') l--;
      if (s[i] == 'U') u++;
      if (s[i] == 'D') u--;
    }
    l = abs(l);
    u = abs(u);
    cout << (l + u) / 2 << endl;
  }
  return 0;
}
