#include<vector>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;

ll f(ll x,ll n){
  ll mod = 10;
  ll res = 1;
  while(n>0){
    if(n&1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  ll mod = 10;
  ll n,m,k;
  cin>>n>>m>>k;
  n%=mod;
  ll nm = f(n,m)%mod;
  set<ll> list;
  vector<ll> listl;
  list.insert(n);
  listl.push_back(n);
  ll loop=0;
  for(ll i=1;i<k;i++){
    n= nm*n%mod;
    if(list.count(n)>0){
      loop=i;
      break;
    }else{
      list.insert(n);
      listl.push_back(n);
    }
  }
  /*
  cout<<loop<<endl;
  for(int i=0;i<listl.size();i++){
    cout<<listl[i]<<" ";
  }cout<<endl;
  */
  ll loopsum = 0;
  for(auto i : list){
    loopsum +=i;
  }
  ll ans =0;
  ans += loopsum*(k/list.size());
  for(int i=0;i<(k%listl.size());i++){
    ans+=listl[i];
  }
  cout<<ans<<endl;
}
