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