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