#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int MOD = 1e9 + 7;
int main() {
  long long t, a, b;
  cin >> t >> a >> b;
  int ans = 0;
  if (t == 1) {
    if (a == b) ans++;
    if (a == 1 and b == 1)
      ans += 10000;
    else if (a > 1) {
      long long sum = 0;
      for (long long x = b; x > 0; x /= a) {
        sum += (x % a);
      }
      if (sum == a or (sum == 1 and b > a)) ans++;
    }
  } else {
    if (a == b) ans++;
    if (a > 1) {
      vector<long long> coef1;
      for (long long x = b; x > 0; x /= a) {
        coef1.push_back(x % a);
      }
      vector<long long> coef2;
      for (long long x = a; x > 0; x /= t) {
        coef2.push_back(x % t);
      }
      if (coef1 == coef2) ans++;
    }
  }
  if (ans >= 10000)
    puts("inf");
  else
    cout << ans;
  return 0;
}
