#include <bits/stdc++.h>

using namespace std;

int modPow(int x, int n, int mod) {
    if (n == 0) return 1;
    int z = modPow(x, n / 2, mod);
    z *= z;
    z %= mod;
    if (n & 1) z *= x, z %= mod;
    return z;
}


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    a %= 10;
    vector<int> p;
    p.push_back(a);
    int t = a;
    while ((t * a) % 10 != a) {
        t *= a;
        t %= 10;
        p.push_back(t);
    }
    int cycleLength = p.size();
    int remPow =  modPow(b, c, cycleLength);
    int ans = remPow == 0? p.back(): p[remPow - 1];
    cout << ans << "\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    long double X, Y, R;
  cin >> X >> Y >> R;

  long ans = 0;
  int high = floor(Y + R);
  int low = ceil(Y - R);
  R += 1e-14;
  long double RR = R*R;

  for(long double h = high; h >= low; h--) {
    long double YYhh = (Y-h)*(Y-h);
    if(RR > YYhh ){
    long double halfLen = sqrt(RR - YYhh);
    int right = floor(X + halfLen);
    int left = ceil(X - halfLen);

    ans += right - left + 1; 
    }
  }

  cout << ans;

  return 0;
}