#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int len = s.size();
    int i;
    int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
    if (len & 1)
      printf("-1\n");
    else {
      for (i = 0; i < s.size(); i++) {
        if (s[i] == 'U')
          x1++;
        else if (s[i] == 'D')
          x2++;
        else if (s[i] == 'L')
          x3++;
        else if (s[i] == 'R')
          x4++;
      }
      int ans = (abs(x1 - x2) + abs(x3 - x4)) / 2;
      cout << ans << endl;
    }
  }
  return 0;
}
