local s = io.read("l")
local t = {}
for i=1,4 do
    local x = string.sub(s, i, i)
    t[x] = (t[x] or 0) + 1
end
for k,v in pairs(t) do
    if v ~= 2 then
        print("No")
        return
    end
end
print("Yes")