#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a,b,c,p = 0,res = 0;
    freopen("flowers.in", "r", stdin);
    freopen("flowers.out", "w", stdout);
    cin >> a >> b >> c;
    for (int i = 0; i <= c; i++)
      for (int j = 0; j <= c; j++)
        if (i*a + j*b <= c && i+j >= p)
        {
          if (i+j > p)
          {
             p = i + j;
             res = i*a + j*b;
          }
          else
             res = max(res,i*a+j*b);
        }
    cout << res;
    return(0);
}
