#include <bits/stdc++.h>
using namespace std;
void gcd(long long &X, long long &Y, long long A, long long B) {
  if (!B) {
    X = 1;
    Y = 0;
  } else {
    gcd(X, Y, B, A % B);
    long long var = X;
    X = Y;
    Y = var - Y * (A / B);
  }
}
long long t, a;
long long f(long long xa, long long xb) {
  if (xa <= 0 || xb <= 0)
    return 0;
  else {
    long long s = 0;
    if (xa == xb) s = 1;
    long long invers, ins;
    gcd(invers, ins, t, a);
    if (invers <= 0) invers = a + invers % a;
    for (long long i =
             max((xb % a - xa % t) * invers, ((xa % t - xb % a) * invers) % a);
         i <= (xa - t - xa % t) / t && i <= (xb - a - xb % a) / a; i += a)
      if ((xa % t - xb % a - t * i) % a == 0) {
        s += f((xa - xa % t - t * i) / t, (xb - xa % t - t * i) / a);
        s = s % 1000000007;
      }
    return s;
  }
}
int main() {
  long long b;
  cin >> t >> a >> b;
  if (t == a && b != a)
    cout << '0';
  else {
    if (t == 1 && a == 1 && b == 1) {
      cout << "inf";
    } else
      cout << f(a, b);
  }
}
