#include <iostream>
using namespace std;
int main() {
int a, b, c, max;
cin >> a >> b >> c;
if (c % a == 0) max = c;
else {
int n = c / a; // максимальное количество цветков
max = 0;
for (int i = 0; i <= (n / 2) && max != c; i++) {
int first = (n - i) * b + i * a;
if (first > max && first <= c) max = first;
int second = (n - i) * a + i * b;
if (second > max && second <= c) max = second;
}
}
cout << max;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgYSwgYiwgYywgbWF4OwoJY2luID4+IGEgPj4gYiA+PiBjOwoJaWYgKGMgJSBhID09IDApIG1heCA9IGM7CgllbHNlIHsKCQlpbnQgbiA9IGMgLyBhOyAvLyDQvNCw0LrRgdC40LzQsNC70YzQvdC+0LUg0LrQvtC70LjRh9C10YHRgtCy0L4g0YbQstC10YLQutC+0LIKCQltYXggPSAwOwoJCWZvciAoaW50IGkgPSAwOyBpIDw9IChuIC8gMikgJiYgbWF4ICE9IGM7IGkrKykgewoJCQlpbnQgZmlyc3QgPSAobiAtIGkpICogYiArICBpICogYTsKCQkJaWYgKGZpcnN0ID4gbWF4ICYmIGZpcnN0IDw9IGMpIG1heCA9IGZpcnN0OwoJCQlpbnQgc2Vjb25kID0gKG4gLSBpKSAqIGEgKyAgaSAqIGI7CgkJCWlmIChzZWNvbmQgPiBtYXggJiYgc2Vjb25kIDw9IGMpIG1heCA9IHNlY29uZDsKCQl9IAoJfQoJY291dCA8PCBtYXg7CglyZXR1cm4gMDsKfQ==