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

using namespace std;

int main()
{
    int a,b,c,p,res;
    freopen("flowers.in", "r", stdin);
    freopen("flowers.out", "w", stdout);
    cin >> a >> b >> c;
    p = c/a;
    if (c%a + a >= b)
       res = (p-1)*a + b;
    else
       res = p*a;
    cout << res;
    return(0);
}
