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){ long W = Input(1,1000000); long H = Input(1,1000000); long N = Input(1, (int) Math.min(W*H,100)); ArrayList S = new ArrayList<>(); ArrayList K = new ArrayList<>(); for(int i = 0 ; i < N ; i++){ S.add(Input(1, (int) W)); K.add(Input(1, (int) H)); } long 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 long Processing(long W , long H , long N , ArrayList S , ArrayList K){ ArrayList CountS = new ArrayList<>(new HashSet<>(S)); ArrayList CountK = new ArrayList<>(new HashSet<>(K)); long Total = W * H ; long UnmatchW = W - CountS.size(); long UnmatchH = H - CountK.size(); long Result = Total - UnmatchW * UnmatchH - N; return Result; } }