$s = gets.chomp
t = gets.chomp
def f(s, t, i = 0, j = 0, k = 0)
    return true if i >= $s.size
    begin
        j += 1 until s[j]*1 == $s[i]
    rescue
        return false
    end
    f(t, s, i + 1, k, j + 1)
end
puts f($s, t) || f(t, $s) ? 'Yes' : 'No'
