def f(a,c,e,as1)
t=a
c1=0
while t<=e
as1<<[t,c1]
t=t*c
c1+=1
end
end
a,b,c,d,e=gets.chomp.split(" ").map{|e| e.to_i}
as1=[]
bs1=[]
f(a,c,e,as1)
f(b,d,e,bs1)
ans=-1
as1.each{|a1,c1|
bs1.each{|b1,c2|
if e==a1+b1 && (ans==-1 || ans>c1+c2) then
ans=c1+c2
end
}
}
if ans==-1 then
puts "No"
else
puts "Yes"
puts ans
end
ZGVmIGYoYSxjLGUsYXMxKQp0PWEKYzE9MAoKd2hpbGUgdDw9ZQoJYXMxPDxbdCxjMV0KCXQ9dCpjCgljMSs9MQplbmQKZW5kIAoKYSxiLGMsZCxlPWdldHMuY2hvbXAuc3BsaXQoIiAiKS5tYXB7fGV8IGUudG9faX0KYXMxPVtdCmJzMT1bXQpmKGEsYyxlLGFzMSkKZihiLGQsZSxiczEpCmFucz0tMQphczEuZWFjaHt8YTEsYzF8CgliczEuZWFjaHt8YjEsYzJ8CgkJaWYgZT09YTErYjEgJiYgKGFucz09LTEgfHwgYW5zPmMxK2MyKSB0aGVuCgkJCWFucz1jMStjMgoJCWVuZAoJfQp9CmlmIGFucz09LTEgdGhlbgoJcHV0cyAiTm8iCmVsc2UKCXB1dHMgIlllcyIKCXB1dHMgYW5zCmVuZA==