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