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