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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split();
            BigInteger a, b;
            BigInteger.TryParse(ab[0], out a);
            BigInteger.TryParse(ab[1], out b);
            BigInteger sum = (b - 1) * b / 2 * (a + b * a / 2 + b * a * a / 2) % 1000000007;
            Console.WriteLine(sum.ToString());
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
using BitVector = System.Collections.Specialized.BitVector32;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var a = sc.Long();
            var b = sc.Long();
            var sum = 0L;
            const long mod = (long)1e9 + 7;

            for (int m = 1; m < b; m++)
            {
                var n = a * m;
                var k = n % mod;
                var sn = (k * (m + b)) % mod;
                sn += (((k * (k-1)/2) % mod) * b) % mod;
                sum = (sum + sn) % mod;
            }
            IO.Printer.Out.PrintLine(sum);
            /*
            var primes = Sieve((int)1e6);
            var n = sc.Integer();
            var k = sc.Integer();
            var used = new bool[(int)1e6];
            for (int _ = 1; _ <= n; _++)
            {

            }*/
        }
        static public long ModPow(long x, long n, long mod)
        {
            long r = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                    r = r * x % mod;
                x = x * x % mod;
                n >>= 1;
            }
            return r;
        }

        static public int[] Sieve(int p)
        {
            var isPrime = new bool[p + 1];
            var l = new List<int>();
            for (int i = 2; i <= p; i++)
                isPrime[i] = true;
            for (int i = 2; i * i <= p; i++)
            {
                if (!isPrime[i])
                    continue;
                l.Add(i);
                for (int j = i * i; j <= p; j += i)
                    isPrime[j] = false;
            }
            return l.ToArray();
        }
        internal IO.Scanner sc;

    }
    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            System.Diagnostics.Debug.AutoFlush = false;
            var sw = new Watch();
            sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.Scanner(Console.In);
                IO.Printer.Out = new IO.Printer(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                System.Diagnostics.Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer
    {
        static Printer()
        {
            Out = new Printer(Console.Out);
        }
        public static Printer Out { get; set; }
        private readonly System.IO.TextWriter writer;
        private readonly System.Globalization.CultureInfo info;
        public string Separator { get; set; }
        public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? "\n"; } }
        public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)
        {
            writer = tw ?? System.IO.TextWriter.Null;
            info = ci ?? System.Globalization.CultureInfo.InvariantCulture;
            NewLine = newLine;
            Separator = separator ?? " ";
        }
        public void Print(int num) { writer.Write(num.ToString(info)); }
        public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(long num) { writer.Write(num.ToString(info)); }
        public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(double num) { writer.Write(num.ToString(info)); }
        public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(string str) { writer.Write(str); }
        public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }
        public void Print<T>(string format, IEnumerable<T> sources) { writer.Write(format, sources.OfType<object>().ToArray()); }
        public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
        public void Print<T>(IEnumerable<T> sources)
        {
            var res = new System.Text.StringBuilder();
            foreach (var x in sources)
            {
                res.AppendFormat(info, "{0}", x);
                if (string.IsNullOrEmpty(Separator))
                    res.Append(Separator);
            }
            writer.Write(res.ToString(0, res.Length - Separator.Length));
        }
        public void PrintLine() { writer.WriteLine(); }
        public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(string str) { writer.WriteLine(str); }
        public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }
        public void PrintLine<T>(string format, IEnumerable<T> sources) { writer.WriteLine(format, sources.OfType<object>().ToArray()); }
        public void PrintLine<T>(IEnumerable<T> sources)
        {
            var res = new StringBuilder();
            foreach (var x in sources)
            {
                res.AppendFormat(info, "{0}", x);
                if (!string.IsNullOrEmpty(Separator))
                    res.Append(Separator);
            }
            writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
        }
        public void Flush() { writer.Flush(); }
    }
    public class Scanner
    {
        readonly private System.Globalization.CultureInfo info;
        readonly System.IO.TextReader reader;
        string[] buffer = new string[0];
        int position;

        public char[] Separator { get; set; }
        public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
        {

            this.reader = reader ?? Console.In;
            if (string.IsNullOrEmpty(separator))
                separator = " ";
            this.Separator = separator.ToCharArray();
            this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;
        }
        public string Scan()
        {
            if (this.position < this.buffer.Length)
                return this.buffer[this.position++];
            do this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
            while (this.buffer.Length == 0);
            this.position = 0;
            return this.buffer[this.position++];
        }

        public string ScanLine()
        {
            if (this.position >= this.buffer.Length)
                return this.reader.ReadLine();
            else
            {
                var sb = new System.Text.StringBuilder();
                for (; this.position < buffer.Length; this.position++)
                {
                    sb.Append(this.buffer[this.position]);
                    sb.Append(' ');
                }
                return sb.ToString();
            }
        }
        public string[] ScanArray(int length)
        {
            var ar = new string[length];
            for (int i = 0; i < length; i++)
                ar[i] = this.Scan();
            return ar;
        }

        public int Integer()
        {
            return int.Parse(this.Scan(), info);
        }
        public long Long()
        {
            return long.Parse(this.Scan(), info);
        }
        public double Double()
        {
            return double.Parse(this.Scan(), info);
        }
        public double Double(string str)
        {
            return double.Parse(str, info);
        }

        public int[] IntArray(int length)
        {
            var a = new int[length];
            for (int i = 0; i < length; i++)
                a[i] = this.Integer();
            return a;
        }
        public long[] LongArray(int length)
        {
            var a = new long[length];
            for (int i = 0; i < length; i++)
                a[i] = this.Long();
            return a;
        }
        public double[] DoubleArray(int length)
        {
            var a = new double[length];
            for (int i = 0; i < length; i++)
                a[i] = this.Double();
            return a;
        }

    }

}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> source)
        {
            return new string(source.ToArray());
        }
        static public string AsJoinedString<T>(this IEnumerable<T> source, string separator = " ")
        {
            return string.Join(separator, source);
        }
        static public T[] Enumerate<T>(this int n, Func<int, T> selector)
        {
            var res = new T[n];
            for (int i = 0; i < n; i++)
                res[i] = selector(i);
            return res;
        }
    }
}
#endregion


using System;
using System.IO;

namespace CF272
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            const long module = 1000000007L;
            string[] input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            long sum = 0L;
            for (long i = 1; i <= a; i++)
            {
                sum += ((i*b + 1)*(b*(b - 1)/2));
                sum = sum%module;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    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)
        {
            const long mod = 1000000007;
            long a = Next();
            long b = Next();

            long sum = 0;
            for (long i = 1; i < b; i++)
            {
                long count = a/i;
                if (count == 0)
                    break;
                long b0 = i*b + i;
                sum += (2*b0 + b*(count - 1))*count/2;
                sum = sum%mod;
            }

            writer.WriteLine(sum%mod);
            writer.Flush();
        }

        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';
            }
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    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)
        {
            const long mod = 1000000007;
            long a = Next();
            long b = Next();

            long sum = 0;
            for (long i = 1; i < b; i++)
            {
                long count = a;
                long b0 = (i*b + i)%mod;
                sum += (count*b0)%mod + (((count - 1)*count/2*i)%mod*b)%mod;
                sum = sum%mod;
            }

            writer.WriteLine(sum%mod);
            writer.Flush();
        }

        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';
            }
        }
    }
}


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

namespace prC {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            long a = Next();
            long b = Next();
            long ans = 0;
            const long m = 1000000007;
            long b1 = b - 1;
            long d = b1 * (b1 + 1) / 2;
            d = d % m;
            for(int k = 1; k <= a; k++) {
                long y = k * b + 1;
                long s = y * d;
                ans = (ans + s) % m;
            }
            writer.WriteLine(ans);

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static long Next() {
            long c;
            long res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.IO;

namespace CF272
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            string[] input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            long sum = 0L;
            for (long i = 1; i <= a; i++)
            {
                sum += ((i*b + 1)*(b*(b - 1)/2))%10000000007;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    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)
        {
            const long mod = 1000000007;
            long a = Next();
            long b = Next();

            long sum = 0;
            for (long i = 1; i < b; i++)
            {
                long count = a/i;
                if (count == 0)
                    break;
                long b0 = i*b + i;
                sum += (count*b0)%mod + ((count - 1)*count/2*b)%mod;
                sum = sum%mod;
            }

            writer.WriteLine(sum%mod);
            writer.Flush();
        }

        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';
            }
        }
    }
}


using System;
using System.IO;

namespace CF272
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            const long module = 10000000007L;
            string[] input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            long sum = 0L;
            for (long i = 1; i <= a; i++)
            {
                sum += (((i*b)%module + 1)*(((b*(b - 1))%module)/2))%module;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    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)
        {
            const long mod = 1000000007;
            long a = Next();
            long b = Next();

            long sum = 0;
            for (long i = 1; i < b; i++)
            {
                long count = a;
                if (count == 0)
                    break;
                long b0 = i*b + i;
                sum += (count*b0)%mod + ((count - 1)*count/2*b)%mod;
                sum = sum%mod;
            }

            writer.WriteLine(sum%mod);
            writer.Flush();
        }

        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';
            }
        }
    }
}


using System;
using System.IO;

namespace CF272
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            const long module = 1000000007L;
            string[] input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            long a = Int64.Parse(input[0]);
            long b = Int64.Parse(input[1]);
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            long sum = 0L;
            for (long i = 1; i <= a; i++)
            {
                sum += ((i*b + 1)*(b*(b - 1)/2))%module;
            }
            Console.WriteLine(sum);
        }
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long mod=(long)(1e9+7);
		if(B==1){
			Console.WriteLine(0);
			return;
		}

		long xx=(B-1)*B;
		xx/=2;
		xx%=mod;

		long yy=A*(A+1);
		yy/=2;
		yy*=B;
		yy%=mod;
		yy+=A;

		long Ans=xx*yy;
		Ans%=mod;
		Console.WriteLine(Ans);

	}
	long A;
	long B;
	public Sol(){
		var d=rla();
		A=d[0];B=d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}


using System;
using System.IO;

namespace CF272
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            const long module = 1000000007L;
            string[] input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            long sum = 0L;
            for (long i = 1; i <= a; i++)
            {
                sum += (((i*b)%module + 1)*((b*(b - 1))%module/2))%module;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    class Program
    {
        static void Main(string[] args)
        {
            //int c = Console.Read();
           // Console.Write(c);
            long a = My_get_int();
            long b = My_get_int();
            long sum = 0, i, j;
            for (i = 1; i < b; i++)
                for (j = 1; j <= a / i; j++)
                {
                    sum += j * i * b + i;
                }
            Console.Write(sum);
        }
        static int My_get_int()
        {
            int i = 0;
            char c;
            c =(char) Console.Read();
            while((int)c!=32&&(int)c!=13)
            {
                i = i * 10 + c - 48;
                c = (char)Console.Read();
            }
            return i;
        }
    }

}


using System;
using System.IO;

namespace CF272
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            const long module = 10000000007L;
            string[] input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            long sum = 0L;
            for (long i = 1; i <= a; i++)
            {
                sum += ((i*b + 1)*(b*(b - 1)/2));
                sum = sum%module;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    class Program
    {
        static void Main(string[] args)
        {
            //int c = Console.Read();
           // Console.Write(c);
            long a = My_get_int();
            long b = My_get_int();
            long sum = 0, i, j;
            for (i = 1; i < b; i++)
                for (j = 1; j <= a; j++)
                {
                    sum += j * i * b + i;
                    while(sum>1000000007)
                    {
                        sum -= 1000000007;
                    }
                }
            Console.Write(sum);
        }
        static int My_get_int()
        {
            int i = 0;
            char c;
            c =(char) Console.Read();
            while((int)c!=32&&(int)c!=13)
            {
                i = i * 10 + c - 48;
                c = (char)Console.Read();
            }
            return i;
        }
    }

}


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

namespace Dreamoon_and_Sums
{
    class Program
    {
        static void Main(string[] args)
        {
            //int c = Console.Read();
           // Console.Write(c);
            long a = My_get_int();
            long b = My_get_int();
            long sum = 0, i, j;
            for (i = 1; i < b; i++)
                for (j = 1; j <= a; j++)
                {
                    sum += (j * i * b + i)%1000000007;
                    sum %= 1000000007;

                }
            Console.Write(sum);
        }
        static int My_get_int()
        {
            int i = 0;
            char c;
            c =(char) Console.Read();
            while((int)c!=32&&(int)c!=13)
            {
                i = i * 10 + c - 48;
                c = (char)Console.Read();
            }
            return i;
        }
    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;

namespace cf
{
    public class Cf
    {
        private static void Println(int n)
        {
            Console.WriteLine(n);
        }

        private static void Println(String s)
        {
            Console.WriteLine(s);
        }

        private static void Print(int n)
        {
            Console.Write(n);
        }

        private static void Print(String s)
        {
            Console.Write(s);
        }

        public static void Main(String[] args)
        {
            C();
        }

        private static void C()
        {
            var scanner = new MyScanner();
            ulong a = scanner.NextInt();
            ulong b = scanner.NextInt();
            long m = 1000000007;
            ulong ans = 0;
            for (ulong i = 1; i < b; i++)
            {
                ans += (a*i + (((a*(a + 1)/2)%m)*b)%m*i)%m;
                ans %= m;
            }
            Print(ans.ToString());
        }

        private static void A()
        {
            var scanner = new MyScanner();
            var n = scanner.NextInt();
            var m = scanner.NextInt();
            var x2 = n / 2;
            var x1 = n % 2;
            var d = (m - ((x1 + x2) % m)) % m;
            x2 -= d;
            x1 += 2 * d;
            if (x2 < 0)
            {
                Print(-1);
            }
            else
            {
                Print(x1 + x2);
            }
        }

        private static void B()
        {
            var f = new int[11];
            f[0] = 1;
            for (int i = 1; i < 11; i++)
                f[i] = f[i - 1]*i;
            var scanner = new MyScanner();
            var s1 = scanner.NextString();
            var s2 = scanner.NextString();
            var p1 = s1.Count(c => c == '+') - s1.Count(c => c == '-');
            var p2 = s2.Count(c => c == '+') - s2.Count(c => c == '-');
            var d = Math.Abs(p1 - p2);
            var q = s2.Count(c => c == '?');
            if (d > q)
            {
                Print(0);
                return;
            }
            var x = q - d;
            if (x%2 == 1)
            {
                Print(0);
                return;
            }
            x /= 2;
            double pp = ((double)f[q])/(f[x]*f[q - x]);
            Print((pp/Math.Pow(2,q)).ToString().Replace(',','.'));
        }
    }

    class Pair
    {
        public int X;
        public int Y;

        Pair(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
    class MyScanner
    {
        private String[] _buffer;
        private int _pos = 0;

        public int NextInt()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return int.Parse(_buffer[_pos - 1]);
        }

        public String NextString()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return _buffer[_pos - 1];
        }

        public List<int> GetIntList(int n)
        {
            var result = new List<int>(n);
            for (int i = 0; i < n; i++)
                result.Add(NextInt());
            return result;
        }

        public int[] GetIntArray(int n)
        {
            var result = new int[n];
            for (int i = 0; i < n; i++)
                result[i] = (NextInt());
            return result;
        }

    }
}


#include <studio.h>
int main()
{
    long a,b,sum;
    int i,j;
    scanf("%ld%ld",&a,&b);
    for(i=1;i<b;i++)
        for(j=1;j<a/i;j++)
        {
            sum+=b*i*j+i;
        }
    printf("%d",sum);
    return 0;
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dreamoon and Sums", "Dreamoon and Sums\Dreamoon and Sums.csproj", "{1C760D49-94B1-469A-B31E-01FA81BF8BB4}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{1C760D49-94B1-469A-B31E-01FA81BF8BB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{1C760D49-94B1-469A-B31E-01FA81BF8BB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{1C760D49-94B1-469A-B31E-01FA81BF8BB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{1C760D49-94B1-469A-B31E-01FA81BF8BB4}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;

namespace cf
{
    public class Cf
    {
        private static void Println(int n)
        {
            Console.WriteLine(n);
        }

        private static void Println(String s)
        {
            Console.WriteLine(s);
        }

        private static void Print(int n)
        {
            Console.Write(n);
        }

        private static void Print(String s)
        {
            Console.Write(s);
        }

        public static void Main(String[] args)
        {
            C();
        }

        private static void C()
        {
            var scanner = new MyScanner();
            var a = scanner.NextInt();
            var b = scanner.NextInt();
            ulong m = 1000000007;
            ulong ans = 0;
            for (int i = 1; i < b; i++)
            {
                ans += (a*i + (((a*(a + 1)/2)%m)*b)%m*i)%m;
                ans %= m;
            }
            Print(ans.ToString());
        }

        private static void A()
        {
            var scanner = new MyScanner();
            var n = scanner.NextInt();
            var m = scanner.NextInt();
            var x2 = n / 2;
            var x1 = n % 2;
            var d = (m - ((x1 + x2) % m)) % m;
            x2 -= d;
            x1 += 2 * d;
            if (x2 < 0)
            {
                Print(-1);
            }
            else
            {
                Print(x1 + x2);
            }
        }

        private static void B()
        {
            var f = new int[11];
            f[0] = 1;
            for (int i = 1; i < 11; i++)
                f[i] = f[i - 1]*i;
            var scanner = new MyScanner();
            var s1 = scanner.NextString();
            var s2 = scanner.NextString();
            var p1 = s1.Count(c => c == '+') - s1.Count(c => c == '-');
            var p2 = s2.Count(c => c == '+') - s2.Count(c => c == '-');
            var d = Math.Abs(p1 - p2);
            var q = s2.Count(c => c == '?');
            if (d > q)
            {
                Print(0);
                return;
            }
            var x = q - d;
            if (x%2 == 1)
            {
                Print(0);
                return;
            }
            x /= 2;
            double pp = ((double)f[q])/(f[x]*f[q - x]);
            Print((pp/Math.Pow(2,q)).ToString().Replace(',','.'));
        }
    }

    class Pair
    {
        public int X;
        public int Y;

        Pair(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
    class MyScanner
    {
        private String[] _buffer;
        private int _pos = 0;

        public int NextInt()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return int.Parse(_buffer[_pos - 1]);
        }

        public String NextString()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return _buffer[_pos - 1];
        }

        public List<int> GetIntList(int n)
        {
            var result = new List<int>(n);
            for (int i = 0; i < n; i++)
                result.Add(NextInt());
            return result;
        }

        public int[] GetIntArray(int n)
        {
            var result = new int[n];
            for (int i = 0; i < n; i++)
                result[i] = (NextInt());
            return result;
        }

    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;

namespace cf
{
    public class Cf
    {
        private static void Println(int n)
        {
            Console.WriteLine(n);
        }

        private static void Println(String s)
        {
            Console.WriteLine(s);
        }

        private static void Print(int n)
        {
            Console.Write(n);
        }

        private static void Print(String s)
        {
            Console.Write(s);
        }

        public static void Main(String[] args)
        {
            C();
        }

        private static void C()
        {
            var scanner = new MyScanner();
            ulong a = (ulong)scanner.NextInt();
            ulong b = (ulong)scanner.NextInt();
            long m = 1000000007;
            ulong ans = 0;
            for (ulong i = 1; i < b; i++)
            {
                ans += (a*i + (((a*(a + 1)/2)%m)*b)%m*i)%m;
                ans %= m;
            }
            Print(ans.ToString());
        }

        private static void A()
        {
            var scanner = new MyScanner();
            var n = scanner.NextInt();
            var m = scanner.NextInt();
            var x2 = n / 2;
            var x1 = n % 2;
            var d = (m - ((x1 + x2) % m)) % m;
            x2 -= d;
            x1 += 2 * d;
            if (x2 < 0)
            {
                Print(-1);
            }
            else
            {
                Print(x1 + x2);
            }
        }

        private static void B()
        {
            var f = new int[11];
            f[0] = 1;
            for (int i = 1; i < 11; i++)
                f[i] = f[i - 1]*i;
            var scanner = new MyScanner();
            var s1 = scanner.NextString();
            var s2 = scanner.NextString();
            var p1 = s1.Count(c => c == '+') - s1.Count(c => c == '-');
            var p2 = s2.Count(c => c == '+') - s2.Count(c => c == '-');
            var d = Math.Abs(p1 - p2);
            var q = s2.Count(c => c == '?');
            if (d > q)
            {
                Print(0);
                return;
            }
            var x = q - d;
            if (x%2 == 1)
            {
                Print(0);
                return;
            }
            x /= 2;
            double pp = ((double)f[q])/(f[x]*f[q - x]);
            Print((pp/Math.Pow(2,q)).ToString().Replace(',','.'));
        }
    }

    class Pair
    {
        public int X;
        public int Y;

        Pair(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
    class MyScanner
    {
        private String[] _buffer;
        private int _pos = 0;

        public int NextInt()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return int.Parse(_buffer[_pos - 1]);
        }

        public String NextString()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return _buffer[_pos - 1];
        }

        public List<int> GetIntList(int n)
        {
            var result = new List<int>(n);
            for (int i = 0; i < n; i++)
                result.Add(NextInt());
            return result;
        }

        public int[] GetIntArray(int n)
        {
            var result = new int[n];
            for (int i = 0; i < n; i++)
                result[i] = (NextInt());
            return result;
        }

    }
}


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

namespace Dreamoon_and_Sums
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = Int64.Parse(Console.ReadLine());
            long b = Int64.Parse(Console.ReadLine());
            long sum = 0,i,j;
            for(i=1;i<b;i++)
                for(j=1;j<=a/i;j++)
                {
                    sum+=j*i*b+i;
                }
            Console.Write(sum);
        }
    }
}


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

namespace Dreamoon_and_Sums
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = Int32.Parse(Console.ReadLine());
            int b = Int32.Parse(Console.ReadLine());
            int sum = 0,i,j;
            for(i=1;i<b;i++)
                for(j=1;j<=a/i;j++)
                {
                    sum+=j*i*b+i;
                }
            Console.Write(sum);
        }
    }
}


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

namespace ReadTemplate
{
    public class Solver
    {
        public static void Solve()
        {
            long a = ReadLong();
            long b = ReadLong();

            int k = 2;
            long mod = 1000000007;
            long[] d = { a, b, b - 1, (2 + b * (a + 1)) % mod };
            int i = 0;
            while (k > 0)
            {
                while (k > 0 && d[i] % 2 == 0)
                {
                    d[i] /= 2;
                    k--;
                }
                i++;
            }

            long ans = 1;
            foreach (var l in d)
            {
                ans = (ans * l) % mod;
            }
            Writer.Write(ans);
        }

        public static void Main()
        {
            Reader = Console.In; Writer = Console.Out;
            //Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");

            Solve();

            Reader.Close();
            Writer.Close();
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}


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

namespace CFTraining.D_s
{
    class Polyline340
    {
        public static void Main(string[] args)
        {
            List<Point> p = new List<Point>();
            for (int i = 0; i < 3; i++) {
                string[] line = Console.ReadLine().Split(' ');
                p.Add(new Point{ x = Convert.ToInt32(line[0]), y = Convert.ToInt32(line[1])});
            }

            if (p[0].x == p[1].x && p[1].x == p[2].x
                || p[0].y == p[1].y && p[1].y == p[2].y) Console.WriteLine(1);
            else
            {
                int s1 = p[0].LieInSameLine(p[1]), s2 = p[0].LieInSameLine(p[2]), s3 = p[1].LieInSameLine(p[2]);
                if (s1 > 0 && (s3 > 0 || s2 > 0)) Console.WriteLine(2);
                else if (s2 > 0 && (s1 > 0 || s3 > 0)) Console.WriteLine(2);
                else if (s3 > 0 && (s1 > 0 || s2 > 0)) Console.WriteLine(2);
                else Console.WriteLine(3);
            }
        }
    }

    class Point
    {
        public int x, y;
        public int LieInSameLine(Point p)
        {
            if (x == p.x) return 1;
            else if (y == p.y) return 2;
            else return 0;
        }
    }
}


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

namespace CFTraining.D_s
{
    class Polyline340
    {
        public static void Main(string[] args)
        {
            List<Point> p = new List<Point>();
            for (int i = 0; i < 3; i++) {
                string[] line = Console.ReadLine().Split(' ');
                p.Add(new Point{ x = Convert.ToInt32(line[0]), y = Convert.ToInt32(line[1])});
            }

            if (p[0].x == p[1].x && p[1].x == p[2].x
                || p[0].y == p[1].y && p[1].y == p[2].y) Console.WriteLine(1);
            else
            {
                int s1 = p[0].LieInSameLine(p[1]), s2 = p[0].LieInSameLine(p[2]), s3 = p[1].LieInSameLine(p[2]);
                if (s1 > 0 || s2 > 0 || s3 > 0) Console.WriteLine(2);
                else Console.WriteLine(3);
            }
        }
    }

    class Point
    {
        public int x, y;
        public int LieInSameLine(Point p)
        {
            if (x == p.x) return 1;
            else if (y == p.y) return 2;
            else return 0;
        }
    }
}


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

namespace CFTraining.D_s
{
    class Polyline340
    {
        public static void Main(string[] args)
        {
            List<Point> p = new List<Point>();
            for (int i = 0; i < 3; i++) {
                string[] line = Console.ReadLine().Split(' ');
                p.Add(new Point{ x = Convert.ToInt32(line[0]), y = Convert.ToInt32(line[1])});
            }

            if (p[0].x == p[1].x && p[1].x == p[2].x
                || p[0].y == p[1].y && p[1].y == p[2].y) Console.WriteLine(1);
            else
            {
                int s1 = p[0].LieInSameLine(p[1]), s2 = p[0].LieInSameLine(p[2]), s3 = p[1].LieInSameLine(p[2]);
                if (s1 > 0)
                {
                    if (s1 == 1)
                    {
                        int min = Math.Min(p[0].x, p[1].x);
                        int max = Math.Max(p[0].x, p[1].x);
                        if (p[2].x < min || p[2].x > max)
                        {
                            Console.WriteLine(3);
                            return;
                        }
                    }
                    if (s1 == 2)
                    {
                        int min = Math.Min(p[0].y, p[1].y);
                        int max = Math.Max(p[0].y, p[1].y);
                        if (p[2].y < min || p[2].y > max)
                        {
                            Console.WriteLine(3);
                            return;
                        }
                    }
                }

                else if (s2 > 0)
                {
                    if (s2 == 1)
                    {
                        int min = Math.Min(p[0].x, p[2].x);
                        int max = Math.Max(p[0].x, p[2].x);
                        if (p[1].x < min || p[1].x > max)
                        {
                            Console.WriteLine(3);
                            return;
                        }
                    }
                    if (s2 == 2)
                    {
                        int min = Math.Min(p[0].y, p[2].y);
                        int max = Math.Max(p[0].y, p[2].y);
                        if (p[1].y < min || p[1].y > max)
                        {
                            Console.WriteLine(3);
                            return;
                        }
                    }
                }
                else if (s3 > 0)
                {
                    if (s3 == 1)
                    {
                        int min = Math.Min(p[1].x, p[2].x);
                        int max = Math.Max(p[1].x, p[2].x);
                        if (p[0].x < min || p[0].x > max)
                        {
                            Console.WriteLine(3);
                            return;
                        }
                    }
                    if (s3 == 2)
                    {
                        int min = Math.Min(p[1].y, p[2].y);
                        int max = Math.Max(p[1].y, p[2].y);
                        if (p[0].y < min || p[0].y > max)
                        {
                            Console.WriteLine(3);
                            return;
                        }
                    }
                }
                else if (s1 > 0 || s2 > 0 || s3 > 0) Console.WriteLine(2);
                else Console.WriteLine(3);
            }
        }
    }

    class Point
    {
        public int x, y;
        public int LieInSameLine(Point p)
        {
            if (x == p.x) return 1;
            else if (y == p.y) return 2;
            else return 0;
        }
    }
}


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

namespace CompetitiveProgramming
{
    class Program
    {
        static bool s_IsMultipleTestCases = false;
        static void Main(string[] args)
        {
            InputReader input = new InputReader();
            TextWriter output = Console.Out;
            var numberOfTest = 1;
            if (s_IsMultipleTestCases)
            {
                numberOfTest = input.NextInt();
            }
            for (var testNumber = 1; testNumber <= numberOfTest; ++testNumber)
            {
                Task solver = new Task();
                solver.Solve(testNumber, input, output);
            }

#if DEBUG
            Console.ReadKey();
#endif
        }
    }

    class Task
    {
        public void Solve(int testNumber, InputReader ip, TextWriter op)
        {
            int n = 3;
            var x = new int[n];
            var y = new int[n];
            for (var i = 0; i < n; ++i)
            {
                x[i] = ip.NextInt();
                y[i] = ip.NextInt();
            }
            if (IsCaseOne(x, y))
            {
                op.WriteLine(1);
            }
            else if (IsCaseTwo(x, y))
            {
                op.WriteLine(2);
            }
            else
            {
                op.WriteLine(3);
            }
        }

        private bool IsCaseOne(int[] x, int[] y)
        {
            return (x[0] == x[1] && x[1] == x[2]) || (y[0] == y[1] && y[1] == y[2]);
        }

        private bool IsCaseTwo(int[] x, int[] y)
        {
            bool isValid = false;
            isValid |= x[0] == x[1] && (x[2] >= Max(x[0],x[1]) || x[2] <= Min(x[0], x[1]));
            isValid |= x[1] == x[2] && (x[0] >= Max(x[1], x[2]) || x[0] <= Min(x[1], x[2]));
            isValid |= x[2] == x[0] && (x[1] >= Max(x[2], x[0]) || x[1] <= Min(x[2], x[0]));
            isValid |= y[0] == y[1] && (y[2] >= Max(y[0], y[1]) || y[2] <= Min(y[0], y[1]));
            isValid |= y[1] == y[2] && (y[0] >= Max(y[1], y[2]) || y[0] <= Min(y[1], y[2]));
            isValid |= y[2] == y[0] && (y[1] >= Max(y[2], y[0]) || y[1] <= Min(y[2], y[0]));
            return isValid;
        }

        private int Max(int v1, int v2)
        {
            return Math.Max(v1, v2);
        }

        private int Min(int v1, int v2)
        {
            return Math.Min(v1,v2);
        }
    }

    class InputReader
    {
        static int s_index = 0;
        static string[] s_tokens;
        public string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Length)
            {
                s_tokens = Console.ReadLine().Split(' ').ToArray();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        public string NextLine()
        {
            return Console.ReadLine();
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }

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


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

namespace D.Polyline
{
    class Program
    {
        static void Main(string[] args)
        {
            long[][] p = new long[3][];
            for (var i = 0; i < 3; ++i)
                p[i] = new long[2];
            for(var i = 0; i < 3; ++i) {
                var nm = Console.ReadLine().Split();
                p[i][0] = long.Parse(nm[0]);
                p[i][1] = long.Parse(nm[1]);
            }
            Console.WriteLine(function(p));
        }
        static long function(long [][] p)
        {
            long []x = p[0];
            long []y = p[1];
            long []z = p[2];
            long _x = x[0];
            long _y = y[0];

            if (x[0] == y[0] && y[0] == z[0])
                return 1;

            if (x[1] == y[1] && y[1] == z[1])
                return 1;

            int mn = dist(x, y, z);
            mn = Math.Min(mn, dist(x, z, y));
            if (mn == 4)
                return 3;

            if (belong(x, y, z) || belong(z, x, y) || belong(x, z, y))
                return 2;
            return 3;

        }
        static int dist(long[] x, long[] y, long[] z)
        {
            int sm = (x[0] - y[0] != 0) ? 1 : 0;
            sm += (x[1] - y[1] != 0) ? 1 : 0;
            sm += (z[0] - y[0] != 0) ? 1 : 0;
            sm += (z[1] - y[1] != 0) ? 1 : 0;
            return sm;
        }
        static bool belong(long[] p1, long[] p2, long[] p3)
        {

            return ( Math.Min(p1[0], p3[0]) <= p2[0] && p2[0] <= Math.Max(p1[0], p3[0] )) || (Math.Min(p1[1], p3[1]) <= p2[1] && p2[1] <= Math.Max(p1[1], p3[1]));
        }
    }
}


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

class Program
{
    public class Point
    {
        public int X;
        public int Y;
    }

    public static Point ReadPoint()
    {
        var p = new Point();
        p.X = ReadInt();
        p.Y = ReadInt();

        return p;
    }

    private static int Count(Point a, Point b, Point c)
    {
        if (a.X == b.X && a.X == c.X) return 1;
        if (a.Y == b.Y && a.Y == c.Y) return 1;

        if (a.X == b.X) return 2;
        if (a.Y == b.Y) return 2;

        return 3;
    }

    static void Main(string[] args)
    {
        var a = ReadPoint();
        var b = ReadPoint();
        var c = ReadPoint();

        int[] ans = new int[6];
        ans[0] = Count(a, b, c);
        ans[1] = Count(a, c, b);
        ans[2] = Count(b, a, c);
        ans[3] = Count(b, c, a);
        ans[4] = Count(c, a, b);
        ans[5] = Count(c, b, a);

        Console.WriteLine(ans.Min());
    }

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

        return g;
    }

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

        return matrix;
    }

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

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

    private const int BufferSize = 1 << 16;
    private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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


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

namespace D.Polyline
{
    class Program
    {
        static void Main(string[] args)
        {
            int[][] p = new int[3][];
            for (var i = 0; i < 3; ++i)
                p[i] = new int[2];
            for(var i = 0; i < 3; ++i) {
                var nm = Console.ReadLine().Split();
                p[i][0] = int.Parse(nm[0]);
                p[i][1] = int.Parse(nm[1]);
            }
            Console.WriteLine(function(p));
        }
        static long function(int [][] p)
        {
            long x = p[0][0];
            long y = p[0][1];
            long z, w;
            for (var i = 1; i < 3; ++i) {
                x &= p[i][0];
                y &= p[i][1];
            }
            if (x == p[0][0] || y == p[0][1])
                return 1;
            long min = 100;
            for (var i = 0; i < 3; ++i)
                for (var j = 0; j < 3; ++j)
                    for (var l = 0; l < 3; ++l) {
                        if (i == j || j == l || i == l)
                            continue;
                        min = Math.Min(dist(p[i], p[j]) + dist(p[j], p[l]), min);
                    }
            return ( min == 4 ) ? 3 : min;
        }
        static int dist(int []p1, int[] p2)
        {
            if (p1[0] == p2[0])
                return 1;
            if (p1[1] == p2[1])
                return 1;
            return 2;
        }
    }
}


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

namespace CFTraining.D_s
{
    class Polyline340
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }

        public static int Solve()
        {
            List<Point> p = new List<Point>();
            for (int i = 0; i < 3; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                p.Add(new Point { x = Convert.ToInt32(line[0]), y = Convert.ToInt32(line[1]) });
            }

            if (p[0].LieInSameLine(p[1]) != 0 && p[0].LieInSameLine(p[1]) == p[0].LieInSameLine(p[2])) return 1;
            int s1 = p[0].LieInSameLine(p[1]), s2 = p[0].LieInSameLine(p[2]), s3 = p[1].LieInSameLine(p[2]);
            if (s1 > 0)
            {
                if (s1 == 1)
                {
                    int min = Math.Min(p[0].y, p[1].y);
                    int max = Math.Max(p[0].y, p[1].y);
                    if (p[2].y < min || p[2].y > max)
                    {
                        return 2;
                    }
                }
                if (s1 == 2)
                {
                    int min = Math.Min(p[0].x, p[1].x);
                    int max = Math.Max(p[0].x, p[1].x);
                    if (p[2].x < min || p[2].x > max)
                    {
                        return 2;
                    }
                }
            }
            else if (s2 > 0)
            {
                if (s2 == 1)
                {
                    int min = Math.Min(p[0].y, p[2].y);
                    int max = Math.Max(p[0].y, p[2].y);
                    if (p[1].y < min || p[1].y > max)
                    {
                        return 2;
                    }
                }
                if (s2 == 2)
                {
                    int min = Math.Min(p[0].x, p[2].x);
                    int max = Math.Max(p[0].x, p[2].x);
                    if (p[1].x < min || p[1].x > max)
                    {
                        return 2;
                    }
                }
            }
            else if (s3 > 0)
            {
                if (s3 == 1)
                {
                    int min = Math.Min(p[1].y, p[2].y);
                    int max = Math.Max(p[1].y, p[2].y);
                    if (p[0].y < min || p[0].y > max)
                    {
                        return 2;
                    }
                }
                if (s3 == 2)
                {
                    int min = Math.Min(p[1].x, p[2].x);
                    int max = Math.Max(p[1].x, p[2].x);
                    if (p[0].x < min || p[0].x > max)
                    {
                        return 2;
                    }
                }
            }
            return 3;
        }
    }

    class Point
    {
        public int x, y;
        public int LieInSameLine(Point p)
        {
            if (x == p.x) return 1;
            else if (y == p.y) return 2;
            else return 0;
        }
    }
}


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

namespace CFTraining.D_s
{
    class Polyline340
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }

        public static int Solve()
        {
            List<Point> p = new List<Point>();
            for (int i = 0; i < 3; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                p.Add(new Point { x = Convert.ToInt32(line[0]), y = Convert.ToInt32(line[1]) });
            }

            if (p[0].LieInSameLine(p[1]) != 0 && p[0].LieInSameLine(p[1]) == p[0].LieInSameLine(p[2])) return 1;
            int s1 = p[0].LieInSameLine(p[1]), s2 = p[0].LieInSameLine(p[2]), s3 = p[1].LieInSameLine(p[2]);
            if (s1 > 0)
            {
                if (s1 == 1)
                {
                    int min = Math.Min(p[0].x, p[1].x);
                    int max = Math.Max(p[0].x, p[1].x);
                    if (p[2].x < min || p[2].x > max)
                    {
                        return 2;
                    }
                }
                if (s1 == 2)
                {
                    int min = Math.Min(p[0].y, p[1].y);
                    int max = Math.Max(p[0].y, p[1].y);
                    if (p[2].y < min || p[2].y > max)
                    {
                        return 2;
                    }
                }
            }
            else if (s2 > 0)
            {
                if (s2 == 1)
                {
                    int min = Math.Min(p[0].x, p[2].x);
                    int max = Math.Max(p[0].x, p[2].x);
                    if (p[1].x < min || p[1].x > max)
                    {
                        return 2;
                    }
                }
                if (s2 == 2)
                {
                    int min = Math.Min(p[0].y, p[2].y);
                    int max = Math.Max(p[0].y, p[2].y);
                    if (p[1].y < min || p[1].y > max)
                    {
                        return 2;
                    }
                }
            }
            else if (s3 > 0)
            {
                if (s3 == 1)
                {
                    int min = Math.Min(p[1].x, p[2].x);
                    int max = Math.Max(p[1].x, p[2].x);
                    if (p[0].x < min || p[0].x > max)
                    {
                        return 2;
                    }
                }
                if (s3 == 2)
                {
                    int min = Math.Min(p[1].y, p[2].y);
                    int max = Math.Max(p[1].y, p[2].y);
                    if (p[0].y < min || p[0].y > max)
                    {
                        return 2;
                    }
                }
            }
            return 3;
        }
    }

    class Point
    {
        public int x, y;
        public int LieInSameLine(Point p)
        {
            if (x == p.x) return 1;
            else if (y == p.y) return 2;
            else return 0;
        }
    }
}


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

namespace D.Polyline
{
    class Program
    {
        static void Main(string[] args)
        {
            long[][] p = new long[3][];
            for (var i = 0; i < 3; ++i)
                p[i] = new long[2];
            for(var i = 0; i < 3; ++i) {
                var nm = Console.ReadLine().Split();
                p[i][0] = long.Parse(nm[0]);
                p[i][1] = long.Parse(nm[1]);
            }
            Console.WriteLine(function(p));
        }
        static long function(long [][] p)
        {
            long []x = p[0];
            long []y = p[1];
            long []z = p[2];
            long _x = x[0];
            long _y = y[0];
            for (var i = 1; i < 3; ++i) {
                _x &= p[i][0];
                _y &= p[i][1];
            }
            if (_x == p[0][0] || _y == p[0][1])
                return 1;

            if (belong(x, y, z) || belong(z, x, y) || belong(x, z, y))
                return 2;
            return 3;

        }

        static bool belong(long[] p1, long[] p2, long[] p3)
        {
            if (p1[0] == p2[0] || p1[1] == p2[1])
                return true;
            if (p3[0] == p2[0] || p3[1] == p2[1])
                return true;
            return false;
        }
    }
}


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

namespace D.Polyline
{
    class Program
    {
        static void Main(string[] args)
        {
            int[][] p = new int[3][];
            for (var i = 0; i < 3; ++i)
                p[i] = new int[2];
            for(var i = 0; i < 3; ++i) {
                var nm = Console.ReadLine().Split();
                p[i][0] = int.Parse(nm[0]);
                p[i][1] = int.Parse(nm[1]);
            }
            Console.WriteLine(function(p));
        }
        static int function(int [][] p)
        {
            int x = p[0][0];
            int y = p[0][1];
            int z, w;
            for (var i = 1; i < 3; ++i) {
                x &= p[i][0];
                y &= p[i][1];
            }
            if (x == p[0][0] || y == p[0][1])
                return 1;
            int min = 100;
            for (var i = 0; i < 3; ++i)
                for (var j = 0; j < 3; ++j)
                    for (var l = 0; l < 3; ++l) {
                        if (i == j || j == l || i == l)
                            continue;
                        x = ( p[i][0] - p[j][0] != 0 ) ? 1 : 0;
                        y = ( p[i][1] - p[j][1] != 0 ) ? 1 : 0;
                        z = ( p[j][0] - p[l][0] != 0 ) ? 1 : 0;
                        w = ( p[j][1] - p[l][1] != 0 ) ? 1 : 0;
                        int s = x + y + z + w;
                        if (s == 4)
                            --s;
                        min = Math.Min(s, min);
                    }
            return min;
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    bool NextPerm(int[] a)
    {
        int n = a.Length;
        for (int k = n - 2; k >= 0; k--)
            if (a[k] < a[k + 1])
                for (int l = n - 1; l >= 0; l--)
                    if (a[k] < a[l])
                    {
                        Swap(ref a[k], ref a[l]);
                        for (int i = k + 1, j = n - 1; i < j; i++, j--)
                            Swap(ref a[i], ref a[j]);
                        return true;
                    }
        return false;
    }

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

    class Point
    {
        public int x, y;
    }

    int Fun(Point p1, Point p2, Point p3)
    {
        if (p1.x == p2.x && p1.x == p3.x || p1.y == p2.y && p1.y == p3.y)
            return 1;

        if (p1.x == p2.x && (p3.y <= Math.Min(p1.y, p2.y) || p3.y >= Math.Max(p1.y, p2.y)) || p1.y == p2.y && (p3.x <= Math.Min(p1.x, p2.x) || p3.x >= Math.Max(p1.x, p2.x)))
            return 2;
        return 3;
    }

    public void Solve()
    {
        var a = new Point[3];
        for (int i = 0; i < 3; i++)
            a[i] = new Point { x = ReadInt(), y = ReadInt() };

        var p = Enumerable.Range(0, 3).ToArray();
        int ans = 3;
        do
        {
            ans = Math.Min(ans, Fun(a[p[0]], a[p[1]], a[p[2]]));
        } while (NextPerm(p));

        Write(ans);
    }

    #region Main

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

    #endregion

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


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

namespace Polyline
{
    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)
        {
            var x = new int[3];
            var y = new int[3];
            for (int i = 0; i < 3; i++)
            {
                x[i] = Next();
                y[i] = Next();
            }

            if ((x[0] == x[1] && x[0] == x[2]) || (y[0] == y[1] && y[0] == y[2]))
                writer.WriteLine("1");
            else if ((x[0] == x[1] && -1 != Math.Sign(y[0] - y[2])*Math.Sign(y[1] - y[2]))
                     || (x[0] == x[2] && -1 != Math.Sign(y[0] - y[1])*Math.Sign(y[2] - y[1]))
                     || (x[2] == x[1] && -1 != Math.Sign(y[2] - y[0])*Math.Sign(y[1] - y[0]))
                     || (y[0] == y[1] && -1 != Math.Sign(x[0] - x[2])*Math.Sign(x[1] - x[2]))
                     || (y[0] == y[2] && -1 != Math.Sign(x[0] - x[1])*Math.Sign(x[2] - x[1]))
                     || (y[2] == y[1] && -1 != Math.Sign(x[2] - x[0])*Math.Sign(x[1] - x[0]))
                )

            {
                writer.WriteLine("2");
            }
            else
                writer.WriteLine("3");

            writer.Flush();
        }

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


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

namespace Beresta
{

	class ContestIO : StreamWriter
	{
		public ContestIO(Stream streamIn, Stream streamOut) : base(streamOut, Encoding.ASCII, 8192) { Reader = new StreamReader(streamIn, Encoding.ASCII, false, 8192); }
		public ContestIO(string inputFilePath, string outputFilePath) : this(File.OpenRead(inputFilePath), File.OpenWrite(outputFilePath)) { }
		public ContestIO() : this(Console.OpenStandardInput(8192), Console.OpenStandardOutput(8192)) { }
		//d.ToString("N12", CultureInfo.InvariantCulture).Replace(",", "")
		public StreamReader Reader;

		bool IsDigit(int c) { return c >= '0' && c <= '9'; }
		public long Read()
		{
			int c1 = 0, c;
			while (!IsDigit(c = Reader.Read())) { c1 = c; }
			long r = c - '0';
			while (IsDigit(c = Reader.Read()))
				r = r * 10 + c - '0';
			return c1 == '-' ? -r : r;
		}
		public long[] ReadArray(int size) { return Enumerable.Range(0, size).Select(v => Read()).ToArray(); }
	}

	class Program
	{

		static void Main(string[] args)
		{
			using (var io = new ContestIO())
			{
				var x1 = io.Read();
				var y1 = io.Read();
				var x2 = io.Read();
				var y2 = io.Read();
				var x3 = io.Read();
				var y3 = io.Read();

				if ((x1 == x2 && x1 == x3) || (y1 == y2 && y1 == y3))
					io.WriteLine("1");
				else
				{
					if (x1 == x2)
						io.WriteLine(Solve(y1, y2, y3));
					else if (x1 == x3)
						io.WriteLine(Solve(y1, y3, y2));
					else if (x2 == x3)
						io.WriteLine(Solve(y2, y3, y1));
					else if (y1 == y2)
						io.WriteLine(Solve(x1, x2, x3));
					else if (y1 == y3)
						io.WriteLine(Solve(x1, x3, x2));
					else if (y2 == y3)
						io.WriteLine(Solve(x2, x3, x1));
					else
						io.WriteLine("3");
				}
			}

#if DEBUG
			Console.ReadLine();
#endif
		}

		static long Solve(long y1, long y2, long y3)
		{
			var minY = Math.Min(y1, y2);
			var maxY = Math.Max(y1, y2);
			if (y3 >= maxY || y3 <= minY)
				return 2;
			else
				return 3;
		}

	}

}


using System;
using System.Linq;
namespace ConsoleApplication4
{
    class Program
    {
        static bool foo(int a, int b, int c)
        {
            return Math.Min(a, b) <= c && Math.Max(a, b) >= c;
        }
        static bool foo(int i, int j, int k, int[][] arr)
        {
            return (arr[i][0] == arr[k][0] || arr[j][0] == arr[k][0]) && foo(arr[i][1], arr[j][1], arr[k][1]) ||
                   (arr[i][1] == arr[k][1] || arr[j][1] == arr[k][1]) && foo(arr[i][0], arr[j][0], arr[k][0]);
        }
        public static void Main(string[] args)
        {
            int[][] pt = new int[3][];
            for(int i = 0; i < 3; i++)
            {
                pt[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }
            Console.WriteLine(pt[0][0] == pt[1][0] && pt[1][0] == pt[2][0] || pt[0][1] == pt[1][1] && pt[1][1] == pt[2][1] ? 1 :
                             foo(0, 1, 2, pt) || foo(0, 2, 1, pt) || foo(1, 2, 0, pt) ? 2 : 3);
        }
    }
}


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

class Program
{
    public class Point
    {
        public int X;
        public int Y;
    }

    public static Point ReadPoint()
    {
        var p = new Point();
        p.X = ReadInt();
        p.Y = ReadInt();

        return p;
    }

    private static bool Inside(int x, int a, int b)
    {
        return x > Math.Min(a, b) && x < Math.Max(a, b);
    }

    private static int Count(Point a, Point b, Point c)
    {
        if (a.X == b.X && a.X == c.X) return 1;
        if (a.Y == b.Y && a.Y == c.Y) return 1;

        if (a.X == b.X && !Inside(c.Y, a.Y, b.Y)) return 2;
        if (a.Y == b.Y && !Inside(c.X, a.X, b.X)) return 2;

        return 3;
    }

    static void Main(string[] args)
    {
        var a = ReadPoint();
        var b = ReadPoint();
        var c = ReadPoint();

        int[] ans = new int[6];
        ans[0] = Count(a, b, c);
        ans[1] = Count(a, c, b);
        ans[2] = Count(b, a, c);
        ans[3] = Count(b, c, a);
        ans[4] = Count(c, a, b);
        ans[5] = Count(c, b, a);

        Console.WriteLine(ans.Min());
    }

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

        return g;
    }

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

        return matrix;
    }

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

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

    private const int BufferSize = 1 << 16;
    private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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


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

namespace CompetitiveProgramming
{
    class Program
    {
        static bool s_IsMultipleTestCases = false;
        static void Main(string[] args)
        {
            InputReader input = new InputReader();
            TextWriter output = Console.Out;
            var numberOfTest = 1;
            if (s_IsMultipleTestCases)
            {
                numberOfTest = input.NextInt();
            }
            for (var testNumber = 1; testNumber <= numberOfTest; ++testNumber)
            {
                Task solver = new Task();
                solver.Solve(testNumber, input, output);
            }

#if DEBUG
            Console.ReadKey();
#endif
        }
    }

    class Task
    {
        public void Solve(int testNumber, InputReader ip, TextWriter op)
        {
            int n = 3;
            var x = new int[n];
            var y = new int[n];
            for (var i = 0; i < n; ++i)
            {
                x[i] = ip.NextInt();
                y[i] = ip.NextInt();
            }
            if (IsCaseOne(x, y))
            {
                op.WriteLine(1);
            }
            else if (IsCaseTwo(x, y))
            {
                op.WriteLine(2);
            }
            else
            {
                op.WriteLine(3);
            }
        }

        private bool IsCaseOne(int[] x, int[] y)
        {
            return (x[0] == x[1] && x[1] == x[2]) || (y[0] == y[1] && y[1] == y[2]);
        }

        private bool IsCaseTwo(int[] x, int[] y)
        {
            bool isValid = false;
            isValid |= x[0] == x[1] && (y[2] >= Max(y[0], y[1]) || y[2] <= Min(y[0], y[1]));
            isValid |= x[1] == x[2] && (y[0] >= Max(y[1], y[2]) || y[0] <= Min(y[1], y[2]));
            isValid |= x[2] == x[0] && (y[1] >= Max(y[2], y[0]) || y[1] <= Min(y[2], y[0]));
            isValid |= y[0] == y[1] && (x[2] >= Max(x[0], x[1]) || x[2] <= Min(x[0], x[1]));
            isValid |= y[1] == y[2] && (x[0] >= Max(x[1], x[2]) || x[0] <= Min(x[1], x[2]));
            isValid |= y[2] == y[0] && (x[1] >= Max(x[2], x[0]) || x[1] <= Min(x[2], x[0]));
            return isValid;
        }

        private int Max(int v1, int v2)
        {
            return Math.Max(v1, v2);
        }

        private int Min(int v1, int v2)
        {
            return Math.Min(v1,v2);
        }
    }

    class InputReader
    {
        static int s_index = 0;
        static string[] s_tokens;
        public string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Length)
            {
                s_tokens = Console.ReadLine().Split(' ').ToArray();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        public string NextLine()
        {
            return Console.ReadLine();
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }

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


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

namespace D.Polyline
{
    class Program
    {
        static void Main(string[] args)
        {
            long[][] p = new long[3][];
            for (var i = 0; i < 3; ++i)
                p[i] = new long[2];
            for(var i = 0; i < 3; ++i) {
                var nm = Console.ReadLine().Split();
                p[i][0] = long.Parse(nm[0]);
                p[i][1] = long.Parse(nm[1]);
            }
            Console.WriteLine(function(p));
        }
        static long function(long[][] p)
        {
            long[] x = p[0];
            long[] y = p[1];
            long[] z = p[2];
            long _x = x[0];
            long _y = y[0];

            if (x[0] == y[0] && y[0] == z[0])
                return 1;

            if (x[1] == y[1] && y[1] == z[1])
                return 1;
            if (check(x, y, z) || check(x, z, y) || check(y, x, z))
                return 2;

            return 3;

        }
        static bool check(long[] p1, long[] p2, long[] p3)
        {
            if ((p1[0] == p2[0] || p2[0] == p3[0]) && belongY(p1, p2, p3))
                return true;
            if ((p1[1] == p2[1] || p2[1] == p3[1]) && belongX(p1, p2, p3))
                return true;
            return false;
        }
        static bool belongX(long[] p1, long[] p2, long[] p3)
        {
            return Math.Min(p1[0], p3[0]) <= p2[0] && p2[0] <= Math.Max(p1[0], p3[0]);
        }
        static bool belongY(long[] p1, long[] p2, long[] p3)
        {
            return Math.Min(p1[1], p3[1]) <= p2[1] && p2[1] <= Math.Max(p1[1], p3[1]);
        }
    }
}


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

namespace doroga
{
    class Program
    {
        static void Main(string[] args)
        {
            int r, g, b,n=29;
            string[] s=Console.ReadLine().Split(' ');
            r = Int32.Parse(s[0]);
            g = Int32.Parse(s[1]);
            b = Int32.Parse(s[2]);
            while (r>0 | g>0 | b>0)
            {
                if (r > 0) r = r - 2;
                n++;
                if (r < 1 & g < 1 & b < 1) break;
                if (g > 0) g = g - 2;
                n++;
                if (r < 1 & g < 1 & b < 1) break;
                if (b > 0) b = b - 2;
                n++;
            }
            Console.WriteLine(n);
        }
    }
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] t = Console.ReadLine().Split(' ');
            int r = (int.Parse(t[0]) + 1) / 2;
            int g = (int.Parse(t[1]) + 1) / 2;
            int b = (int.Parse(t[2]) + 1) / 2;
            int res = 30;
            int max=0;
            int color=0;
            if (r > g && r > b) { max = r; color = 0; };
            if (g >= r && g > b) { max = g; color = 1; };
            if (b >= r && b >= g) { max = b; color = 2; };
            res += 3 * (max-1) + color;
            Console.WriteLine(res);
        }
    }
}


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

namespace ConsoleApp60
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            var index = -1;
            var j = -1;
            for(int i=0;i<3000;i++)
            {
                j++;
                if (N[j]>=2)
                {
                    N[j] = N[j] - 2;
                }
                else if(N[j]==1)
                {
                    N[j] = N[j] - N[j];
                }
                index++;
                if(N.Sum()==0)
                {
                    break;
                }
                if (j == 2)
                {
                    j = -1;
                }
            }
           Console.WriteLine(index + 30);
        }
    }
}


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

namespace Codeforces
{
	class Task90A
	{
		static void Main()
		{
			string[] tokens = Console.In.ReadLine().Split();
			int r = int.Parse(tokens[0]), g = int.Parse(tokens[1]), b = int.Parse(tokens[2]);

			int answer = 0;
			if (r > 0) answer = Math.Max(answer, (r - 1) / 2 * 3 + 30);
			if (g > 0) answer = Math.Max(answer, (g - 1) / 2 * 3 + 31);
			if (b > 0) answer = Math.Max(answer, (b - 1) / 2 * 3 + 32);

			Console.Out.WriteLine(answer);
		}

	}
}


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

class Solver
{
    public void Solve()
    {
        var ss = CF.ReadLine().Split(' ');
        int r = int.Parse(ss[0]);
        int g = int.Parse(ss[1]);
		int b = int.Parse(ss[2]);

		int tr = ((r + 1) / 2);
		if (tr > 0)
			tr = (tr-1) * 3 + 0;
		else tr = 0;
		int tg = ((g + 1) / 2);
		if (tg > 0)
			tg = (tg-1) * 3 + 1;
		else tg = 0;
		int tb = ((b + 1) / 2);
		if( tb > 0 )
			tb = (tb-1) * 3 + 2;
		else
			tb = 0;
		CF.WriteLine(Math.Max(tr,Math.Max(tg,tb))+30);

    }

	//  test
	static Utils CF = new Utils(new[]{
@"
1 3 2
",

@"
3 2 1
"
,
@"
0 0 1
"

    });
    #region test

    static void Main(string[] args)
    {
#if DEBUG
        for (int t=0;t<CF.TestCount;t++ )
        {
            CF.Test(t);
            new Solver().Solve();
        }
#else
        new Solver().Solve();
#endif
    }

    class Utils
    {
        public void Test(int t)
        {
            _lines = new List<string>();
            string[] ss = _test_input[t].Replace("\n", "").Split('\r');
            for (int i = 0; i < ss.Length; i++)
            {
                if (
                    (i == 0 || i == ss.Length - 1) &&
                    ss[i].Length == 0
                    )
                    continue;

                _lines.Add(ss[i]);
            }
        }

        public int TestCount
        {
            get
            {
                return _test_input.Length;
            }
        }

        public string ReadLine()
        {
#if DEBUG
            string s = null;
            if (_lines.Count > 0)
            {
                s = _lines[0];
                _lines.RemoveAt(0);
            }
            return s;

#else
            //return _sr.ReadLine();
        return Console.In.ReadLine();
#endif
        }

        public void WriteLine(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine(o);
#else
            //_sw.WriteLine(o);
        Console.WriteLine(o);
#endif
        }

        public void Write(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.Write(o);
#else
                //_sw.Write(o);
        Console.Write(o);
#endif
        }

        string[] _test_input;

        List<string> _lines;

#if DEBUG
        public Utils(string[] test_input)
        {
            _test_input = test_input;
        }
#else

        public Utils(string[] dummy)
        {
            //_sr = new System.IO.StreamReader("input.txt");
            //_sw = new System.IO.StreamWriter("output.txt");
        }
#endif

    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Cableway
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int totalRed = (int.Parse(input[0]) + 1) / 2 - 1;
            int totalGreen = (int.Parse(input[1]) + 1) / 2 - 1;
            int totalBlue = (int.Parse(input[2]) + 1) / 2 - 1;
            int total = 30;
            if (totalBlue > totalGreen && totalBlue > totalRed)
                total += (3 * totalBlue) + 2;
            else if (totalGreen > totalBlue && totalGreen > totalRed)
                total += (3 * totalGreen) + 1;
            else if (totalRed > totalBlue && totalRed > totalGreen)
                total += (3 * totalRed);
            else
            {
                int max = Math.Max(totalRed, Math.Max(totalBlue, totalGreen));
                total += (3 * max);
                if (max == totalBlue)
                    total += 2;
                else if (max == totalGreen)
                    total++;
            }
            Console.WriteLine(total);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string t = Console.ReadLine();
        string[] bits = t.Split(' ');
        int r = int.Parse(bits[0]), g = int.Parse(bits[1]), b = int.Parse(bits[2]);

        int ris = 30;
        if (r==0 && g==0 && b==0) ris=0;

        while (r != 0 || g != 0 || b != 0)
        {
            ris++;
            if (r > 1) r -= 2;
            else if (r > 0) r--;
            if (r == 0 && g == 0 && b == 0) break;
            ris++;
            if (g > 1) g -= 2;
            else if (g > 0) g--;
            if (r == 0 && g == 0 && b == 0) break;
            ris++;
            if (b > 1) b -= 2;
            else if (b > 0) b--;
        }

        Console.WriteLine(ris-1);
    }
}