#include <iostream>
using namespace std;
int main() {
unsigned n, m, t, sum, i=1;
cin>>n>>m;
for(i;i<n;i++){
t=i;
sum=0;
while(t!=0){
sum+=t%10;
t/=10;
}
if(sum*sum==m)cout<<i<<" ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cgl1bnNpZ25lZCBuLCBtLCB0LCBzdW0sIGk9MTsKCWNpbj4+bj4+bTsKCWZvcihpO2k8bjtpKyspewoJCXQ9aTsKCQlzdW09MDsKCQl3aGlsZSh0IT0wKXsKCQkJc3VtKz10JTEwOwoJCQl0Lz0xMDsKCQl9CgkJaWYoc3VtKnN1bT09bSljb3V0PDxpPDwiICI7Cgl9CglyZXR1cm4gMDsKfQ==