#include <bits/stdc++.h>
using namespace std;
static const double PI = 2 * acos(0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s.size() % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  int h = 0, v = 0;
  for (int i = 0; i < (int)(s.size()); i++) {
    switch (s[i]) {
      case 'U':
        v++;
        break;
      case 'D':
        v--;
        break;
      case 'R':
        h++;
        break;
      case 'L':
        h--;
        break;
    }
  }
  cout << (abs(h) + abs(v)) / 2 << endl;
  return 0;
}
