#include <bits/stdc++.h>
using namespace std;
int a,b,c,i,j,x;
int min(int a,int b)
{
	if(a>=b)return a;
	else return b;
}
int check(int a,int b,int c)
{
	int i,j;
	for(i=1;i<=(c-b)/a;i++)
	{
		for(j=1;j<=(c-a)/b;j++)
		{
			if(a*i+b*j==c)return 1;;
		}
	}
	return 0;
}
int main()
{
	ifstream f1("BAI2_16.INP");
	ofstream f2("BAI2_16.OUT");
	f1>>a>>b>>c;
	if(check(a,b,c)==1)f2<<c;
	else 
	{
			x=c/min(a,b);
			f2<<x*min(a,b);
}
}
