#region itumono using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using static System.Math; using static Output; using static Consts; #region I/O public static class Output { public static void Put(string a) => Console.WriteLine(a); public static void Put(params object[] i) => Put(string.Join(" ", i)); public static void Put(IEnumerable a) => Put(string.Join(" ", a)); public static void PutV(IEnumerable a) { foreach (var z in a) Put(z); } public static void YN(bool i) { if (i) Put("Yes"); else Put("No"); } } public class Input { public static string Str => Console.ReadLine(); public static bool IsTypeEqual() => typeof(T).Equals(typeof(U)); public static T ConvertType(U a) => (T)Convert.ChangeType(a, typeof(T)); public static T Cast(string s) { if (IsTypeEqual()) return ConvertType(int.Parse(s)); else if (IsTypeEqual()) return ConvertType(long.Parse(s)); else if (IsTypeEqual()) return ConvertType(double.Parse(s)); else if (IsTypeEqual()) return ConvertType(char.Parse(s)); else if (IsTypeEqual()) return ConvertType(BigInteger.Parse(s)); else if (IsTypeEqual()) return ConvertType(decimal.Parse(s)); else return ConvertType(s); } public static T[] Castarr(string[] s) { var ret = new T[s.Length]; int i = 0; if (IsTypeEqual()) { var list = new List(); foreach (var t in s) { foreach (var u in t) { list.Add(ConvertType(char.Parse(u.ToString()))); } } return list.ToArray(); } foreach (var t in s) { if (IsTypeEqual()) ret[i++] = ConvertType(int.Parse(t)); else if (IsTypeEqual()) ret[i++] = ConvertType(long.Parse(t)); else if (IsTypeEqual()) ret[i++] = ConvertType(double.Parse(t)); else if (IsTypeEqual()) ret[i++] = ConvertType(BigInteger.Parse(t)); else ret[i++] = ConvertType(t); } return ret; } Queue q = new Queue(); void next() { var ss = Str.Split(' '); foreach (var item in ss) q.Enqueue(item); } public T cin() { if (!q.Any()) next(); return Cast(q.Dequeue()); } public T[] cinarr() { return Castarr(Str.Split(' ')); } public T[] cinarr(int n) { var ret = new T[n]; for (int i = 0; i < n; ++i) ret[i] = cin(); return ret; } public int Int => cin(); public long Long => cin(); public double Double => cin(); public char Char => cin(); public string String => cin(); public BigInteger BI => cin(); public int[] Intarr => cinarr(); public long[] Longarr => cinarr(); public double[] Doublearr => cinarr(); public char[] Chararr => cinarr(); public string[] Stringarr => cinarr(); public BigInteger[] BIarr => cinarr(); public void cin(out T t) { t = cin(); } public void mul(out T t, out U u) { t = cin(); u = cin(); } public void mul(out T t, out U u, out V v) { t = cin(); u = cin(); v = cin(); } public void mul(out T t, out U u, out V v, out W w) { t = cin(); u = cin(); v = cin(); w = cin(); } public void mul(out T t, out U u, out V v, out W w, out X x) { t = cin(); u = cin(); v = cin(); w = cin(); x = cin(); } public void mul(out T t, out U u, out V v, out W w, out X x, out Y y) { t = cin(); u = cin(); v = cin(); w = cin(); x = cin(); y = cin(); } public void mul(out T t, out U u, out V v, out W w, out X x, out Y y, out Z z) { t = cin(); u = cin(); v = cin(); w = cin(); x = cin(); y = cin(); z = cin(); } } #endregion class Program { static void Main(string[] args) { var CP = new CP(); CP.Solve(); } } #endregion itumono public static class Consts { public const int INF = 1 << 30; //public const long INF = 1L << 60; public const int MOD = 1000000007; //public const int MOD = 998244353; } public class CP { Input cin = new Input(); public void Solve() { Put((cin.Long * cin.Long + cin.Long - cin.Long) % cin.Long); // var N = cin.Int; // var R = cin.Intarr.Select(x => x + 100000).ToArray(); // var dp = new int[N + 1]; // dp[1] = R[0]; // for (int i = 0; i < N; ++i) // { // dp[] // } } }