using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Numerics;

namespace Solving
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                new Solver().Solve();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }
    }

    class Solver
    {
        public void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            long ans = 0;
            ans = n * n - 4 * (n - 1);
            if (n % 2 == 0) ans += 1;

            Console.WriteLine(ans);
            //Console.ReadKey();
        }

    }

    class InputReader
    {
        public static int[] ReadIntArr()
        {
            return Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray

();
        }
        public static string ReadString()
        {
            return Console.ReadLine();
        }
        public static long[] ReadLongArr()
        {
            return Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray

();
        }
        public static double[] ReadDoubleArr()
        {
            return Console.ReadLine().Split(' ').Select(s => Double.Parse(s,

CultureInfo.InvariantCulture)).ToArray();
        }
        public static string[] ReadSplitString()
        {
            return Console.ReadLine().Split(' ').ToArray();
        }
        public static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return Int64.Parse(Console.ReadLine());
        }
        public static double ReadDouble()
        {
            return Double.Parse(Console.ReadLine(),

CultureInfo.InvariantCulture);
        }
        public static int[][] ReadIntMatrix(int numberofrows)
        {
            int[][] matrix = new int[numberofrows][];
            for (int i = 0; i < numberofrows; i++)
            {
                matrix[i] = ReadIntArr();
            }
            return matrix;
        }
        public static string[] ReadStringLines(int numberoflines)
        {
            string[] arr = new string[numberoflines];
            for (int i = 0; i < numberoflines; i++)
            {
                arr[i] = Console.ReadLine().Trim();
            }
            return arr;
        }
    }

    class OutputWriter
    {
        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Console.WriteLine(string.Join(" ", array));
        }
        public static void WriteLines<T>(IEnumerable<T> array)
        {
            foreach (var a in array) { Console.WriteLine(a); }
        }
    }
    class RDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Numerics;

namespace Solving
{
    class Program
    {
        static void Main(string[] args)
       {
            try
            {
                new Solver().Solve();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }
    }

    class Solver {
        public  void Solve() {
            int n = int.Parse(Console.ReadLine()), ans = 0;
            if (n % 2 == 0)
            {
                int sum = 0;
                for (int i = 2; i <= n - 2; i++)
                {
                    sum += i;
                }
                sum *= 2;
                ans = n * n - sum;
            }
            else {
                int sum = 0;
                for (int i = 2; i < n - 1; i++) {
                    sum += i;
                }
                sum *= 2;
                sum += (n - 1);
                ans = n * n - sum;
            }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }

    }

    class InputReader {
        public static int[] ReadIntArr() {
            return Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
        }
        public static string ReadString() {
            return Console.ReadLine();
        }
        public static long[] ReadLongArr() {
            return Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();
        }
        public static double[] ReadDoubleArr() {
            return Console.ReadLine().Split(' ').Select(s => Double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }
        public static string[] ReadSplitString() {
            return Console.ReadLine().Split(' ').ToArray();
        }
        public static int ReadInt() {
            return Int32.Parse(Console.ReadLine());
        }
        public static long ReadLong() {
            return Int64.Parse(Console.ReadLine());
        }
        public static double ReadDouble() {
            return Double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
        }
        public static int[][] ReadIntMatrix(int numberofrows) {
            int[][] matrix = new int[numberofrows][];
            for (int i = 0; i < numberofrows; i++) {
                matrix[i] = ReadIntArr();
            }
            return matrix;
        }
        public static string[] ReadStringLines(int numberoflines) {
            string[] arr = new string[numberoflines];
            for (int i = 0; i < numberoflines; i++) {
                arr[i] = Console.ReadLine().Trim();
            }
            return arr;
        }
    }

    class OutputWriter {
        public static void WriteArray<T>(IEnumerable<T> array) {
            Console.WriteLine(string.Join(" ", array));
        }
        public static void WriteLines<T>(IEnumerable<T> array) {
            foreach (var a in array) { Console.WriteLine(a); }
        }
    }
    class RDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;

namespace Codeforces
{
    class Program
    {

        #region input

        static long readLong() {
            long num;
            long.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static int readInt() {
            int num;
            int.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static bool readBool() {
            int num;
            int.TryParse(Console.ReadLine(),out num);
            return num != 0;
        }

        static long[] readLongs() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            long[] parsed = new long[nums.Length];
            for(int i = 0; i < nums.Length; i++) {
                long.TryParse(nums[i],out parsed[i]);
            }
            return parsed;
        }

        static int[] readInts() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            int[] parsed = new int[nums.Length];
            for(int i = 0; i < nums.Length; i++) {
                int.TryParse(nums[i],out parsed[i]);
            }
            return parsed;
        }

        static BitArray readBools() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            int parsed;
            BitArray bits = new BitArray(nums.Length);
            for(int i = 0; i < nums.Length; i++) {
                int.TryParse(nums[i],out parsed);
                if(parsed != 0) {
                    bits[i] = true;
                }
            }
            return bits;
        }

        #endregion

        #region utility

        static long largeModolu(long a, long b, long m) {
            long prev = a;
            long sum = (b & 1) > 0 ? a : 1;
            int digits = (int)(Math.Ceiling(Math.Log(b,2)));
            for(int i = 1; i < digits; i++) {
                pusing System;
using System.Collections;
using System.Collections.Generic;

namespace Codeforces
{
    class Program
    {

        #region input

        static long readLong() {
            long num;
            long.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static int readInt() {
            int num;
            int.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static bool readBool() {
            int num;
            int.TryParse(Console.ReadLine(),out num);
            return num != 0;
        }

        static long[] readLongs() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            long[] parsed = new long[nums.Length];
            for(int i = 0; i < nums.Length; i++) {
                long.TryParse(nums[i],out parsed[i]);
            }
            return parsed;
        }

        static int[] readInts() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            int[] parsed = new int[nums.Length];
            for(int i = 0; i < nums.Length; i++) {
                int.TryParse(nums[i],out parsed[i]);
            }
            return parsed;
        }

        static BitArray readBools() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            int parsed;
            BitArray bits = new BitArray(nums.Length);
            for(int i = 0; i < nums.Length; i++) {
                int.TryParse(nums[i],out parsed);
                if(parsed != 0) {
                    bits[i] = true;
                }
            }
            return bits;
        }

        #endregion

        #region utility

        static long largeModolu(long a, long b, long m) {
            long prev = a;
            long sum = (b & 1) > 0 ? a : 1;
            int digits = (int)(Math.Ceiling(Math.Log(b,2)));
            for(int i = 1; i < digits; i++) {
                prev = (prev * prev) % (m);
                if((b & (1l << i)) > 0) {
                    sum = (sum * prev) % (m);
                }
            }
            return sum;
        }

        #endregion

        static void Main(string[] args) {
            Console.WriteLine((int)Math.Pow((readInt() - 2),2));
        }
    }
}
rev = (prev * prev) % (m);
                if((b & (1l << i)) > 0) {
                    sum = (sum * prev) % (m);
                }
            }
            return sum;
        }

        #endregion

        static void Main(string[] args) {
            Console.WriteLine((int)Math.Pow((readInt() - 2),2));
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Maximum_Sum_of_Digits
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve());
            writer.Flush();
        }

        private static int Solve()
        {
            string s = reader.ReadLine();

            int ans = s[0] - '0';
            bool fn9 = false;
            for (int i = s.Length - 1; i > 0; i--)
            {
                if (fn9 || s[i] != '9')
                {
                    ans += 9;
                    ans += s[i] - '0';
                    fn9 = true;
                }
                else
                {
                    ans += 9;
                }
            }

            return ans;
        }
    }
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

class Program
{
    class T
    {
        public int X;
        public int Y;

        public T(int x, int y)
        {
            X = x;
            Y = y;
        }
    }
    //////////////////////////////////////////////////

    long tutu(long a)
    {
        long res = 0;
        for (; ; )
        {
            if (a == 0)
                break;
            res += a % 10;
            a /= 10;
        }
        return res;
    }

    //////////////////////////////////////////////////
    void Solution()
    {
        var n = rl;
        long a = 0;
        var p = n;
        for (; ; )
        {
            if (p == 0)
                break;
            p /= 10;
            a = a * 10 + 9;
        }
        if (a > n)
        {
            a /= 10;
        }
        var b = n - a;
        wln(tutu(a) + tutu(b));
    }
    //////////////////////////////////////////////////

    struct P : IComparable<P>
    {
        public long X;
        public long Y;

        public P(long x, long y)
        {
            X = x;
            Y = y;
        }

        public int CompareTo(P other) => X != other.X ? X.CompareTo(other.X) : Y.CompareTo(other.Y);
        public static int Comparison(P p1, P p2) => p1.CompareTo(p2);

        public static bool operator ==(P p1, P p2) => (p1.X == p2.X) && (p1.Y == p2.Y);
        public static bool operator !=(P p1, P p2) => (p1.X != p2.X) || (p1.Y != p2.Y);

        public static P operator +(P p1, P p2) => new P(p1.X + p2.X, p1.Y + p2.Y);
        public static P operator -(P p1, P p2) => new P(p1.X - p2.X, p1.Y - p2.Y);
    }

    void swap<T>(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }
    long gcd(long a, long b) => (b != 0) ? gcd(b, a % b) : a;
    long lcm(long a, long b) => a / gcd(a, b) * b;

    long rast2(long x1, long y1, long x2, long y2) => (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    long rast2(P p1, P p2) => (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
    long ccw(P p1, P p2, P p3) => p1.X * p2.Y + p1.Y * p3.X + p2.X * p3.Y - p2.Y * p3.X - p3.Y * p1.X - p1.Y * p2.X;

    StringBuilder _sb = new StringBuilder();
    void wln() { _sb.AppendLine(); }
    void wln<T>(T o) { _sb.AppendLine(o.ToString()); }
    void wsp<T>(T o) { _sb.Append(o).Append(" "); }
    void wrt<T>(T o) { _sb.Append(o); }
    void wln(double o) { _sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }
    void wsp(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12} ", o)); }
    void wrt(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }

    List<P> rpa(int n)
    {
        var res = new List<P>(n);
        for (int i = 0; i < n; i++)
            res.Add(new P(rl, rl));
        return res;
    }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { var res = _str.Substring(_ind); _count = 0; _ind = 0; return res; }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    List<int> ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res.ToList();
    }
    List<long> rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res.ToList();
    }
    List<double> rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res.ToList();
    }
    List<string> rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res.ToList(); }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main(string[] args) { new Program().Main(); }
    void Main()
    {
        //Console.SetIn(new StreamReader("input.txt")); Console.SetOut(new StreamWriter("output.txt"));
        Solution();
        Console.Write(_sb);
        //Console.In.Close(); Console.Out.Close();
    }
}


using System;
using System.Linq;

namespace Olymp
{
    class Program
    {
        static void Main(string[] args)
        {
            /*  int number = Convert.ToInt32(Console.ReadLine());
              int S = 0;
              if ((1<=number) && (number<=100))
              {

                  int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                  if (a.Length==number)
                  {
                  for (int i=0; i<a.Length; i++)
                  {
                      S = S + a[i];
                  }

                  if (S==0)
                  {
                      Console.WriteLine("EASY");
                      //Console.ReadKey();
                  }
                  else if (S>0)
                  {
                      Console.WriteLine("HARD");
                     // Console.ReadKey();
                  }
                  }
              }
              else
              {
                  //Console.ReadKey();
              } */

            /*
            string nomer = Console.ReadLine();
            if (nomer.Length == number)
            {
                int a = 8;
                //long chislo = Convert.ToInt64(nomer);
                if (nomer.ToString().Contains(a.ToString()) && (nomer.Length >= 11))
                {
                    int res = nomer.Length / 11;
                    //Console.WriteLine(res);
                    foreach (char ch in nomer)
                    {
                        if (ch == '8')
                        {
                            count++;
                        }
                    }
                    if (count <= res)
                    {
                        Console.WriteLine(count);
                        //  Console.ReadKey();
                    }
                    if (count > res)
                    {
                        Console.WriteLine(res);
                        // Console.ReadKey();
                    }

                }
                else
                {
                    Console.WriteLine("0");
                    Console.ReadKey();
                }
            } */

            float number = Convert.ToInt64(Console.ReadLine());
            float Sum = 0;
            float all;
            float a;
            float b;
            float g;
            float mas;
            if ((1 <= number) && (number <= 1000000000000))
            {
              if (number == 10000000000)
                {
                    Sum = 91;
                    Console.WriteLine(Sum);
                }
              if ((number % 2 == 0) && (number != 10000000000))
                {
                    all = number / 2;
                    a = all - 1;
                    b = all + 1;

                    g = float.Parse(Convert.ToString(a) + Convert.ToString(b));
                  //  Console.WriteLine(Convert.ToString(a) + Convert.ToString(b));
                    mas = g;
                    while (mas!= 0)
                    {
                        Sum = Sum + mas % 10;
                        mas = mas / 10;
                    }
                    Console.WriteLine(Sum);
                   // Console.ReadKey();

                }
              else
                {
                    all = (number - 1) / 2;
                    a = all;
                    b = all + 1;

                    g = float.Parse(Convert.ToString(a) + Convert.ToString(b));
                  // Console.WriteLine(Convert.ToString(a) + Convert.ToString(b));
                    mas = g;
                    while (mas != 0)
                    {
                        Sum = Sum + mas % 10;
                        mas = mas / 10;
                    }
                    Console.WriteLine(Sum);
                  //  Console.ReadKey();

                }

            }
            else
            {

            }
        }
    }
}


using System;
using System.Linq;

namespace B.MaxSummOfDigits
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = 0;

            var number = Convert.ToInt64(Console.ReadLine());
            if(number < 1 || number > 1000000000000) goto End;
            if (number == 1)
            {
                result = 1;
                goto End;
            }

            long middleOfNumber = number / 2 + 1;
            var secondHalf = number - middleOfNumber;

            foreach (var charNumb in middleOfNumber.ToString())
            {
                result += Int32.Parse(charNumb.ToString());
            }

            foreach (var charNumb in secondHalf.ToString())
            {
                result += Int32.Parse(charNumb.ToString());
            }

            End:
            Console.WriteLine(result);
            Console.Read();
        }
    }
}


using System;

namespace CSharp
{
    public class _1031A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

            int w = int.Parse(tokens[0]);
            int h = int.Parse(tokens[1]);
            int k = int.Parse(tokens[2]);

            Console.WriteLine(2 * k * (h + w + 2 - 4 * k));
        }
    }
}


using System;
using System.Linq;

namespace Delta
{
    class MainClass
    {

        public static void Main(string[] args)
        {
            int Sum = 0;
            byte i = 0;
            string input = Console.ReadLine();
            int[] Numbers = new int[3];
            foreach (string a in (input.Split(new char[] { ' ' })))
            {
                Numbers[i] = Convert.ToInt32(a);
                i++;
            }
            for (int q = 0; q < Numbers[2]; q++)
            {
                Sum += 2 * Numbers[0] + 2 * Numbers[1] - 4;
                Numbers[0] -= 4;
                Numbers[1] -= 4;
            }
            Console.WriteLine(Sum);

        }
    }
}


using System;
using System.Collections.Generic;

namespace Example
{
    class Program
    {
        static void Main()
        {
            string[] x = Console.ReadLine().Split();
            int w = int.Parse(x[0]);
            int h = int.Parse(x[1]);
            int k = int.Parse(x[2]);
            int P = 0;
            int S = 0;
            int sum = 0;

            for(int i = 0; i < k; i++)
            {

                P = 2*(w + h) - 4;
                sum += P;
                w -= 4;
                h -= 4;
            }

            Console.WriteLine(sum);
        }
    }
}


using System;
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] t = s.Split(new char[] { ' ' });
            var a = Convert.ToInt64(t[0]);
            var b = Convert.ToInt64(t[1]);
            var c = Convert.ToInt64(t[2]);
            Int64 n=0;
            for (int i = 1; i <= c; i++)
            {
                n = a * 2 + b * 2 - 4+n;
                a = a - 4;
                b = b - 4;
            }
            Console.WriteLine(n);
        }
    }


using System;

class Program
{
static void Main()
{
string input = Console.ReadLine();
int w = int.Parse(input.Split(' ')[0]), h = int.Parse(input.Split(' ')[1]), k = int.Parse(input.Split(' ')[2]);
//Console.WriteLine(w+" "+h+" "+k);
int res = w + h + (w-2) + (h-2);
//Console.WriteLine("m="+res);
for(int i = 1; i<k; i++){
int sh = (w-4*(i)), sw = (h-4*(i)), sin = (sh-2)*(sw-2);
int sos = sh*sw-sin;
//Console.WriteLine(sh + " " + sw + " " + sin + " " + sos);
res+=sos;
}
Console.WriteLine(res);
}
}


using System;

public class Program
{
	public static void Main()
	{
		var str = Console.ReadLine().Split(' ');
		var w = int.Parse(str[0]);
		var h = int.Parse(str[1]);
		var k = int.Parse(str[2]);
		int count = 0;
		for (var i = 1; i <= k;i++)
		{
			count += (w - 4*(i-1))*2 + (h - 4*(i-1) -2)*2;
		}
		Console.WriteLine(count);
	}
}
//


using System;

public class Program
{
	public static void Main()
	{
		var str = Console.ReadLine().Split(' ');
		var w = int.Parse(str[0]);
		var h = int.Parse(str[1]);
		var k = int.Parse(str[2]);
		int count = 0;
		for (var i = 1; i <= k;i++)
		{
			count += (w - 4*(i-1))*2 + (h - 4*(i-1) -2)*2;
		}
	}
}
//


using System;

namespace Task1
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var w = int.Parse(args[0].Split(' ')[0]);
            var h = int.Parse(args[0].Split(' ')[1]);
            var k = int.Parse(args[0].Split(' ')[2]);

            //            var w = 3;
            //            var h = 3;
            //            var k = 1;

            if (k == 1)
            {
                var result = (w*h) - ((w-2) * (h-2));
                Console.WriteLine(result);
            }
            else
            {
                var result = 0;
                for (var i = 0; i <= k; i++)
                {
                    result += (w * h) - ((w - 2) * (h - 2)) / 2 * i;
                }
                Console.WriteLine(result);
            }
        }
    }
}


using System;

namespace ConsoleApp2
{
    public class Program
    {
        public static uint Solve(uint h, uint w, uint k)
        {
            uint result = 0;

            for (int i = 1; i <= k; i++)
            {
                uint activeW = (uint)(w - ((i - 1) * 4));
                uint activeH = (uint)(h - ((i - 1) * 4));

                uint amount = 2 * (activeW + activeH) - 4;

                result += amount;
            }

            return result;
        }

        static int Main(string[] args)
        {
            uint w = uint.Parse(args[0]);
            uint h = uint.Parse(args[1]);
            uint k = uint.Parse(args[2]);

            uint result = Solve(h, w, k);

            Console.Write(result);

            return 0;
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var m = ReadLong();
                var res = Recurse(m);
                return res.Item1 + " " + res.Item2;
            }
        }

        Tuple<long, long> Recurse(long m)
        {
            if (m < 8)
                return Tuple.Create(m, m);
            var root = MaxRoot(m);
            var cube = root * root * root;
            var lesserCube = (root - 1) * (root - 1) * (root - 1);
            var firstAns = Recurse(m - cube);
            var secondAns = Recurse(cube - 1 - lesserCube);
            return firstAns.Item1 >= secondAns.Item1
                ? Tuple.Create(firstAns.Item1 + 1, cube + firstAns.Item2)
                : Tuple.Create(secondAns.Item1 + 1, lesserCube + secondAns.Item2);

        }

        long MaxRoot(long x)
        {
            var root = (long) Math.Floor(Math.Pow(x, 1d / 3));
            if ((root + 1) * (root + 1) * (root + 1) <= x)
                root++;
            return root;
        }

        int Solve(string s1, string s2, int L, int m)
        {
            var diff = s1.Length + s2.Length - L;
            if (diff > 0)
            {
                if (s1.Substring(s1.Length - diff) == s2.Substring(0, diff))
                    return 1 % m;
                else
                    return 0;
            }
            else
            {
                return FastPow(26, Math.Abs(diff), m);
            }
        }

        public int FastPow(int b, int pow, int mod)
        {
            if (pow == 0)
                return 1 % mod;
            if (pow == 1)
                return b % mod;
            if ((pow & 1) == 0)
                return FastPow(b * b % mod, pow / 2, mod);
            return b * FastPow(b, pow - 1, mod) % mod;
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }

        public static string JoinStrings(this IEnumerable<int> source, string delimeter)
        {
            return source.Select(x => x.ToString()).JoinStrings(delimeter);
        }
    }
}


/* Date: 23.10.2020 *  Time: 22:45 */
//
// CF 677 E
//
//

using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Example
{
# if ( ! ONLINE_JUDGE )
	public static StreamReader sr = new StreamReader ("C:\\TRR\\2020\\Task\\07 Codeforces\\050\\E.TXT");
	public static StreamWriter sw = new StreamWriter ("C:\\TRR\\2020\\Task\\07 Codeforces\\050\\OUTPUT.OUT");
# endif

	public static void Main (string[] args)
	{
		int n;

# if ( ONLINE_JUDGE )
		n = int.Parse (Console.ReadLine ());
# else
		sw.WriteLine ("*** # " + _q);
		n = int.Parse (sr.ReadLine ());
# endif

# if ( ! ONLINE_JUDGE )
		sw.WriteLine ("*** n = " + n);
# endif

		Int64 k = 1;
		for ( int i=2; i < n; i++ )
			if ( i != n/2 )
				k *= i;

# if ( ONLINE_JUDGE )
		Console.WriteLine (k);
# else
		sw.WriteLine (k);
		sw.Close ();
# endif
	}
}


using System;

class E
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		Console.WriteLine(Ncr(n, n / 2) / 2 * Factorial(n / 2 - 1) * Factorial(n / 2 - 1));
	}

	public static long Factorial(int n) { for (long x = 1, i = 1; ; x *= ++i) if (i >= n) return x; }
	public static long Npr(int n, int r)
	{
		if (n < r) return 0;
		for (long x = 1, i = n - r; ; x *= ++i) if (i >= n) return x;
	}
	public static long Ncr(int n, int r) => n < r ? 0 : n - r < r ? Ncr(n, n - r) : Npr(n, r) / Factorial(r);
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Policy;

public static class Ex
{
    public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }
    public static void yesno(this bool b) => Console.WriteLine(b ? "yes" : "no");
    public static void YesNo(this bool b) => Console.WriteLine(b ? "Yes" : "No");
    public static void YESNO(this bool b) => Console.WriteLine(b ? "YES" : "NO");
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    //public static bool Chmax<T>(ref this T a, T b) where T : struct, IComparable<T>
    //{
    //    if (b.CompareTo(a) > 0) { a = b; return true; }
    //    else return false;
    //}
    //[MethodImpl(MethodImplOptions.AggressiveInlining)]
    //public static bool Chmin<T>(ref this T a, T b) where T : struct, IComparable<T>
    //{
    //    if (b.CompareTo(a) < 0) { a = b; return true; }
    //    else return false;
    //}

    public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }

    public static int PopCount(this uint bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));
    }
}

partial class Program
{
    string GetStr() { return Console.ReadLine().Trim(); }
    char GetChar() { return Console.ReadLine().Trim()[0]; }
    int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
    long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
    double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
    string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
    string[][] GetStrArray(int N)
    {
        var res = new string[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');
        return res;
    }
    int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
    int[][] GetIntArray(int N)
    {
        var res = new int[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        return res;
    }
    public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
    long[][] GetLongArray(int N)
    {
        var res = new long[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
        return res;
    }
    char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
    double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
    double[][] GetDoubleArray(int N)
    {
        var res = new double[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
        return res;
    }
    char[][] GetGrid(int H)
    {
        var res = new char[H][];
        for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();
        return res;
    }
    T[] CreateArray<T>(int N, T value)
    {
        var res = new T[N];
        for (int i = 0; i < N; i++) res[i] = value;
        return res;
    }
    T[][] CreateArray<T>(int H, int W, T value)
    {
        var res = new T[H][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W];
            for (int j = 0; j < W; j++) res[i][j] = value;
        }
        return res;
    }
    T[][][] CreateArray<T>(int H, int W, int R, T value)
    {
        var res = new T[H][][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W][];
            for (int j = 0; j < W; j++)
            {
                res[i][j] = new T[R];
                for (int k = 0; k < R; k++) res[i][j][k] = value;
            }
        }
        return res;
    }

    Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    {
        var dic = new Dictionary<int, List<int>>();
        foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); }
        for (int i = 0; i < M; i++)
        {
            var input = GetIntArray();
            var a = isNode_0indexed ? input[0] : input[0] - 1;
            var b = isNode_0indexed ? input[1] : input[1] - 1;
            dic[a].Add(b);
            if (isDirected == false) dic[b].Add(a);
        }
        return dic;
    }
    //Dictionary<int, List<(int node, long cost)>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    //{
    //    var dic = new Dictionary<int, List<(int, long)>>();
    //    foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }
    //    for (int i = 0; i < M; i++)
    //    {
    //        var input = GetIntArray();
    //        var a = isNode_0indexed ? input[0] : input[0] - 1;
    //        var b = isNode_0indexed ? input[1] : input[1] - 1;
    //        var c = input[2];
    //        dic[a].Add((b, c));
    //        if (isDirected == false) dic[b].Add((a, c));
    //    }
    //    return dic;
    //}

    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                       : eq<T, long>() ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>() ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    void Multi<T>(out T a) => a = cv<T>(GetStr());
    void Multi<T, U>(out T a, out U b)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
    }
    void Multi<T, U, V>(out T a, out U b, out V c)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
    }
    void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
    }
    void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
    }
    void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
    }

    void Output<T>(T t) => Console.WriteLine(t);
    void Output<T>(IList<T> ls) => Console.WriteLine(string.Join(" ", ls));
    void Debug<T>(IList<IList<T>> ls)
    {
        foreach (var l in ls)
            foreach (var s in l)
                Console.WriteLine(s);
    }

    void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }

    int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 };
    int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };
    long mod = 1000000007;
}

partial class Program
{
    static void Main()
    {
        //Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
        //Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        //Console.Out.Flush();
        Console.Read();
    }

    public void Solve()
    {
        long N = GetLong();
        long M = N / 2;
        long b = 1;
        for (long i = 1; i < M; i++) b *= i;
        long B = 1;
        for (long i = M + 1; i <= N; i++) B *= i;
        Output(B / M /2* b);
    }

}


using System;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{
    private int N;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();

        int l = 1 << N;
        int cnt = 0;
        for (int i = 0; i < l; i++)
        {
            int c = 0;
            for (int j = 0; j < N; j++)
            {
                if ((i & (1 << j)) == 0) c++;
            }

            if (c * 2 == N) cnt++;
        }

        long p = 1;
        for (int i = 1; i <= N / 2 - 1; i++)
        {
            p *= i;
        }

        Console.WriteLine(cnt / 2 * p * p);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var a = ReadLongToken();
                var b = ReadLongToken();
                var n = ReadLongToken();
                var x = ReadLongToken();
                if (a == 1)
                    return (x + b * (n % commonMod)) % commonMod;
                var first = (FastPow(a, n, commonMod) * x) % commonMod;
                var q1 = (FastPow(a, n, commonMod) + commonMod - 1);
                var q2 = FastPow(a - 1, commonMod - 2, commonMod);
                var second = b * ((q1 * q2) % commonMod);
                return (first + second) % commonMod;
            }
        }

        long FastPow(long b, long pow, long mod)
        {
            if (pow == 0)
                return 1;
            if (pow == 1)
                return b;
            if (pow % 2 == 0)
                return FastPow((b * b) % mod, pow / 2, mod);
            return (FastPow(b, pow - 1, mod) * b) % mod;
        }

        //object Get()
        //{
        //    checked
        //    {
        //        var n = ReadIntToken();
        //        var k = ReadIntToken();
        //        var table = new bool[n, n];
        //        for (int i = 0; i < n; i++)
        //        {
        //            var input = Read();
        //            for (int j = 0; j < n; j++)
        //                table[i, j] = input[j] == '.';
        //        }
        //        var cells = BFS(table);
        //    }
        //}
        //Cell[,] BFS(bool[,] input)
        //{
        //    var n = input.GetLength(0);
        //    var cells = new Cell[n, n];
        //    var visited = new bool[n, n];
        //    var componentIndex = 0;
        //    for (int i = 0; i < n; i++)
        //    {
        //        for (int j = 0; j < n; j++)
        //        {
        //            if (!visited[i, j] && input[i, j])
        //                BFS(i, j, cells, input, visited, componentIndex);
        //        }
        //    }
        //}

        //void BFS(int i, int j, Cell[,] cells, bool[,] input, bool[,] visited, int ccIndex)
        //{
        //    var n = input.GetLength(0);
        //    for
        //}

        struct Cell
        {
            int CCNumber { get; set; }
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

        protected int ReadIntToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return int.Parse(tokens.Dequeue());
        }

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

        protected long ReadLongToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return long.Parse(tokens.Dequeue());
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }

        public static string JoinStrings(this IEnumerable<int> source, string delimeter)
        {
            return source.Select(x => x.ToString()).JoinStrings(delimeter);
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var a = ReadLongToken();
                var b = ReadLongToken();
                var n = ReadLongToken();
                var x = ReadLongToken();
                if (a == 1)
                    return (x + b * n) % commonMod;
                var first = (FastPow(a, n, commonMod) * x) % commonMod;
                var q1 = (FastPow(a, n, commonMod) + commonMod - 1);
                var q2 = FastPow(a - 1, commonMod - 2, commonMod);
                var second = b * ((q1 * q2) % commonMod);
                return (first + second) % commonMod;
            }
        }

        long FastPow(long b, long pow, long mod)
        {
            if (pow == 0)
                return 1;
            if (pow == 1)
                return b;
            if (pow % 2 == 0)
                return FastPow((b * b) % mod, pow / 2, mod);
            return (FastPow(b, pow - 1, mod) * b) % mod;
        }

        //object Get()
        //{
        //    checked
        //    {
        //        var n = ReadIntToken();
        //        var k = ReadIntToken();
        //        var table = new bool[n, n];
        //        for (int i = 0; i < n; i++)
        //        {
        //            var input = Read();
        //            for (int j = 0; j < n; j++)
        //                table[i, j] = input[j] == '.';
        //        }
        //        var cells = BFS(table);
        //    }
        //}
        //Cell[,] BFS(bool[,] input)
        //{
        //    var n = input.GetLength(0);
        //    var cells = new Cell[n, n];
        //    var visited = new bool[n, n];
        //    var componentIndex = 0;
        //    for (int i = 0; i < n; i++)
        //    {
        //        for (int j = 0; j < n; j++)
        //        {
        //            if (!visited[i, j] && input[i, j])
        //                BFS(i, j, cells, input, visited, componentIndex);
        //        }
        //    }
        //}

        //void BFS(int i, int j, Cell[,] cells, bool[,] input, bool[,] visited, int ccIndex)
        //{
        //    var n = input.GetLength(0);
        //    for
        //}

        struct Cell
        {
            int CCNumber { get; set; }
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

        protected int ReadIntToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return int.Parse(tokens.Dequeue());
        }

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

        protected long ReadLongToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return long.Parse(tokens.Dequeue());
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }

        public static string JoinStrings(this IEnumerable<int> source, string delimeter)
        {
            return source.Select(x => x.ToString()).JoinStrings(delimeter);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;

class Program
{
    private static long Sqrt3(long x)
    {
        long l = 1;
        long r = Math.Min(1000000, x);
        while (r - l > 1)
        {
            long mid = (l + r) / 2;
            long m3 = mid * mid * mid;
            if (m3 <= x)
                l = mid;
            else
                r = mid;
        }

        return l;
    }

    private static long div(long a, long b, long mod)
    {
        return (a * pow(b, mod - 2, mod)) % mod;
    }
    private static long pow(long a, long p, long mod)
    {
        long res = 1;
        while (p > 0)
        {
            if ((p & 1) == 1) res = (res * a) % mod;
            a = (a * a) % mod;
            p >>= 1;
        }
        return res;
    }

    private static long f(long x)
    {
        //Console.WriteLine(x);
        return (a * x + b) % Mod;
    }

    private static long g(long n, long x)
    {
        if (n == 0) return x;
        return f(g(n - 1, x));
    }

    private static long g2(long n, long x)
    {
        if (a == 1)
        {
            long qwe = x + b * n;
            return qwe % Mod;
        }

        long ans = (pow(a, n, Mod) * x) % Mod;

        long b1 = 1;
        long q= a;
        long top = (pow(a, n, Mod) - 1 + Mod) % Mod;
        top = (top * b1) % Mod;

        long botom = a - 1;
        //if (top % botom == 0) return ans + (top / botom);

        long s = div(top, botom, Mod);
        s = (s * b) % Mod;

        ans = (ans + s) % Mod;

        return ans;
    }

    private const long Mod = 1000000007;
    private static long a, b, n, x;
    static void Main(string[] args)
    {
        a =  ReadLong();
        b =  ReadLong();
        n =  ReadLong();
        x = ReadLong();

Console.WriteLine(g2(n, x));
        /*
        for (long i = 0; i < 10; i++)
            Console.WriteLine(i + " " + g(i, 1) + " " + g2(i, 1));

        Console.WriteLine(g(n, x));

        long[,] m = new long[2, 2];
        m[0, 0] = a;
        m[0, 1] = x;
        m[1, 1] = b;

        var mm = new Matrix(m, 2, 2);
        mm.Square();
        mm.Square();
        Console.WriteLine(mm);*/
    }

    public class Matrix
    {
        public int X;
        public int Y;
        public long[,] m;
        public Matrix(long[,] m, int x, int y)
        {
            this.m = m;
            this.X = x;
            this.Y = y;
        }

        public void Square()
        {
            var tmp = this * this;
            this.m = tmp.m;
        }

        public static Matrix operator +(Matrix a, Matrix b)
        {
            int x = a.X;
            int y = a.Y;
            long[,] m = new long[x, y];

            for (int i = 0; i < x; i++)
                for (int j = 0; j < y; j++)
                    m[i, j] = a.m[i, j] + b.m[i, j];

            return new Matrix(m, x, y);
        }

        public static Matrix operator -(Matrix a, Matrix b)
        {
            int x = a.X;
            int y = a.Y;
            long[,] m = new long[x, y];

            for (int i = 0; i < x; i++)
                for (int j = 0; j < y; j++)
                    m[i, j] = a.m[i, j] - b.m[i, j];

            return new Matrix(m, x, y);
        }

        public static Matrix operator *(Matrix a, Matrix b)
        {
            //if (a.Y != b.X) throw new Exception("Wrong dimensions");

            int x = a.X;
            int y = b.Y;

            int n = a.Y;

            long[,] m = new long[x, y];

            for (int i = 0; i < x; i++)
                for (int j = 0; j < y; j++)
                {
                    long sum = 0;
                    for (int k = 0; k < n; k++)
                        sum += a.m[i, k] * b.m[k, j];

                    m[i, j] = sum;
                }

            return new Matrix(m, x, y);
        }

        public override string ToString()
        {
            var sb = new StringBuilder();
            for (int i = 0; i < this.X; i++)
            {
                for (int j = 0; j < this.Y; j++)
                {
                    sb.Append(m[i, j]);
                    sb.Append(' ');
                }

                sb.AppendLine();
            }

            return sb.ToString();
        }
    }

    public class RSQ
    {
        private int[] m = new int[200001];
        public void Push(int pos, int v)
        {
            m[pos] += v;
        }

        public int Sum(int l, int r)
        {
            int ans = 0;
            while (l <= r) ans += m[l++];
            return ans;
        }
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n + 1];
        for (int i = 0; i <= n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt() - 1;
            int b = ReadInt() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt();
            int b = ReadInt();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 12;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int ReadInt()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong ReadULong()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long ReadLong()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] ReadIntArray(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadInt();
        return ans;
    }

    private static long[] ReadLongArray(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadLong();
        return ans;
    }

    private static char[] ReadString()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(string data)
    {
#if !ONLINE_JUDGE
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    private const int MOD = 1000000007;

    long ModPow(long x, long p)
    {
        long ret = 1;
        while (p > 0)
        {
            if ((p & 1) == 1)
                ret = ret * x % MOD;
            x = x * x % MOD;
            p >>= 1;
        }
        return ret;
    }

    public void Solve()
    {
        int a = ReadInt();
        int b = ReadInt();
        long n = ReadLong();
        int x = ReadInt();

        if (a == 1)
        {
            Write((x + 1L * n * b) % MOD);
            return;
        }

        long ans = x * ModPow(a, n % (MOD - 1));
        ans += (ModPow(a, n % (MOD - 1)) + MOD - 1) % MOD * ModPow(a - 1, MOD - 2) % MOD * b;
        Write(ans % MOD);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Long();
            var m = sc.Long();
            if (m > n) { var t = n; n = m; m = t; }
            var k = sc.Long() - 1;
            if (n == 1 || m == 1)
            {
                IO.Printer.Out.WriteLine(k + 1);
                return;
            }
            long l = 1, r = n * m;
            while (l <= r)
            {
                var v = (l + r) >> 1;
                long count = 0;
                long i = 1;
                for (; i * i < v && i <= m; i++)
                    count += Math.Min(n, v / i);
                long j = 1;
                for (; j * j < v && j <= n; j++)
                    count += Math.Min(m, v / j);
                count -= Math.Min(m, i - 1) * Math.Min(n, j - 1);
                if (count <= k)
                    l = v + 1;
                else r = v - 1;
            }
            IO.Printer.Out.WriteLine(l);
        }

        internal IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(); return a; }
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
    }
}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Linq;
    public class Printer : StreamWriter
    {
        static Printer()
        {
            Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
            Error = new Printer(System.IO.Stream.Null);
        }
        public static Printer Out { get; set; }
        public static Printer Error { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
        public void Flush() { str.Flush(); }

    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp61
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            int start = 1;
            int end = (n*m)+1;
            while (start<end)
            {
                int mid = (start + end) / 2;
                int j = GetNum(n, m, mid);
                if (j < k)
                {
                    start = mid+1;
                }

                else
                {
                    end = mid;
                }
            }
            Console.WriteLine(start-1);
        }
        static int GetNum(int n,int m,int a)
        {
            int ans = 0;
            for (int i = 1; i <= n; i++)
            {
                ans += Math.Min(m, (a - 1) / n);
            }
            return ans;
        }
    }
}


using System;

namespace Codeforces.R256
{
    public class Task_D
    {
        static void Main(string[] args)
        {
            new Task_D().Solve();
        }

        private long n;
        private long m;
        private long k;

        private void Solve()
        {
            var parts = Console.ReadLine().Split();
            n = long.Parse(parts[0]);
            m = long.Parse(parts[1]);
            k = long.Parse(parts[2]);

            long left = 1;
            long right = n * m;
            while (left < right)
            {
                var x = (left + right + 1) / 2;
                var before = GetLessThenCount(x);
                if (before < k)
                {
                    left = x;
                }
                else
                {
                    right = x - 1;
                }
            }
            Console.WriteLine(left);
        }

        private long GetLessThenCount(long num)
        {
            long sum = 0;
            for (int i = 1; i <= n; i++)
            {
                long w = Math.Min(m, (num - 1) / i);
                sum += w;
                if (w == 0)
                    break;
            }
            return sum;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class D
    {
        //*

        static void Main(string[] args)
        {

            string s = Console.ReadLine();
            string[] splitStr = s.Split(' ');
            int n = Convert.ToInt32(splitStr[0]);
            int m = Convert.ToInt32(splitStr[1]);
            int k = Convert.ToInt32(splitStr[2]);

            int p = n * m / 4;

            while (true)
            {
                int res = 0;
                int count = 0;
                for (int i = 1; i <= m; i++)
                {
                    int b = p / i;
                    res += Math.Min(b, n);
                    if ((p % i == 0) && (b <= n)) count++;
                }
                if ((k >= res - count) && (k <= res))
                {
                    Console.WriteLine(p);
                    return;
                }
                if (k < res - count)
                {
                    p -= p / 2;
                }
                else p += p / 2;
            }
        }
         /**/
    }
}


//author: camypaper
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using System.Numerics;
using Point = System.Numerics.Complex;
using static System.Math;
using Number = ModInt;
using System.Runtime.CompilerServices;
using N = ModInt;
namespace Program {
    public class Solver {
        Random rnd = new Random(0);
        public void Solve() {
            var n = rl;
            var m = rl;
            var L = ri;
            var R = ri;
            var cnt = new ModInt[2];
            cnt[0] += R / 2;
            cnt[1] += (R + 1) / 2;
            cnt[1] -= L / 2;
            var ans = new ModInt[2];
            ans[0] = 1;
            var s = n * m;
            while (s > 0) {
                if (s % 2 == 1) {
                    var nans = new ModInt[2];
                    for (int i = 0; i < 2; i++)
                        for (int j = 0; j < 2; j++)
                            nans[(i + j) % 2] += ans[i] * cnt[j];
                    s--;
                }
                else {
                    var ncnt = new ModInt[2];
                    for (int i = 0; i < 2; i++)
                        for (int j = 0; j < 2; j++)
                            ncnt[(i + j) % 2] += cnt[i] * cnt[j];
                    s /= 2;
                }
            }
            Console.WriteLine(ans[0]);
        }

        const long INF = 1L << 60;
        int ri => sc.Integer();
        long rl => sc.Long();
        double rd => sc.Double();
        string rs => sc.Scan();
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

        static IEnumerable<int> Rep(int n) => Enumerable.Range(0, n);
        static IEnumerable<int> RRep(int n) => Enumerable.Range(0, n).Reverse();
        static T[] Enumerate<T>(int n, Func<int, T> f) {
            var a = new T[n];
            for (int i = 0; i < a.Length; ++i) a[i] = f(i);
            return a;
        }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex {
    static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
        return string.Join(st, ie);
    }
    static public void Main() {
        //Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Program.Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO {
    using System.IO;
    using System.Text;
    using System.Globalization;

    public class Printer : StreamWriter {
        public override IFormatProvider FormatProvider => CultureInfo.InvariantCulture;
        public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    }

    public class StreamScanner {
        public StreamScanner(Stream stream) { str = stream; }

        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;

        private byte read() {
            if (isEof) return 0;
            if (ptr >= len) {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0) {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }

        public char Char() {
            byte b = 0;
            do b = read(); while ((b < 33 || 126 < b) && !isEof);
            return (char)b;
        }
        public string Scan() {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine() {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
        public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
        public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
}

#endregion
#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
    /// <summary>
    /// 剰余を取る値．
    /// </summary>
    public const long Mod = 998244353;

    /// <summary>
    /// 実際の数値．
    /// </summary>
    public long num;
    /// <summary>
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    /// </summary>
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    /// <summary>
    /// このインスタンスの数値を文字列に変換します．
    /// </summary>
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k) {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    /// <summary>
    /// 与えられた数の逆元を計算します．
    /// </summary>
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}
#endregion

#region Matrix
public class Matrix {
    int row, col;
    public N[] mat;
    /// <summary>
    /// <paramref name="r"/> 行 <paramref name="c"/> 列目の要素へのアクセスを提供します。
    /// </summary>
    /// <param name="r">行の番号</param>
    /// <param name="c">列の番号</param>
    public N this[int r, int c] {
        get { return mat[r * col + c]; }
        set { mat[r * col + c] = value; }
    }
    public Matrix(int r, int c) {
        row = r; col = c;
        mat = new N[row * col];
    }
    public static Matrix operator *(Matrix l, Matrix r) {
        System.Diagnostics.Debug.Assert(l.col == r.row);
        var ret = new Matrix(l.row, r.col);
        for (int i = 0; i < l.row; i++)
            for (int k = 0; k < l.col; k++)
                for (int j = 0; j < r.col; j++)
                    ret.mat[i * r.col + j] = (ret.mat[i * r.col + j] + l.mat[i * l.col + k] * r.mat[k * r.col + j]);
        return ret;
    }
    /// <summary>
    /// <paramref name="m"/>^<paramref name="n"/> を O(<paramref name="m"/>^3 log <paramref name="n"/>) で計算します。
    /// </summary>
    public static Matrix Pow(Matrix m, long n) {
        var ret = new Matrix(m.row, m.col);
        for (int i = 0; i < m.row; i++)
            ret.mat[i * m.col + i] = 1;
        for (; n > 0; m *= m, n >>= 1)
            if ((n & 1) == 1)
                ret = ret * m;
        return ret;

    }
    public N[][] Items {
        get {
            var a = new N[row][];
            for (int i = 0; i < row; i++) {
                a[i] = new N[col];
                for (int j = 0; j < col; j++)
                    a[i][j] = mat[i * col + j];
            }
            return a;
        }
    }
}
#endregion