#include <bits/stdc++.h>
using namespace std;
long long solve(long long a, long long b, long long c, long long d) {
  if (b == 0 && d == 0) return 1;
  if (b == 0 || d == 0) return 0;
  long long ans = 0;
  for (int i = 0; i <= 1; i++) {
    long long a0 = i * c + d % c;
    if (a0 > b || a0 > d) break;
    if ((b - a0) % a == 0)
      ans = (ans + solve(a, (b - a0) / a, c, (d - a0) / c)) % 1000000007;
  }
  return ans % 1000000007;
}
int main() {
  long long t, a, b;
  cin >> t >> a >> b;
  if (t == 1 && a == 1) {
    if (b == 1)
      cout << "inf" << endl;
    else
      cout << 0 << endl;
    return 0;
  }
  cout << solve(t, a, a, b) % 1000000007;
  return 0;
}
