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

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			int n = NextInt();
			int[] x1 = new int[n], x2 = new int[n], y1 = new int[n], y2 = new int[n];
			long sq = 0;
			int minX = int.MaxValue, maxX = int.MinValue, minY = int.MaxValue, maxY = int.MinValue;
			for ( int i = 0; i < n; ++i )
			{
				x1[i] = NextInt();
				y1[i] = NextInt();
				x2[i] = NextInt();
				y2[i] = NextInt();
				sq += (long)( x2[i] - x1[i] ) * ( y2[i] - y1[i] );
				minX = Math.Min( minX, x1[i] );
				maxX = Math.Max( maxX, x2[i] );
				minY = Math.Min( minY, y1[i] );
				maxY = Math.Max( maxY, y2[i] );
			}

			bool res = false;
			if ( maxX - minX == maxY - minY )
			{
				if ( sq == (long)( maxX - minX ) * ( maxX - minX ) )
				{
					res = true;
				}
			}

			Out.WriteLine( res ? "YES" : "NO" );
		}

		#region Local wireup

		public int[] NextIntArray( int size )
		{
			var res = new int[size];
			for ( int i = 0; i < size; ++i ) res[i] = NextInt();
			return res;
		}

		public long[] NextLongArray( int size )
		{
			var res = new long[size];
			for ( int i = 0; i < size; ++i ) res[i] = NextLong();
			return res;
		}

		public double[] NextDoubleArray( int size )
		{
			var res = new double[size];
			for ( int i = 0; i < size; ++i ) res[i] = NextDouble();
			return res;
		}

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }


using System;
using System.Linq;
using System.Text;

namespace CodeForces.Solutions.c325_memsql_1
{
	public class Program1
	{
		public static void Main()
		{
			checked
			{
				var n = int.Parse(Console.ReadLine());
				var rects = Enumerable.Range(0, n)
					.Select(i => Console.ReadLine().Split(' ').Select(long.Parse).ToArray())
					.ToArray();

				var s = rects.Select(a => (a[2] - a[0])*(a[3] - a[1])).Sum();
				var minX = rects.Min(a => a[0]);
				var maxX = rects.Max(a => a[2]);
				var minY = rects.Min(a => a[1]);
				var maxY = rects.Max(a => a[3]);

				var dx = (maxX - minX);
				var dy = (maxY - minY);
				Console.WriteLine(s == dx*dy && dx == dy ? "YES" : "NO");
			}
		}

	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
//using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _a()
    {
        int n = int.Parse(reader.ReadLine());
        int xmin = 31400, xmax = 0, ymin = 31400, ymax = 0;
        long square = 0;
        for (int i = 0; i < n; ++i)
        {
            string[] s = reader.ReadLine().Split();
            int x1 = int.Parse(s[0]), y1 = int.Parse(s[1]), x2 = int.Parse(s[2]), y2 = int.Parse(s[3]);
            xmin = Math.Min(xmin, x1);
            ymin = Math.Min(ymin, y1);
            xmax = Math.Max(xmax, x2);
            ymax = Math.Max(ymax, y2);
            square += (x2 - x1) * (y2 - y1);
        }
        if ((xmax - xmin) == (ymax - ymin) && square == (xmax - xmin) * (ymax - ymin))
            writer.Write("YES");
        else
            writer.Write("NO");
    }
    static void _b()
    {

    }
    static void _c()
    {

    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _a();
        reader.Close();
        writer.Close();
    }
}


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

namespace Square_and_Rectangles
{
    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() ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve()
        {
            int n = Next();

            var nn = new Rec[n];
            var xx = new List<int>();
            var yy = new List<int>();
            for (int i = 0; i < n; i++)
            {
                nn[i] = new Rec(Next(), Next(), Next(), Next());

                xx.Add(nn[i].x1);
                xx.Add(nn[i].x2);

                yy.Add(nn[i].y1);
                yy.Add(nn[i].y2);
            }

            xx.Sort();
            yy.Sort();

            if (xx[xx.Count - 1] - xx[0] != yy[yy.Count - 1] - yy[0])
            {
                return false;
            }

            var x = new List<int> {xx[0]};
            for (int i = 1; i < xx.Count; i++)
            {
                if (xx[i] != xx[i - 1])
                    x.Add(xx[i]);
            }
            var y = new List<int> {yy[0]};
            for (int i = 1; i < yy.Count; i++)
            {
                if (yy[i] != yy[i - 1])
                    y.Add(yy[i]);
            }
            foreach (Rec rec in nn)
            {
                rec.x1 = x.BinarySearch(rec.x1);
                rec.x2 = x.BinarySearch(rec.x2);
                rec.y1 = y.BinarySearch(rec.y1);
                rec.y2 = y.BinarySearch(rec.y2);
            }

            var nm = new int[x.Count,y.Count];
            foreach (Rec rec in nn)
            {
                for (int i = rec.x1 + 1; i <= rec.x2; i++)
                {
                    for (int j = rec.y1 + 1; j <= rec.y2; j++)
                    {
                        nm[i, j] = 1;
                    }
                }
            }

            for (int i = 1; i < x.Count; i++)
            {
                for (int j = 1; j < y.Count; j++)
                {
                    if (nm[i, j] == 0)
                        return false;
                }
            }

            return true;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }

        #region Nested type: Rec

        private class Rec
        {
            public int x1;
            public int x2;
            public int y1;
            public int y2;

            public Rec(int x1, int y1, int x2, int y2)
            {
                this.x1 = x1;
                this.x2 = x2;
                this.y1 = y1;
                this.y2 = y2;
            }
        }

        #endregion
    }
}


#define Online

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

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    partial class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            A();

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static void A()
        {
            int n = ReadInt();
            int minx = int.MaxValue;
            int maxx = int.MinValue;
            int miny = int.MaxValue;
            int maxy = int.MinValue;
            int S=0;
            for (int i = 0; i < n; i++)
            {
                ReadArray(' ');
                int x1=NextInt();
                int y1=NextInt();
                int x2=NextInt();
                int y2=NextInt();
                minx = Math.Min(minx, x1);
                miny = Math.Min(miny, y1);
                maxx = Math.Max(maxx, x2);
                maxy = Math.Max(maxy, y2);
                S+=(x2-x1)*(y2-y1);
            }
            if (maxx - minx == maxy - miny && S == (maxx - minx) * (maxy - miny)) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }

        static void B()
        {
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (comp(L[i], R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R, comp);
            Merge_Sort(A, q + 1, r, L, R, comp);
            Merge(A, p, q, r, L, R, comp);
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) >= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R, comp);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }

    partial class Program
    {
        static string[] tokens;
        static int cur_token = 0;

        static void ReadArray(char sep)
        {
            cur_token = 0;
            tokens = Console.ReadLine().Split(sep);
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static int NextInt()
        {
            return int.Parse(tokens[cur_token++]);
        }

        static long NextLong()
        {
            return long.Parse(tokens[cur_token++]);
        }

        static double NextDouble()
        {
            return double.Parse(tokens[cur_token++]);
        }

        static decimal NextDecimal()
        {
            return decimal.Parse(tokens[cur_token++]);
        }

        static string NextToken()
        {
            return tokens[cur_token++];
        }

        static string ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


using System;
using System.Linq;

class Program
{
    static void Main()
    {
        string str = Console.ReadLine();
        int n = int.Parse(str);

        var squares = new int[n, 4];

        int minX = -1, maxX = -1, minY = -1, maxY = -1;

        for (int i = 0; i < n; i++)
        {
            str = Console.ReadLine();
            var q = str.Split(new char[] {' '});

            squares[i, 0] = int.Parse(q[0]);
            squares[i, 1] = int.Parse(q[1]);
            squares[i, 2] = int.Parse(q[2]);
            squares[i, 3] = int.Parse(q[3]);

            if (i == 0)
            {
                minX = squares[i, 0];
                minY = squares[i, 1];
                maxX = squares[i, 2];
                maxY = squares[i, 3];
            }

            if (minX > squares[i, 0]) minX = squares[i, 0];
            if (minY > squares[i, 1]) minY = squares[i, 1];
            if (maxX < squares[i, 2]) maxX = squares[i, 2];
            if (maxY < squares[i, 3]) maxY = squares[i, 3];
            // Console.WriteLine(str);
        }

        if (maxX - minX != maxY - minY)
        {
            Console.WriteLine("NO");
            return;
        }

        int square1 = (maxX - minX) * (maxY - minY);
        int square2 = 0;

        for (int i = 0; i < n; i++)
        {
            square2 += (squares[i, 2] - squares[i, 0]) * (squares[i, 3] - squares[i, 1]);
        }

        if (square1 != square2)
        {
            // Console.WriteLine("NO 2 1: {0} 2: {1}", square1, square2);
            Console.WriteLine("NO");
            return;
        }

        Console.WriteLine("YES");
    }
}


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

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    void calc()
    {
        Scanner cin = new Scanner();
        int n = cin.nextInt();
        int[] x1 = new int[n];
        int[] x2 = new int[n];
        int[] y1 = new int[n];
        int[] y2 = new int[n];
        int x1min = 99999;
        int x2max = 0;
        int y1min = 99999;
        int y2max = 0;

        long sum = 0;

        for (int i = 0; i < n; i++)
        {
            x1[i] = cin.nextInt();
            y1[i] = cin.nextInt();
            x2[i] = cin.nextInt();
            y2[i] = cin.nextInt();
            x1min = Math.Min(x1min, x1[i]);
            x2max = Math.Max(x2max, x2[i]);
            y1min = Math.Min(y1min, y1[i]);
            y2max = Math.Max(y2max, y2[i]);
            sum += (x2[i] - x1[i]) * (y2[i] - y1[i]);
        }
        if (x2max - x1min == y2max - y1min && (long)(x2max - x1min) * (y2max - y1min) == sum)
        {
            Console.WriteLine("YES");
        }
        else Console.WriteLine("NO");
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }
}


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

namespace codeforces
{
    class rect
    {
        public Tuple<int, int> leftbottom;
        public Tuple<int, int> righttop;
        public rect(int x1, int y1, int x2, int y2)
        {
            leftbottom = new Tuple<int, int>(x1, y1);
            righttop = new Tuple<int, int>(x2, y2);
        }
    }
    public class A
    {
        public static int Main()
        {

            int n;

            n = int.Parse(System.Console.ReadLine());
            List<rect> rtlist = new List<rect>();
            SortedSet<int> xs = new SortedSet<int>();
            SortedSet<int> ys = new SortedSet<int>();
            for (int i = 0; i < n; i++)
            {
                string line= System.Console.ReadLine();
                string[] ints = line.Split(new char[1]{' '});
                int[] x = new int[4];
                for (int j = 0; j < 4; j++)
                    x[j] = int.Parse(ints[j]);
                rect rt = new rect(x[0], x[1], x[2], x[3]);
                xs.Add(x[0]);
                xs.Add(x[2]);
                ys.Add(x[1]);
                ys.Add(x[3]);
                rtlist.Add(rt);

            }
            if ((xs.Max - xs.Min) != (ys.Max - ys.Min))
            {
                System.Console.WriteLine("NO");
                return 0;
            }
            Dictionary<Tuple<int,int>,int> dic = new Dictionary<Tuple<int,int>,int>();

            for (int i = 0; i < n; i++)
            {
                rect rt = rtlist[i];
                var valuex = xs.GetViewBetween(rt.leftbottom.Item1, rt.righttop.Item1);
                var valuey = ys.GetViewBetween(rt.leftbottom.Item2, rt.righttop.Item2);
                foreach(int x in valuex)
                {
                    foreach (int y in valuey)
                    {
                        Tuple<int, int> tu = new Tuple<int, int>(x, y);
                        int v = 4;
                        if ((x == rt.leftbottom.Item1) || (x == rt.righttop.Item1))
                            v /= 2;
                        if ((y== rt.leftbottom.Item2) || (y == rt.righttop.Item2))
                            v /= 2;
                        if (dic.ContainsKey(tu))
                            dic[tu] += v;
                        else
                            dic[tu] = v;

                    }
                }
            }
            foreach(var x in dic)
            {
                var k = x.Key;
                var v = x.Value;
                if ((k.Item1 == xs.Max) || (k.Item1 == xs.Min))
                    v *= 2;
                if ((k.Item2 == ys.Max) || (k.Item2 == ys.Min))
                    v *= 2;
                if (v != 4)
                {
                    System.Console.WriteLine("NO");
                    return 0;
                }
            }
            System.Console.WriteLine("YES");
            return 0;

        }
    }
}


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

namespace codeforces
{
    class rect
    {
        public Tuple<int, int> leftbottom;
        public Tuple<int, int> righttop;
        public rect(int x1, int y1, int x2, int y2)
        {
            leftbottom = new Tuple<int, int>(x1, y1);
            righttop = new Tuple<int, int>(x2, y2);
        }
    }
    public class A
    {
        static void Main()
        {

            int n;

            n = int.Parse(System.Console.ReadLine());
            List<rect> rtlist = new List<rect>();
            SortedSet<int> xs = new SortedSet<int>();
            SortedSet<int> ys = new SortedSet<int>();
            for (int i = 0; i < n; i++)
            {
                string line= System.Console.ReadLine();
                string[] ints = line.Split(new char[1]{','});
                int[] x = new int[4];
                for (int j = 0; j < 4; j++)
                    x[j] = int.Parse(ints[j]);
                rect rt = new rect(x[0], x[1], x[2], x[3]);
                xs.Add(x[0]);
                xs.Add(x[2]);
                ys.Add(x[1]);
                ys.Add(x[3]);
                rtlist.Add(rt);

            }
            if ((xs.Max - xs.Min) != (ys.Max - ys.Min))
            {
                System.Console.WriteLine("NO");
                return;
            }
            Dictionary<Tuple<int,int>,int> dic = new Dictionary<Tuple<int,int>,int>();

            for (int i = 0; i < n; i++)
            {
                rect rt = rtlist[i];
                var valuex = xs.GetViewBetween(rt.leftbottom.Item1, rt.righttop.Item1);
                var valuey = xs.GetViewBetween(rt.leftbottom.Item2, rt.righttop.Item2);
                foreach(int x in valuex)
                {
                    foreach (int y in valuex)
                    {
                        Tuple<int, int> tu = new Tuple<int, int>(x, y);
                        int v = 4;
                        if ((x == rt.leftbottom.Item1) || (x == rt.righttop.Item1))
                            v /= 2;
                        if ((y== rt.leftbottom.Item2) || (y == rt.righttop.Item2))
                            v /= 2;
                        if (dic.ContainsKey(tu))
                            dic[tu] += v;
                        else
                            dic[tu] = v;

                    }
                }
            }
            foreach(var x in dic)
            {
                var k = x.Key;
                var v = x.Value;
                if ((k.Item1 == xs.Max) || (k.Item1 == xs.Min))
                    v *= 2;
                if ((k.Item2 == ys.Max) || (k.Item2 == ys.Min))
                    v *= 2;
                if (v != 4)
                {
                    System.Console.WriteLine("NO");
                    return;
                }
            }
            System.Console.WriteLine("YES");
            return;

        }
    }
}


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

namespace codeforces
{
    class rect
    {
        public Tuple<int, int> leftbottom;
        public Tuple<int, int> righttop;
        public rect(int x1, int y1, int x2, int y2)
        {
            leftbottom = new Tuple<int, int>(x1, y1);
            righttop = new Tuple<int, int>(x2, y2);
        }
    }
    public class A
    {
        public static int Main()
        {

            int n;

            n = int.Parse(System.Console.ReadLine());
            List<rect> rtlist = new List<rect>();
            SortedSet<int> xs = new SortedSet<int>();
            SortedSet<int> ys = new SortedSet<int>();
            for (int i = 0; i < n; i++)
            {
                string line= System.Console.ReadLine();
                string[] ints = line.Split(new char[1]{','});
                int[] x = new int[4];
                for (int j = 0; j < 4; j++)
                    x[j] = int.Parse(ints[j]);
                rect rt = new rect(x[0], x[1], x[2], x[3]);
                xs.Add(x[0]);
                xs.Add(x[2]);
                ys.Add(x[1]);
                ys.Add(x[3]);
                rtlist.Add(rt);

            }
            if ((xs.Max - xs.Min) != (ys.Max - ys.Min))
            {
                System.Console.WriteLine("NO");
                return 0;
            }
            Dictionary<Tuple<int,int>,int> dic = new Dictionary<Tuple<int,int>,int>();

            for (int i = 0; i < n; i++)
            {
                rect rt = rtlist[i];
                var valuex = xs.GetViewBetween(rt.leftbottom.Item1, rt.righttop.Item1);
                var valuey = xs.GetViewBetween(rt.leftbottom.Item2, rt.righttop.Item2);
                foreach(int x in valuex)
                {
                    foreach (int y in valuex)
                    {
                        Tuple<int, int> tu = new Tuple<int, int>(x, y);
                        int v = 4;
                        if ((x == rt.leftbottom.Item1) || (x == rt.righttop.Item1))
                            v /= 2;
                        if ((y== rt.leftbottom.Item2) || (y == rt.righttop.Item2))
                            v /= 2;
                        if (dic.ContainsKey(tu))
                            dic[tu] += v;
                        else
                            dic[tu] = v;

                    }
                }
            }
            foreach(var x in dic)
            {
                var k = x.Key;
                var v = x.Value;
                if ((k.Item1 == xs.Max) || (k.Item1 == xs.Min))
                    v *= 2;
                if ((k.Item2 == ys.Max) || (k.Item2 == ys.Min))
                    v *= 2;
                if (v != 4)
                {
                    System.Console.WriteLine("NO");
                    return 0;
                }
            }
            System.Console.WriteLine("YES");
            return 0;

        }
    }
}


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

namespace CodeForces
{
    class R191MemSql_A
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] x1 = new int[n];
            int[] x2 = new int[n];
            int[] y1 = new int[n];
            int[] y2 = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                x1[i] = int.Parse(s[0]);
                y1[i] = int.Parse(s[1]);
                x2[i] = int.Parse(s[2]);
                y2[i] = int.Parse(s[3]);
            }

            int it = (1 << n);
            for (int i = 1; i < it; i++)
            {
                int area = 0;
                int maxx = -1, minx = 35000, maxy = -1, miny = 35000;
                for (int j = 0; j < n; j++)
                {
                    int e = (1 << j);
                    if ((i & e) > 0)
                    {
                        area += (x2[j] - x1[j]) * (y2[j] - y1[j]);
                        maxx = Math.Max(maxx, x2[j]);
                        maxy = Math.Max(maxy, y2[j]);
                        minx = Math.Min(minx, x1[j]);
                        miny = Math.Min(miny, y1[j]);
                    }
                }
                if (area == (maxx - minx) * (maxy - miny)
                    && (maxx - minx) == (maxy - miny))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}


using System;
using System.Linq;

class Program
{
    static void Main()
    {
        string str = Console.ReadLine();
        int n = int.Parse(str);

        var squares = new int[n, 4];

        int minX = -1, maxX = -1, minY = -1, maxY = -1;

        for (int i = 0; i < n; i++)
        {
            str = Console.ReadLine();
            var q = str.Split(new char[] {' '});

            squares[i, 0] = int.Parse(q[0]);
            squares[i, 1] = int.Parse(q[1]);
            squares[i, 2] = int.Parse(q[2]);
            squares[i, 3] = int.Parse(q[3]);

            if (i == 0)
            {
                minX = squares[i, 0];
                minY = squares[i, 1];
                maxX = squares[i, 2];
                maxY = squares[i, 3];
            }

            if (minX > squares[i, 0]) minX = squares[i, 0];
            if (minY > squares[i, 1]) minY = squares[i, 1];
            if (maxX < squares[i, 2]) maxX = squares[i, 2];
            if (maxY < squares[i, 3]) maxY = squares[i, 3];
            // Console.WriteLine(str);
        }

        Console.WriteLine("min X: {0}", minX);
        Console.WriteLine("min Y: {0}", minY);
        Console.WriteLine("max X: {0}", maxX);
        Console.WriteLine("max Y: {0}", maxY);

        // 31400, 0 ≤ y1 < y2 ≤ 31400
        var a = new byte[31401, 31401];

        for (int i = 0; i < n; i++)
        {
            for (int x = squares[i, 0]; x < squares[i, 2]; x++)
            {
                for (int y = squares[i, 1]; y < squares[i, 3]; y++)
                {
                    a[x, y] = 1;
                }
            }
        }

        if (maxX - minX != maxY - minY)
        {
            Console.WriteLine("NO");
            return;
        }

        int square1 = (maxX - minX) * (maxY - minY);
        int square2 = 0;

        for (int i = 0; i < n; i++)
        {
            square2 += (squares[i, 2] - squares[i, 0]) * (squares[i, 3] - squares[i, 1]);
        }

        if (square1 != square2)
        {
            // Console.WriteLine("NO 2 1: {0} 2: {1}", square1, square2);
            Console.WriteLine("NO");
            return;
        }

        Console.WriteLine("YES");
    }
}


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

namespace codeforces
{
    class rect
    {
        public Tuple<int, int> leftbottom;
        public Tuple<int, int> righttop;
        public rect(int x1, int y1, int x2, int y2)
        {
            leftbottom = new Tuple<int, int>(x1, y1);
            righttop = new Tuple<int, int>(x2, y2);
        }
    }
    public class A
    {
        static void main()
        {

            int n;

            n = int.Parse(System.Console.ReadLine());
            List<rect> rtlist = new List<rect>();
            SortedSet<int> xs = new SortedSet<int>();
            SortedSet<int> ys = new SortedSet<int>();
            for (int i = 0; i < n; i++)
            {
                string line= System.Console.ReadLine();
                string[] ints = line.Split(new char[1]{','});
                int[] x = new int[4];
                for (int j = 0; j < 4; j++)
                    x[j] = int.Parse(ints[j]);
                rect rt = new rect(x[0], x[1], x[2], x[3]);
                xs.Add(x[0]);
                xs.Add(x[2]);
                ys.Add(x[1]);
                ys.Add(x[3]);
                rtlist.Add(rt);

            }
            if ((xs.Max - xs.Min) != (ys.Max - ys.Min))
            {
                System.Console.WriteLine("NO");
                return;
            }
            Dictionary<Tuple<int,int>,int> dic = new Dictionary<Tuple<int,int>,int>();

            for (int i = 0; i < n; i++)
            {
                rect rt = rtlist[i];
                var valuex = xs.GetViewBetween(rt.leftbottom.Item1, rt.righttop.Item1);
                var valuey = xs.GetViewBetween(rt.leftbottom.Item2, rt.righttop.Item2);
                foreach(int x in valuex)
                {
                    foreach (int y in valuex)
                    {
                        Tuple<int, int> tu = new Tuple<int, int>(x, y);
                        int v = 4;
                        if ((x == rt.leftbottom.Item1) || (x == rt.righttop.Item1))
                            v /= 2;
                        if ((y== rt.leftbottom.Item2) || (y == rt.righttop.Item2))
                            v /= 2;
                        if (dic.ContainsKey(tu))
                            dic[tu] += v;
                        else
                            dic[tu] = v;

                    }
                }
            }
            foreach(var x in dic)
            {
                var k = x.Key;
                var v = x.Value;
                if ((k.Item1 == xs.Max) || (k.Item1 == xs.Min))
                    v *= 2;
                if ((k.Item2 == ys.Max) || (k.Item2 == ys.Min))
                    v *= 2;
                if (v != 4)
                {
                    System.Console.WriteLine("NO");
                    return;
                }
            }
            System.Console.WriteLine("YES");
            return;

        }
    }
}


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

namespace ConsoleApp5
{
    class Program
    {
        static Stack<bool> GetBinaryNumber(long number)
        {
            Stack<bool> result = new Stack<bool>();
            while (number != 0)
            {
                result.Push(number % 2 == 1);
                number /= 2;
            }
            return result;
        }
        static long FastDegree(long number, long pow)
        {
            long result = 1;
            Stack<bool> StackPow = GetBinaryNumber(pow);
            while (StackPow.Count != 0)
            {
                result *= result;
                result %= (int)(1e9 + 7);
                if (StackPow.Pop())
                {
                    result *= number;
                    result %= (int)(1e9 + 7);
                }
            }
            return result;
        }
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            long n = long.Parse(str[0]);
            long k = long.Parse(str[1]);
            for (long i = 1; i <= n && ((i + 1) * i) / 2 <= k + n - i; i++)
            {
                if (((i + 1) * i) / 2 == k + n - i)
                {
                    Console.WriteLine(n - i);
                    break;
                }
            }
        }
    }
}


using System;
class Program
    {
        static void Main(string[] args)
        {
            double tn, k, m;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                k = int.Parse(input[1]);
                tn = 2D*(k + int.Parse(input[0]));
            }
            if (((m = Math.Floor(Math.Sqrt(tn)) - 1D) * m + m * 3D) > tn) --m;
            Console.WriteLine((m * m + m) / 2D - k);
        }
    }


// Problem: 1195B - Sport Mafia
// Author: Gusztav Szmolik

using System;

class SportMafia
    {
    static int Main ()
        {
        string[] words = ReadSplitLine (2);
        if (words == null)
            return -1;
        uint n;
        if (!UInt32.TryParse (words[0], out n))
            return -1;
        if (n < 1 || n > 1000000000)
            return -1;
        uint k;
        if (!UInt32.TryParse (words[1], out k))
            return -1;
        if (k > 1000000000)
            return -1;
        uint numCandy = 0;
        uint nPut = 0;
        while (numCandy < k)
            {
            nPut++;
            numCandy += nPut;
            }
        bool solved = false;
        uint nEat = numCandy-k;
        uint nSum = nPut+nEat;
        while (nSum <= n && !solved)
            {
            if (nSum == n)
                solved = true;
            else
                {
                nPut++;
                numCandy += nPut;
                nEat = numCandy-k;
                nSum = nPut+nEat;
                }
            }
        if (!solved)
            return -1;
        Console.WriteLine (nEat);
        return 0;
        }

    static string[] ReadSplitLine (uint numWordNeed)
        {
        string line = Console.ReadLine ();
        if (line == null)
            return null;
        char[] delims = new char[2] {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        return (words.Length == numWordNeed ? words : null);
        }
    }


using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();

        // 最初飴を1つ入れる

        // 飴を1つ食べる
        // 前回入れる操作した個数+1入れる

        // n回操作してk個飴入ってる 食べた個数

        // 食べた x回

        for (long y = 0; y <= n; y++)
        {
            long x = n - y;
            long t = (y + 1) * y / 2 - x;
            if (t == k)
            {
                Console.WriteLine(x);
                return;
            }
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

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.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces574
{
    class Program2
    {
        static void Main()
        {
            //l=入れた回数
            // s = n - l
            // l = n - s
            //(n-s)*(1+n-s)/2 - s - k = 0
            var input = Console.ReadLine().Split(' ').Select(long.Parse);
            var n = input.First();
            var k = input.Skip(1).First();

            var A = -2 * n - 2 * k;
            var l = (int)(-3 + Math.Sqrt(9 - 4 * A)) / 2;
            var ans = n - l;
            Console.WriteLine(ans);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] array = new long[2];
            string str = Console.ReadLine();
            string s = "";
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == ' ')
                {
                    array[0] = Convert.ToInt64(s);
                    s = "";
                }
                else
                {
                    s += str[i];
                }
            }
            array[1] = Convert.ToInt64(s);

            long l = 1;
            long r = array[0];
            long mid = 0;
            while (l < r)
            {
                mid = (l + r) / 2;
                if ((1 + mid) * mid / 2 - (array[0] - mid) < array[1])
                {
                    l = mid + 1;
                }

                if ((1 + mid) * mid / 2 - (array[0] - mid) > array[1])
                {
                    r = mid - 1;
                }
                if ((1 + mid) * mid / 2 - (array[0] - mid) == array[1])
                {
                    break;
                }

            }
            if (l == r)
            {
                mid = l;

            }
            Console.WriteLine(array[0] - mid);

      // Console.Read();

        }
    }

}


using System;

public class Program
{
	public static void Main()
	{
	    var s = Console.ReadLine().Split(' ');
		int n = Int32.Parse(s[0]);
		int k = Int32.Parse(s[1]);
		int allCandy = 0;
		for(int i = 1; i <= n; i++)
		{
			allCandy += i;
		}
		int lostCandy = allCandy - k;
		int j = 0;
		while(lostCandy != 0)
		{
			lostCandy -= n +1;
			n--;
			j++;
		}

		Console.WriteLine(j);
	}
}


/*
csc -debug B.cs && mono --debug B.exe <<< "1 1"
*/

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

public class HelloWorld {
    public static void SolveCodeForces() {
        var n = cin.NextLong();
        var k = cin.NextLong();

        var put = n + k;

        for (var a = 0L; a <= n; a++) {
            if (a * (a + 3L) / 2L == put) {
                System.Console.WriteLine(n - a);
                break;
            }
        }
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr) {
        return string.Join(" ", arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


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

using static System.Console;

public class Test
{
    static long Sum(int n)
    {
        return (2 + (long)n - 1) * (long)n / 2;
    }

    static long Res(int i, int n)
    {
        return Sum(i) - n + i;
    }

    static int Mid(int left, int right)
    {
        return (int)Math.Floor((double)(left + right) / (double)2);
    }

    public static void Main()
	{
        var line1 = ReadLine().Split();
        int n = int.Parse(line1[0]);
        int k = int.Parse(line1[1]);

        int left = 1;
        int right = n;
        int mid = Mid(left, right);
        while(Res(mid, n) != k)
        {
            if(Res(mid, n) > k)
            {
                right = mid;
            }
            else
            {
                left = mid;
            }
            if(mid == Mid(left, right))
                break;
            mid = Mid(left, right);
        }

        WriteLine(Sum(mid) - k);
	}
}


using System;

namespace _1195B_SportMafia
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();

            int moves = Convert.ToInt32(input[0]);
            int candiesLeft = Convert.ToInt32(input[1]);

            int candies = 0;

            int c = 1;

            int eatenCandies = 0;

            for(int i = 0; i < moves; i++)
            {
                if(candiesLeft > candies)
                {
                    candies += c;
                    c++;
                }
                else
                {
                    eatenCandies++;
                    candies -= 1;
                }
            }

            Console.WriteLine(eatenCandies);

        }
    }
}


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

namespace Task_02
{
    class Program
    {
        static void Main(string[] args)
        {
            var ints = Console.ReadLine().Split(null).Select(long.Parse).ToArray();
            var n = ints[0];
            var k = ints[1];

            long a = 1,
                b = -(2 * n + 3),
                c = -2*k + n * n + n;

            var d = b * b - 4 * a * c;
            var i = (-b - Math.Sqrt(d)) / 2 * a;
            if (i < 0)
                i = (-b + Math.Sqrt(d)) / 2 * a;
            Console.WriteLine(i);
        }
    }
}


using System;
using System.Linq;

namespace CF_574
{
    public class Program
    {
        private static void Main(string[] args)
        {
            var ar = Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
            var n = ar[0];
            var k = ar[1];

            var put = Bs(1, n, k, n);
            Console.WriteLine(n - put);
        }

        private static long Bs(long lo, long hi, long k, long n)
        {
            var mid = (lo + hi) / 2L;
            var rem = ((mid * (mid + 1)) / 2) - (n - mid);
            if (rem == k)
                return mid;
            if (rem > k)
                return Bs(lo, mid, k, n);
            return Bs(mid, hi, k, n);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            int n = int.Parse(s[0]);

            int k = int.Parse(s[1]);

            int l = Convert.ToInt32((-1 / 2.0 * Math.Sqrt(8.0 * k + 8.0 * n + 9.0) + n + 3.0 / 2));

            Console.Write(l);

            //Console.ReadKey();
        }
    }
}


//#define EXTENDSTACKSIZE

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

         namespace CF
{
    internal class Program
    {
        private const int stackSize = 64 * 1024 * 1024;

        private static void Run()
        {
            using (var sr = new InputReader(Console.In))
//            using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
//            using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }

        private static void Main(string[] args)
        {
#if EXTENDSTACKSIZE
            var threadStart = new ThreadStart(Run);
            var thread = new Thread(threadStart, stackSize);
            thread.Start();
            thread.Join();
#else
            Run();
#endif
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt64();
            var k = sr.NextInt64();
            var start = 1L;
            var end = n;
            while (start <= end)
            {
                var mid = (start + end) / 2L;
                var r = mid * mid + 3L*mid - 2L * n - 2L * k;
                if (r == 0)
                {
                    sw.WriteLine(n - mid);
                    return;
                }

                if (r < 0)
                {
                    start = mid + 1;
                }
                else
                {
                    end = mid - 1;
                }
            }

            throw new InvalidOperationException();
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Numerics;
using System.Threading;

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
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    string GetStr() { return Console.ReadLine().Trim(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    char GetChar() { return Console.ReadLine().Trim()[0]; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    string[][] GetStrArray(int N)
    {
        var res = new string[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    char[][] GetGrid(int H)
    {
        var res = new char[H][];
        for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T[] CreateArray<T>(int N, T value)
    {
        var res = new T[N];
        for (int i = 0; i < N; i++) res[i] = value;
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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;
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T>(out T a) => a = cv<T>(GetStr());
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T, U>(out T a, out U b)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    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]);
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Output<T>(T t) => Console.WriteLine(t);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Output<T>(IList<T> ls) => Console.WriteLine(string.Join(" ", ls));
    void Debug<T>(IList<IList<T>> ls)
    {
        foreach (var l in ls)
        {
            Console.Error.WriteLine(string.Join(" ", l));
        }
        Console.Error.WriteLine();
    }

    public static void Yes() => Console.WriteLine("Yes");
    public static void YES() => Console.WriteLine("YES");
    public static void No() => Console.WriteLine("No");
    public static void NO() => Console.WriteLine("NO");
    public static void M1() => Console.WriteLine("-1");

    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 });
        var program = new Program();
        //var t = new Thread(program.Solve, 134217728);
        //t.Start();
        //t.Join();
        program.Solve();
        //Console.Out.Flush();
        Console.Read();
    }

    public void Solve()
    {
        long n, k;
        Multi(out n, out k);
        for(long i=0; ; i++)
        {
            if (i * i + 3 * i == 2 * n + 2 * k)
            {
                Output(n - i);
                return;
            }
        }
    }

}


using System;
using System.Linq;

namespace Codeforces
{
    public class ProblemB574
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long n = nk[0];
            long k = nk[1];
            // a add
            // e eat
            // a + e = n
            // a(a+1)/2 - e = k
            var delta = (long)(9 + 8 * (n + k));
            var sqdelta = (long)(Math.Sqrt(delta));
            while (sqdelta * sqdelta < delta)
                sqdelta++;

            var a1 = (-3 + sqdelta) / 2;
            var e = n - a1;
            Console.WriteLine(e);
        }
    }
}


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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt64);
            long n = nk[0], k = nk[1];
            int t = (int)Math.Sqrt(8 * n + 8 * k + 9);
            Console.WriteLine((2 * n + 3 - t) / 2 >= 0 ? (2 * n + 3 - t) / 2 : (2 * n + 3 + t) / 2);

        }
    }
}


using System;

class _1195B
{
	static void Main()
	{
		long[] nk = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		long n = nk[0];
		long k = nk[1];
		Console.WriteLine(n - ((-3 + (long)Math.Sqrt(9 + 8 * (k + n))) >> 1));
	}
}


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

namespace Codeforces
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse);
            var n = input.First();
            var k = input.Last();

            var A = -2 * n - 2 * k;
            var l = (int)(-3 + Math.Sqrt(9 - 4 * A)) / 2;
            var ans = n - l;
            Console.WriteLine(ans);
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using static System.Math;
using System.Text;
using System.Threading;

namespace Program
{
    public static class CODEFORCES1
    {
        static public void Solve()
        {
            var n = NN;
            var k = NN;
            var ok = 0L;
            var ng = n;
            while (ng - ok > 1)
            {
                var mid = (ng + ok) / 2;
                var eat = mid;
                var canNum = n - eat;
                var canSum = (1 + canNum) * canNum / 2;
                if (canSum - eat >= k)
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            Console.WriteLine(ok);

        }

        static public void Main(string[] args) { if (args.Length == 0) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static Random rand = new Random();
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => rand.Next());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void RevSort<T>(T[] l) where T : IComparable { Array.Sort(l, (x, y) => y.CompareTo(x)); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void RevSort<T>(T[] l, Comparison<T> comp) where T : IComparable { Array.Sort(l, (x, y) => comp(y, x)); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static IEnumerable<long> Primes(long x) { if (x < 2) yield break; yield return 2; var halfx = x / 2; var table = new bool[halfx + 1]; var max = (long)(Math.Sqrt(x) / 2); for (long i = 1; i <= max; ++i) { if (table[i]) continue; var add = 2 * i + 1; yield return add; for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true; } for (long i = max + 1; i <= halfx; ++i) if (!table[i] && 2 * i + 1 <= x) yield return 2 * i + 1; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static IEnumerable<long> Factors(long x) { if (x < 2) yield break; while (x % 2 == 0) { x /= 2; yield return 2; } var max = (long)Math.Sqrt(x); for (long i = 3; i <= max; i += 2) while (x % i == 0) { x /= i; yield return i; } if (x != 1) yield return x; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static IEnumerable<long> Divisor(long x) { if (x < 1) yield break; var max = (long)Math.Sqrt(x); for (long i = 1; i <= max; ++i) { if (x % i != 0) continue; yield return i; if (i != x / i) yield return x / i; } }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static long GCD(long a, long b) { while (b > 0) { var tmp = b; b = a % b; a = tmp; } return a; }
        static long LCM(long a, long b) => a * b / GCD(a, b);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static Mat<T> Pow<T>(Mat<T> x, long y) => Mat<T>.Pow(x, y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static T Pow<T>(T x, long y) { T a = (dynamic)1; while (y != 0) { if ((y & 1) == 1) a *= (dynamic)x; x *= (dynamic)x; y >>= 1; } return a; }
        static List<long> _fact = new List<long>() { 1 };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void _B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static long Comb(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static long Perm(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static Func<TR> Lambda<TR>(Func<Func<TR>, TR> f) { Func<TR> t = () => default(TR); return t = () => f(t); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static Func<T1, TR> Lambda<T1, TR>(Func<T1, Func<T1, TR>, TR> f) { Func<T1, TR> t = x1 => default(TR); return t = x1 => f(x1, t); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static Func<T1, T2, TR> Lambda<T1, T2, TR>(Func<T1, T2, Func<T1, T2, TR>, TR> f) { Func<T1, T2, TR> t = (x1, x2) => default(TR); return t = (x1, x2) => f(x1, x2, t); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static Func<T1, T2, T3, TR> Lambda<T1, T2, T3, TR>(Func<T1, T2, T3, Func<T1, T2, T3, TR>, TR> f) { Func<T1, T2, T3, TR> t = (x1, x2, x3) => default(TR); return t = (x1, x2, x3) => f(x1, x2, x3, t); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static Func<T1, T2, T3, T4, TR> Lambda<T1, T2, T3, T4, TR>(Func<T1, T2, T3, T4, Func<T1, T2, T3, T4, TR>, TR> f) { Func<T1, T2, T3, T4, TR> t = (x1, x2, x3, x4) => default(TR); return t = (x1, x2, x3, x4) => f(x1, x2, x3, x4, t); }
        class PQ<T> where T : IComparable
        {
            List<T> h; Comparison<T> c; public T Peek => h[0]; public int Count => h.Count;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(int cap, Comparison<T> c, bool asc = true) { h = new List<T>(cap); this.c = asc ? c : (x, y) => c(y, x); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(Comparison<T> c, bool asc = true) { h = new List<T>(); this.c = asc ? c : (x, y) => c(y, x); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public void Push(T v) { var i = h.Count; h.Add(v); while (i > 0) { var ni = (i - 1) / 2; if (c(v, h[ni]) >= 0) break; h[i] = h[ni]; i = ni; } h[i] = v; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public T Pop() { var r = h[0]; var v = h[h.Count - 1]; h.RemoveAt(h.Count - 1); if (h.Count == 0) return r; var i = 0; while (i * 2 + 1 < h.Count) { var i1 = i * 2 + 1; var i2 = i * 2 + 2; if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2; if (c(v, h[i1]) <= 0) break; h[i] = h[i1]; i = i1; } h[i] = v; return r; }
        }
        class PQ<TK, TV> where TK : IComparable
        {
            PQ<Tuple<TK, TV>> q; public Tuple<TK, TV> Peek => q.Peek; public int Count => q.Count;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(int cap, Comparison<TK> c, bool asc = true) { q = new PQ<Tuple<TK, TV>>(cap, (x, y) => c(x.Item1, y.Item1), asc); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(Comparison<TK> c, bool asc = true) { q = new PQ<Tuple<TK, TV>>((x, y) => c(x.Item1, y.Item1), asc); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public void Push(TK k, TV v) => q.Push(Tuple.Create(k, v));
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tuple<TK, TV> Pop() => q.Pop();
        }
        public class UF
        {
            long[] d;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public UF(long s) { d = Repeat(-1L, s).ToArray(); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public bool Unite(long x, long y) { x = Root(x); y = Root(y); if (x != y) { if (d[y] < d[x]) { var t = y; y = x; x = t; } d[x] += d[y]; d[y] = x; } return x != y; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public bool IsSame(long x, long y) => Root(x) == Root(y);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public long Root(long x) => d[x] < 0 ? x : d[x] = Root(d[x]);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public long Count(long x) => -d[Root(d[x])];
        }
        struct Mod : IEquatable<object>
        {
            static public long _mod = 1000000007; long _val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Mod(long x) { if (x < _mod && x >= 0) _val = x; else if ((_val = x % _mod) < 0) _val += _mod; }
            static public implicit operator Mod(long x) => new Mod(x);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public implicit operator long(Mod x) => x._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mod operator +(Mod x, Mod y) => x._val + y._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mod operator -(Mod x, Mod y) => x._val - y._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mod operator *(Mod x, Mod y) => x._val * y._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mod operator /(Mod x, Mod y) => x._val * Inverse(y._val);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public bool operator ==(Mod x, Mod y) => x._val == y._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public bool operator !=(Mod x, Mod y) => x._val != y._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public long Inverse(long x) { long b = _mod, r = 1, u = 0, t = 0; while (b > 0) { var q = x / b; t = u; u = r - q * u; r = t; t = b; b = x - q * b; x = t; } return r < 0 ? r + _mod : r; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            bool IEquatable<object>.Equals(object obj) => obj == null ? false : Equals((Mod)obj);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public override bool Equals(object obj) => obj == null ? false : Equals((Mod)obj);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public bool Equals(Mod obj) => obj == null ? false : _val == obj._val;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public override int GetHashCode() => _val.GetHashCode();
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public override string ToString() => _val.ToString();
            static List<Mod> _fact = new List<Mod>() { 1 };
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static void B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mod Comb(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mod Perm(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }
        }
        struct Mat<T>
        {
            T[,] m;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Mat(T[,] v) { m = (T[,])v.Clone(); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public implicit operator Mat<T>(T[,] v) => new Mat<T>(v);
            public T this[int r, int c] { get { return m[r, c]; } set { m[r, c] = value; } }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> operator +(Mat<T> a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] += (dynamic)x; return tm; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> operator +(Mat<T> a, Mat<T> b) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] += (dynamic)b[r, c]; return tm; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> operator -(Mat<T> a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] -= (dynamic)x; return tm; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> operator -(Mat<T> a, Mat<T> b) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] -= (dynamic)b[r, c]; return tm; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> operator *(Mat<T> a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] *= (dynamic)x; return tm; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> operator *(Mat<T> a, Mat<T> b) { var nr = a.m.GetLength(0); var nc = b.m.GetLength(1); var tm = new T[nr, nc]; for (int i = 0; i < nr; ++i) for (int j = 0; j < nc; ++j) tm[i, j] = (dynamic)0; for (int r = 0; r < nr; ++r) for (int c = 0; c < nc; ++c) for (int i = 0; i < a.m.GetLength(1); ++i) tm[r, c] += a[r, i] * (dynamic)b[i, c]; return tm; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Mat<T> Pow(Mat<T> x, long y) { var n = x.m.GetLength(0); var t = (Mat<T>)new T[n, n]; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) t[i, j] = (dynamic)(i == j ? 1 : 0); while (y != 0) { if ((y & 1) == 1) t *= x; x *= x; y >>= 1; } return t; }
        }
        class Tree
        {
            long N; int l; List<long>[] p; int[] d; long[][] pr; long r; Tuple<long, long, int>[] e; Tuple<long, long>[] b; bool lca; bool euler; bool bfs;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tree(List<long>[] p_, long r_) { N = p_.Length; p = p_; r = r_; lca = false; euler = false; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tuple<long, long>[] FromRoot() { if (!bfs) { var nb = new List<Tuple<long, long>>(); var q = new Queue<long>(); var d = new bool[N]; nb.Add(Tuple.Create(r, -1L)); d[r] = true; q.Enqueue(r); while (q.Count > 0) { var w = q.Dequeue(); foreach (var i in p[w]) { if (d[i]) continue; d[i] = true; q.Enqueue(i); nb.Add(Tuple.Create(i, w)); } } b = nb.ToArray(); bfs = true; } return b; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tuple<long, long>[] FromLeaf() => FromRoot().Reverse().ToArray();
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tuple<long, long, int>[] Euler() { if (!euler) { var ne = new List<Tuple<long, long, int>>(); var s = new Stack<Tuple<long, long>>(); var d = new bool[N]; d[r] = true; s.Push(Tuple.Create(r, -1L)); while (s.Count > 0) { var w = s.Peek(); var ad = true; foreach (var i in p[w.Item1]) { if (d[i]) continue; d[i] = true; ad = false; s.Push(Tuple.Create(i, w.Item1)); } if (!ad || p[w.Item1].Count == 1) ne.Add(Tuple.Create(w.Item1, w.Item2, 1)); if (ad) { s.Pop(); ne.Add(Tuple.Create(w.Item1, w.Item2, -1)); } } e = ne.ToArray(); euler = true; } return e; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public long LCA(long u, long v) { if (!lca) { l = 0; while (N > (1 << l)) l++; d = new int[N]; pr = Repeat(0, l).Select(_ => new long[N]).ToArray(); d[r] = 0; pr[0][r] = -1; var q = new Stack<long>(); q.Push(r); while (q.Count > 0) { var w = q.Pop(); foreach (var i in p[w]) { if (i == pr[0][w]) continue; q.Push(i); d[i] = d[w] + 1; pr[0][i] = w; } } for (var k = 0; k + 1 < l; k++) for (var w = 0; w < N; w++) if (pr[k][w] < 0) pr[k + 1][w] = -1; else pr[k + 1][w] = pr[k][pr[k][w]]; lca = true; } if (d[u] > d[v]) { var t = u; u = v; v = t; } for (var k = 0; k < l; k++) if ((((d[v] - d[u]) >> k) & 1) != 0) v = pr[k][v]; if (u == v) return u; for (var k = l - 1; k >= 0; k--) if (pr[k][u] != pr[k][v]) { u = pr[k][u]; v = pr[k][v]; } return pr[0][u]; }
        }
        class BT<T> where T : IComparable
        {
            class Node { public Node l; public Node r; public T v; public bool b; }
            Comparison<T> c; Node r; bool ch; T lm;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public BT(Comparison<T> _c) { c = _c; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public BT() : this((x, y) => x.CompareTo(y)) { }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            bool R(Node n) => n != null && !n.b;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            bool B(Node n) => n != null && n.b;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node RtL(Node n) { Node m = n.r, t = m.l; m.l = n; n.r = t; return m; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node RtR(Node n) { Node m = n.l, t = m.r; m.r = n; n.l = t; return m; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node RtLR(Node n) { n.l = RtL(n.l); return RtR(n); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node RtRL(Node n) { n.r = RtR(n.r); return RtL(n); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public void Add(T x) { r = A(r, x); r.b = true; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node A(Node n, T x) { if (n == null) { ch = true; return new Node() { v = x }; } if (c(x, n.v) < 0) n.l = A(n.l, x); else n.r = A(n.r, x); return Bl(n); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node Bl(Node n) { if (!ch) return n; if (!B(n)) return n; if (R(n.l) && R(n.l.l)) { n = RtR(n); n.l.b = true; } else if (R(n.l) && R(n.l.r)) { n = RtLR(n); n.l.b = true; } else if (R(n.r) && R(n.r.l)) { n = RtRL(n); n.r.b = true; } else if (R(n.r) && R(n.r.r)) { n = RtL(n); n.r.b = true; } else ch = false; return n; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public void Remove(T x) { r = Rm(r, x); if (r != null) r.b = true; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node Rm(Node n, T x) { if (n == null) { ch = false; return n; } var r = c(x, n.v); if (r < 0) { n.l = Rm(n.l, x); return BlL(n); } if (r > 0) { n.r = Rm(n.r, x); return BlR(n); } if (n.l == null) { ch = n.b; return n.r; } n.l = RmM(n.l); n.v = lm; return BlL(n); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node RmM(Node n) { if (n.r != null) { n.r = RmM(n.r); return BlR(n); } lm = n.v; ch = n.b; return n.l; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node BlL(Node n) { if (!ch) return n; if (B(n.r) && R(n.r.l)) { var b = n.b; n = RtRL(n); n.b = b; n.l.b = true; ch = false; } else if (B(n.r) && R(n.r.r)) { var b = n.b; n = RtL(n); n.b = b; n.r.b = true; n.l.b = true; ch = false; } else if (B(n.r)) { ch = n.b; n.b = true; n.r.b = false; } else { n = RtL(n); n.b = true; n.l.b = false; n.l = BlL(n.l); ch = false; } return n; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Node BlR(Node n) { if (!ch) return n; if (B(n.l) && R(n.l.r)) { var b = n.b; n = RtLR(n); n.b = b; n.r.b = true; ch = false; } else if (B(n.l) && R(n.l.l)) { var b = n.b; n = RtR(n); n.b = b; n.l.b = true; n.r.b = true; ch = false; } else if (B(n.l)) { ch = n.b; n.b = true; n.l.b = false; } else { n = RtR(n); n.b = true; n.r.b = false; n.r = BlR(n.r); ch = false; } return n; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public bool Have(T x) { var t = FindUpper(x); return t.Item1 && t.Item2.CompareTo(x) == 0; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tuple<bool, T> FindUpper(T x) { var v = FU(r, x); return v == null ? Tuple.Create(false, default(T)) : v; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Tuple<bool, T> FU(Node n, T x) { if (n == null) return null; var r = c(x, n.v); if (r < 0) { var v = FU(n.l, x); return v == null ? Tuple.Create(true, n.v) : v; } if (r > 0) return FU(n.r, x); return Tuple.Create(true, n.v); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public Tuple<bool, T> FindLower(T x) { var v = FL(r, x); return v == null ? Tuple.Create(false, default(T)) : v; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            Tuple<bool, T> FL(Node n, T x) { if (n == null) return null; var r = c(x, n.v); if (r < 0) return FL(n.l, x); if (r > 0) { var v = FL(n.r, x); return v == null ? Tuple.Create(true, n.v) : v; } return Tuple.Create(true, n.v); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public T Min() { Node n = r, p = null; while (n != null) { p = n; n = n.l; } return p == null ? default(T) : p.v; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public T Max() { Node n = r, p = null; while (n != null) { p = n; n = n.r; } return p == null ? default(T) : p.v; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public bool Any() => r != null;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public int CountSlow() => L(r).Count();
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public IEnumerable<T> List() => L(r);
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            IEnumerable<T> L(Node n) { if (n == null) yield break; foreach (var i in L(n.l)) yield return i; yield return n.v; foreach (var i in L(n.r)) yield return i; }
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long K = long.Parse(str[1]);
		long min = 0;
		long max = N;
		while(min<max){
			long n = (min+max)/2;
			long N1 = N-n;
			long a = (1+N1)*N1/2;
			a -= n;
			a -= K;
			if(a>0){
				min = n+1;
			} else if(a<0){
				max = n-1;
			} else {
				min = n;
				break;
			}
		}
		Console.WriteLine(min);
	}
}


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

namespace Sport_Mafia
{
    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(args));
            writer.Flush();
        }

        private static long Solve(string[] args)
        {
            long n = Next();
            long k = Next();

            return n - (-3 + (long) Math.Sqrt(9 + 8*(n + k)))/2;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


/* Date: 19.07.2019  *  Time: 21:45 */
//
// https://docs.microsoft.com/en-us/dotnet/api/system.tuple-8?redirectedfrom=MSDN&view=netframework-4.7.2
//
// ������������ ����� �� ����� 11

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

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

class Example
{
	public const int K = 256;
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\040\\B.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\040\\OUTPUT.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

			string s;
# if ( ONLINE_JUDGE )
			s = Console.ReadLine ();
# else
			s = sr.ReadLine ();
			sw.WriteLine ("*** " + s);
# endif

			Int64 n, k;
			{
				string [] ss = s.Split (' ');
				n = Int64.Parse (ss [0]);
				k = Int64.Parse (ss [1]);
			}

			Int64 m = 0;
			for ( Int64 i=1; i <= n; i++ )
			{
# if ( ! ONLINE_JUDGE )
//				sw.WriteLine ("***--- " + i + " " + i*(i+1)/2);
# endif

				if ( i + i*(i+1)/2 - k == n )
				{
					m = i*(i+1)/2 - k;
					break;
				}
			}

# if ( ONLINE_JUDGE )
			Console.WriteLine (m);
# else
			sw.WriteLine (m);
# endif

# if ( ! ONLINE_JUDGE )
		sw.Close ();
# endif

	}
}