local s = io.read()
local n = #s
local cnt = 0
local t = {}
for i = 1, n do
  local sstr = s:sub(i, i)
  if sstr == "x" then
    cnt = cnt + 1
  else
    local tmp = {}
    tmp.c = cnt
    tmp.s = sstr
    table.insert(t, tmp)
    cnt = 0
  end
end
local ret = 0
local mab = math.abs
local nt = #t
local isok = true

local half = nt // 2
for i = 1, half do
  if t[i].s ~= t[nt + 1 - i].s then
    isok = false
    break
  else
    if i == 1 then
      ret = ret + mab(t[i].c - cnt)
    else
      ret = ret + mab(t[i].c - t[nt + 2 - i].c)
    end
  end
end
if nt % 2 == 1 then
  if nt == 1 then
    ret = ret + mab(t[1].c - cnt)
  else
    ret = ret + mab(t[half + 1].c - t[half + 2].c)
  end
end
print(isok and ret or -1)
