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

pair <int, int> delta[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m, k;
    cin >> m >> n >> k;

    vector <vector <int>> arr(n + 2, vector <int> (n + 2));
    vector <vector <bool>> check(n + 2, vector <bool> (n + 2));

    for (int i = 0; i < n + 2; i++) {
        check[0][i] = true;
        check[n + 1][i] = true;
        check[i][0] = true;
        check[i][n + 1] = true;
    }

    /*for (int i = 0; i < n + 2; i++) {
        for (int j = 0; j < n + 2; j++) {
            cout << check[i][j] << ' ';
        }

        cout << endl;
    }*/

    int x = 1, y = 1, dir = 0;

    while (1) {
        arr[x][y] = m;
        m++;
        check[x][y] = true;

        if (check[x + delta[dir].first][y + delta[dir].second]) dir = (dir + 1) % 4;
        if (check[x + delta[dir].first][y + delta[dir].second]) break;

        x += delta[dir].first;
        y += delta[dir].second;
    }

    /*for (auto& i : arr) {
        for (int j : i) cout << j << '\t';
        cout << endl;
    }

    cout << endl << endl;*/
    int sum = 0;

    for (int i : arr[k]) sum += i;
    cout << sum << endl;

    return 0;

}
