#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 20;
long long a[N], b[N], n;
string s;
int main() {
  int n;
  while (cin >> s) {
    int x = 0, y = 0;
    for (int i = 0; s[i]; i++) {
      if (s[i] == 'U') y++;
      if (s[i] == 'D') y--;
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
    }
    x = abs(x), y = abs(y);
    if (x % 2 != y % 2)
      puts("-1");
    else {
      int mx = max(x, y);
      int mn = min(x, y);
      cout << (mx + mn) / 2 << endl;
    }
  }
  return 0;
}
