program main implicit none type card integer::S,K end type card integer::W,H,N,i,markmatch,numbermatch integer,allocatable::mark(:),number(:) type(card),allocatable::cards(:) read *,W,H,N allocate(mark(W),number(H),cards(N)) mark = 0 number = 0 read *, cards do i=1,N mark(cards(i)%S) = 1 number(cards(i)%K) = 1 end do markmatch = COUNT(mark.eq.1) numbermatch = COUNT(number.eq.1) print '(i0)',markmatch*H+numbermatch*W-markmatch*numbermatch-N end program main