using System; namespace yukicoder { class Program { static void Main(string[] args) { //X座標 int X = int.Parse(Console.ReadLine()); //Y座標 int Y = int.Parse(Console.ReadLine()); //1命令につき最大の距離 int L = int.Parse(Console.ReadLine()); //Y座標 int a = Y / L; int b = Y % L; //X座標 int c = X / L; int d = X % L; //マイナスならプラスに変更 if (a < 0 || c < 0) { if (a < 0) { a = Y / -L; } if (c < 0) { c = X / -L; } } //回転回数 int x = 0; //回転 if((X>0&&Y>0)||(X<0&&Y>0)) { x = 1; } else if((X<0&&Y<0)||(X>0&&Y<0)|| (X == 0 && Y < 0)) { x = 2; } else if((X==0&&Y==0)|| (X == 0 && Y > 0)) { x = 0; } else if((X>0&&Y==0)||(X<0&&Y==0)) { x = 1; } int num = a + b + c + d + x; Console.WriteLine(num.ToString()); } } }