#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  map<char, int64_t> m;
  int64_t l = s.size();
  if (l & 1) {
    cout << -1 << '\n';
    return;
  }
  for (int64_t i = 0; i < l; i++) {
    m[s[i]]++;
  }
  int64_t ans = (abs(m['U'] - m['D']) + abs(m['R'] - m['L'])) / 2;
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int64_t test = 1;
  while (test--) {
    solve();
  }
}
