#include <iostream>
using namespace std;
int main()
{
    int n,d,k,z=1,f=1,i;
    cin >>n>>d>>k;//5 3 4
    for (i=1; i<=k; ++i)
    {
        f=f+d;
        if (f!=5) {f=f%n;}
        z=z+f;//5, 7,
    }
    cout <<z;
    return 0;
}
