Java - 183183 177 bytes
int p(int a,int b){int P,c,t,l=P=t=a,f=0;double p;while(P>0){a=t=l;c=0;while(t>0){if(a-(p=Math.pow(t,b))>=0&&t<=P){while((a-=p)>=0)c++;a+=p;}t--;}f=c<f||f==0?c:f;P--;}return f;}
183 bytes
int p(int a,int b){int P,c,t,l,f=0;P=t=l=a;double p;while(P>0){a=t=l;c=0;while(t>0){if(a-(p=Math.pow(t,b))>=0&&t<=P){while((a-=p)>=0){c++;}a+=p;}t--;}f=c<f||f==0?c:f;P--;}return f;}
Ungolfed
int p(int a, int b){
int P,c,t,ll=P=t=a,f=0;
P=t=l=a;
double p;
while (P>0){
a=t=l;
c=0;
while (t>0){
if (a-(p=Math.pow(t, b))>=0 && t<=P){
while((a-=p)>=0){
c++;
}
a+=p;
}
t--;
}
f=c<f||f==0?c:f;
P--;
}
return f;
}
Result
System.out.println(p(7, 2)); // 4
System.out.println(p(4,2)); // 1
System.out.println(p(7,3)); // 7
System.out.println(p(23,3)); // 9