#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  int i, j, k;
  cin >> s;
  int n = (int)(s.size());
  if (n & 1) {
    cout << -1 << endl;
    return 0;
  }
  int x = 0, y = 0;
  for (i = 0; s[i]; i++) {
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    if (s[i] == 'R') x++;
    if (s[i] == 'L') x--;
  }
  cout << (abs(x) + abs(y)) / 2 << endl;
  return 0;
}
