import java.util.Scanner; import java.util.ArrayList; import java.util.HashSet; import java.util.InputMismatchException; public class CardMatch { static Scanner scanner = new Scanner(System.in); public static void main(String[] args){ int W = Input(1,1000000); int H = Input(1,1000000); int N = Input(1,Math.min(W*H,100)); ArrayList S = new ArrayList<>(); ArrayList K = new ArrayList<>(); for(int i = 0 ; i < N ; i++){ S.add(Input(1,W)); K.add(Input(1,H)); } int Result = Processing(W,H,N,S,K); System.out.println(Result); } public static int Input(int Min , int Max){ int Number = scanner.nextInt(); try{ if(Number < Min || Number > Max){ System.out.println(Min + "以上" + Max + "以下の数字で入力してください"); System.exit(0); } }catch(InputMismatchException e){ System.out.println("数字を入力してください"); System.exit(0); }catch(Exception E){ System.out.println("想定外のエラーです"); System.exit(0); } return Number; } public static int Processing(int W , int H , int N , ArrayList S , ArrayList K){ ArrayList CountS = new ArrayList<>(new HashSet<>(S)); ArrayList CountK = new ArrayList<>(new HashSet<>(K)); int Total = W * H ; int UnmatchW = W - CountS.size(); int UnmatchH = H - CountK.size(); int Result = Total - UnmatchW * UnmatchH - N; return Result; } }