#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int mod = 10;
/*

typedef vector<vi> M;
inline M operator*(const M & a, const M &b){
	M c(a.size(), vi(b[0].size()));
	rep(i, c.size()) rep(j, c[0].size()){
		ll s = 0;
		rep(k, a[0].size()) s += (ll)a[i][k] * b[k][j] % mod;
		c[i][j] = s % mod;
	}
	return c;
}
inline M pow(M a, ll m){
	M res(a.size(), vi(a.size()));
	rep(i, a.size()) res[i][i] = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * a;
		a = a * a;
	}
	return res;
}
*/
ll pw(ll n, ll m){
	ll res = 1;
	for(n %= mod; m; m /= 2){
		if(m & 1) res = res * n % mod;
		n = n * n % mod;
	}
	return res;
}
int main(){
	
	ll n, m, k;
	cin >> n >> m >> k;
	n %= 10;
	
	
	ll N = pw(n, m);
	ll ans = 0;
	map<ll, pair<ll, int> > memo;
	
	ll cur = n;
	
	rep(i, k){
		
		ans += cur;
		
		if(memo.count(cur)){
			
			ll pans = memo[cur].first;
			int prev = memo[cur].second;
			
			int t = (k - i - 1) / (i - prev);
			
			ans += (ans - pans) * t;
			i += t * (i - prev);
		}
		
		memo[cur] = mp(ans, i);
		cur = cur * N % 10;
	}
	cout << ans << endl;
	
	/*
	ll N = pw(n, m); cerr<<n<<" "<<m<<"?"<<N<<endl; dbg(k);
	
	M A(2, vi(2));
	M b(2, vi(1));
	
	A[0][0] = N;
	A[1][0] = A[1][1] = 1;
	
	b[0][0] = 1;
	
	A = pow(A, k) * b;
	
	ll ans = A[1][0];
	ans = ans * n % mod;
	
	cout << ans << endl;
	*/
	return 0;
}
