#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long MOD = 1000000007;
long long t, a, b;
long long solve(long long x, long long y) {
  if (x == 0 && y != 0) return 0;
  if (x == 0 && y == 0) return 1;
  if (x != 0 && y == 0) return 0;
  static map<pair<long long, long long>, long long> dp;
  if (dp.count(make_pair(x, y)) != 0) return dp[make_pair(x, y)];
  long long res = 0;
  for (long long v = y % a; v <= x && v <= y && v <= a; v += a)
    if (((y - v) % a == 0) && ((x - v) % t == 0))
      res += solve((x - v) / t, (y - v) / a);
  return dp[make_pair(x, y)] = res % MOD;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t >> a >> b;
  if (a == t && a != b) {
    cout << 0;
    return 0;
  }
  if (a == t && t == 1) {
    cout << "inf";
    return 0;
  }
  cout << solve(a, b);
  return 0;
}
