#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll N,M,K;
ll pow_mod(ll num,ll p,ll mod){
  ll mul=num;
  ll res=1;
  while(p){
    if(p%2)res=(res*mul)%mod;
    p/=2;
    mul=(mul*mul)%mod;
  }
  return res;
}

int appear[10]={};
ll GetCycleLen(){
  for(int i=0;i<10;i++)appear[i]=-1;
  int pm=pow_mod(N%10,M,10)%10;
  int cur=N%10;
  for(int ite=0;;ite++){
    if(appear[cur]!=-1)return ite;
    else{
      appear[cur]=ite;
      cur=(cur*pm)%10;
    }
  }
  return -1;
}

int main(){

  cin>>N>>M>>K;
  ll sz=GetCycleLen();
  ll res=0;
  // サイクルの長さから該当するものの数を計算
  for(int i=0;i<10;i++){
    if(appear[i]==-1)continue;
    else{
      ll tmp=(K-1)-appear[i];
      if(tmp<0)continue;
      ll cnt=(tmp/sz)+1;
      res=(res+cnt*i);
    }
  }
  cout<<res<<endl;
  
  return 0;
}
