#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long u = 0, d = 0, r = 0, l = 0;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == 'R')
      r++;
    else if (s[i] == 'L')
      l++;
    else if (s[i] == 'D')
      d++;
    else if (s[i] == 'U')
      u++;
  }
  long long ans = 0;
  if (s.length() % 2 != 0)
    cout << "-1";
  else {
    if (abs(u - d) % 2 == 0) {
      ans += abs(u - d) / 2;
      ans += abs(r - l) / 2;
    } else {
      ans += (abs(u - d) - 1) / 2;
      ans += (abs(r - l) + 1) / 2;
    }
    cout << ans;
  }
  return 0;
}
