#include using namespace std; int P, Q, MaxSeki, Count; bool f(int shi, int bo, int start, int dep, int check){ //cout << "!" << endl; //cout << shi << " " << bo << endl; if(check > MaxSeki) { return false; } if(shi * Q == bo * P) { Count++; //return true; } if(shi * Q > bo * P) { return false; } if(dep == 0) { return false; } for(int i = start; i <= 6000; i++) { f(i*shi + bo, bo*i, i, dep - 1, check * i); } return true; } int main(){ int n; while(cin >> P >> Q >> MaxSeki >> n) { if(P == 0 && Q == 0 && MaxSeki == 0 && n == 0) break; Count = 0; f(0, 1, 1, n, 1); cout << Count << endl; } return 0; }