import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long m = sc.nextLong(); long cut = 0; if (n >= m){ } long cut1 = Math.max(0, Math.min(m-1,n-1)); long cut2 = Math.max(0, Math.max(m-1,n-1) * (cut1+1)); System.out.println(cut1+cut2); } }