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