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