#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int sz = s.size(), r = 0, u = 0, l = 0, d = 0;
  if (sz % 2) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < sz; i++) {
    if (s[i] == 'R')
      r++;
    else if (s[i] == 'U')
      u++;
    else if (s[i] == 'D')
      d++;
    else
      l++;
  }
  cout << (abs(l - r) + abs(u - d)) / 2 << endl;
  return 0;
}
