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