import java.util.Scanner;
public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	}
} Main static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;} gcd {return b>0?gcd(b,a%b):a;} return b>0?gcd(b,a%b):a; b>0?gcd(b,a%b):a b>0 b 0 gcd(b,a%b) gcd b a%b a b a int a a int b b static int lcm (int a, int b) {return a*b/gcd(a,b);} lcm {return a*b/gcd(a,b);} return a*b/gcd(a,b); a*b/gcd(a,b) a*b a b gcd(a,b) gcd a b int a a int b b public static int lower_bound(int vector[],int key){
		return 0;
	} lower_bound {
		return 0;
	} return 0; 0 int vector[] vector int key key public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	} max {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	} if(a>b) {
			return a;
		}
		else {
			return b;
		} a>b a b {
			return a;
		} return a; a {
			return b;
		} return b; b int a a int b b public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	} min {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	} if(a<b) {
			return a;
		}
		else {
			return b;
		} a<b a b {
			return a;
		} return a; a {
			return b;
		} return b; b int a a int b b public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	} isPrime {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	} if (n==2) return true; n==2 n 2 return true; true if (n<2 || n%2==0) return false; n<2 || n%2==0 n<2 n 2 n%2==0 n%2 n 2 0 return false; false double d = Math.sqrt(n); d Math.sqrt(n) Math.sqrt Math n for (int i=3; i<=d; i+=2) if(n%i==0){return false;} int i=3; int i=3; i 3 i<=d i d i+=2 i+=2 i 2 if(n%i==0){return false;} if(n%i==0){return false;} n%i==0 n%i n i 0 {return false;} return false; false return true; true int n n public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	} factorial {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	} if (i==1) {return 1;}
		else {return i*factorial(i-1);} i==1 i 1 {return 1;} return 1; 1 {return i*factorial(i-1);} return i*factorial(i-1); i*factorial(i-1) i factorial(i-1) factorial i-1 i 1 int i i public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	} main {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int b=scan.nextInt(); b scan.nextInt() scan.nextInt scan int moto=(b+a+b-1)*a/2; moto (b+a+b-1)*a/2 (b+a+b-1)*a (b+a+b-1) b+a+b b+a+b b a b 1 a 2 int min=1145141929; min 1145141929 for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	} int i=0,j=b; int i=0 i 0 j=b; j b i<a i a i++,j++ i++ i j++ j {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	} {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	} int are=moto-j; are moto-j moto j min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min min min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto) min(Math.abs(are-moto),Math.abs(moto-min)) min Math.abs(are-moto) Math.abs Math are-moto are moto Math.abs(moto-min) Math.abs Math moto-min moto min Math.abs(are-moto) Math.abs Math are-moto are moto are min System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	}
} public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	}
} Main
import java.util.Scanner;
public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int moto=(b+a+b-1)*a/2;
	int min=1145141929;
	for(int i=0,j=b;i<a;i++,j++) {
		int are=moto-j;
		min=min(Math.abs(are-moto),Math.abs(moto-min))==Math.abs(are-moto)?are:min;
	}
	System.out.println(min);
	}
}