#include <bits/stdc++.h>
#define endl '\n';
using namespace std;
long long c[1000][1000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long m, n, p;
    cin >> m >> n >> p;
    vector<pair<int, int>> a{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    long long zapulnen = 0;
    long long segr = 0, segk = 0;
    long long red = 0;
    int n1 = n;
    int nul1 = 0, nul2 = 0;
    int n3 = n;
    long long sb = 0;
    while(zapulnen!=n3*n3){
        if(red==0){
            if(segk+a[red].second==n){
                red++;
            } else {
                c[segr][segk] = m;
                m++;
                segk+=a[red].second;
                zapulnen++;
                if(segr==p){
                    sb+=c[segr][segk];
                }
            }
        } else if(red == 1){
            if(segr+a[red].first==n1){
                red++;
            } else {
                c[segr][segk] = m;
                m++;
                segr+=a[red].first;
                zapulnen++;
                if(segr==p){
                    sb+=c[segr][segk];
                }
            }
        } else if(red==2){
            if(segk+a[red].second==nul1){
                red++;
            } else {
                c[segr][segk] = m;
                m++;
                segk+=a[red].second;
                zapulnen++;
                if(segr==p){
                    sb+=c[segr][segk];
                }
            }
        } else if(red == 3){
            if(segr+a[red].first==nul2){
                red = 0;
                nul2++;
                nul1++;
                n1--;
                n--;
            } else {
                c[segr][segk] = m;
                m++;
                segr+=a[red].first;
                zapulnen++;
                if(segr==p){
                    sb+=c[segr][segk];
                }
            }
        }
    }
    cout << sb << endl;
    return 0;
}

