#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
typedef long long ll;
vector<int> d[10],a;
void init(){
	d[0].push_back(0);
	d[1].push_back(1);
	d[2].push_back(2);
	d[2].push_back(4);
	d[2].push_back(8);
	d[2].push_back(6);
	d[3].push_back(3);
	d[3].push_back(9);
	d[3].push_back(7);
	d[3].push_back(1);
	d[4].push_back(4);
	d[4].push_back(6);
	d[5].push_back(5);
	d[6].push_back(6);
	d[7].push_back(7);
	d[7].push_back(9);
	d[7].push_back(3);
	d[7].push_back(1);
	d[8].push_back(8);
	d[8].push_back(4);
	d[8].push_back(2);
	d[8].push_back(6);
	d[9].push_back(9);
	d[9].push_back(1);
}
int main(){
	init();
	ll n,m,k,ans=0;
	cin >> n >> m >> k;
	n%=10;
	int dis=d[n].size(),cnt=0;
	do{
		a.push_back(d[n][m*cnt%dis]);
		ans+=d[n][m*cnt%dis];
		cnt++;
	}while(m*cnt%dis!=0);
	ans*=(k/a.size());
	rep(i,k%a.size()) ans+=a[i];
	cout << ans << endl;
	return 0;
}
