/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001l
#define MOD 1000000007
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

/**
 * [l >= 0, r]にある1e4の倍数
 * @param l
 * @param r
 * @return
 */
int g(int l, int r){
    return r / (int)1e4 - l / (int)1e4;
}

/**
 * [l, r]にある，1e4の倍数
 * @param l
 * @param r
 * @return
 */
int f(int l, int r){
    if(r < 0) return g(-r-1, -l);
    if(l > 0) return g(l-1, r);
    return g(0,r) + g(0, -l) + 1;
}

int sqr(int x){
    int r = sqrt(x) - 1;
    while((r+1) * (r+1) <= x)r++;
    return r;
}

class DCircleLatticePoints {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        double x,y,r;
        cin >> x >> y >> r;
        x *= 1e4;
        y *= 1e4;
        r *= 1e4;
        int X = round(x);
        int Y = round(y);
        int R = round(r);
        int now_x = X - R;
        while(now_x % (int)1e4 != 0) now_x++;
        int ans = 0;
        while(now_x <= X + R){
            int t = sqr(R * R - (X - now_x) * (X - now_x));
            ans += f(Y - t, Y + t);
            now_x += 1e4;
        }
        cout << ans << endl;
	}
};

signed main() {
	DCircleLatticePoints solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

long long pow(long long x, long long n, long long MOD) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(){

    ll a, b, c;
    cin >> a >> b >> c;
    ll cnt = 0;
    // a は何回かけたら一周するか
    set<int> si;
    ll now = a;

    while(1){
        if(si.count(now*a%10ll)){
            break;
        }else{
            si.insert(now * a % 10ll);
            now *= a % 10;
            now %= 10;
        }
        cnt++;
    }

    ll b_c = pow(b, c, cnt);
    if (!b_c){
        b_c = cnt;
    }
    ll ans = pow(a, b_c, 10);
    cout << ans << endl;
    return 0;
}