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