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