#include <bits/stdc++.h>
using namespace std;
int main() {
  int r = 0, l = 0, d = 0, u = 0, len, i;
  string s;
  cin >> s;
  len = s.length();
  if (len & 1) {
    cout << -1;
    return 0;
  }
  for (i = 0; i < len; i++) {
    switch (s[i]) {
      case 'R':
        r++;
        break;
      case 'L':
        l++;
        break;
      case 'D':
        d++;
        break;
      case 'U':
        u++;
    }
  }
  int ans = abs(l - r) / 2 + abs(u - d) / 2;
  if ((l - r) & 1) ans++;
  cout << ans;
}
