// Arup Guha
// 5/11/2016
// Solution to USACO 2016 Bronze February Problem: Milk Pails

import java.util.*;
import java.io.*;

public class pails {

	public static void main(String[] args) throws Exception {

		// Read in data.
		BufferedReader stdin = new BufferedReader(new FileReader("pails.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		int a = Integer.parseInt(tok.nextToken());
		int b = Integer.parseInt(tok.nextToken());
		int total = Integer.parseInt(tok.nextToken());

		int res = 0;

		// We'll just do the really simple (probably intended) solution.
		// We try all scenarios. Worst case run time is 1,000,000
		for (int i=0; i<=total; i+=a)
			for (int j=i; j<=total; j+=b)
				res = Math.max(res, j);

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("pails.out"));
		out.println(res);
		out.close();
		stdin.close();
	}
}