import java.util.Scanner;
public class Main {
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); int n = scanner.nextInt();
int m = scanner.nextInt();
for(int i=1; i<n; i++) {
int a=i;
int sum=0;
while(a!=0) {
sum+=a%10;
a/=10;
}
if(sum*sum==m)
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwogCnB1YmxpYyBjbGFzcyBNYWluIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CgkJU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQlpbnQgbiA9IHNjYW5uZXIubmV4dEludCgpOwoJCWludCBtID0gc2Nhbm5lci5uZXh0SW50KCk7CgkJZm9yKGludCBpPTE7IGk8bjsgaSsrKSB7CgkJCWludCBhPWk7CgkJCWludCBzdW09MDsKCQkJd2hpbGUoYSE9MCkgewoJCQkJc3VtKz1hJTEwOwoJCQkJYS89MTA7CgkJCX0KCQkJaWYoc3VtKnN1bT09bSkKCQkJCVN5c3RlbS5vdXQucHJpbnQoaSsiICIpOwoJCX0KCX0KfQ==