#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll A, B, N;
	cin >> A >> B >> N;

	ll ans = 1LL << 50;
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= N; j++) {
			if(B * i % j != 0) continue;
			ll x = B * i / j - A;
			if(A + x < 0) continue;
			ans = min(ans, abs(x));
		}
	}

	cout << ans << endl;
}