program main
integer :: n,k,d,ans = 0
integer,allocatable :: a(:),sn(:)

read(*,*)n,k
allocate(a(n),sn(n))
sn = 0
a = 0

do i = 1,k
read(*,*)d
read(*,*)a(1:d)
do j = 1,d
if (sn(a(j)) == 0) ans = ans + 1
sn(a(j)) = sn(a(j)) + 1
end do
end do

write(*,*) n - ans

end program main
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.7 = internal unnamed_addr global i64 1
@_QFEa.8 = internal unnamed_addr global i64 0
@_QFEans = internal unnamed_addr global i32 0
@_QFEsn.0 = internal unnamed_addr global ptr null
@_QFEsn.7 = internal unnamed_addr global i64 1
@_QQcl.40cffa0c0a61be2818bb447128d1a1f1 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1484/source.f\00"
@_QQcl.16373402fa3425c6e46827601abb88fa = linkonce constant [76 x i8] c"array left hand side must be allocated when the right hand side is a scalar\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.40cffa0c0a61be2818bb447128d1a1f1, i32 5)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 4)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 4)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %9 = load i32, ptr %4, align 4, !tbaa !3
  %10 = call i32 @llvm.smax.i32(i32 %9, i32 0)
  %11 = zext i32 %10 to i64
  %12 = shl nuw nsw i64 %11, 2
  %13 = call ptr @malloc(i64 %12)
  store ptr %13, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEa.7, align 8, !tbaa !7
  store i64 %11, ptr @_QFEa.8, align 8, !tbaa !7
  %14 = call ptr @malloc(i64 %12)
  store ptr %14, ptr @_QFEsn.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEsn.7, align 8, !tbaa !7
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %17, label %.preheader540

.preheader540:                                    ; preds = %0
  %.not547 = icmp slt i32 %9, 1
  br i1 %.not547, label %.loopexit541, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader540
  %15 = call i64 @llvm.smax.i64(i64 %11, i64 1)
  %16 = shl nuw nsw i64 %15, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 %14, i8 0, i64 %16, i1 false), !tbaa !3
  br label %.loopexit541

17:                                               ; preds = %0
  %18 = call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.40cffa0c0a61be2818bb447128d1a1f1, i32 7)
  %.unpack525.unpack.unpack = load i64, ptr @_QFEsn.7, align 8, !tbaa !7
  %19 = icmp slt i32 %9, 1
  %20 = select i1 %19, i64 1, i64 %.unpack525.unpack.unpack
  store ptr null, ptr @_QFEsn.0, align 8, !tbaa !7
  store i64 %20, ptr @_QFEsn.7, align 8, !tbaa !7
  %.unpack.pre = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack431.unpack.unpack433.pre = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  br label %.loopexit541

.loopexit541:                                     ; preds = %.lr.ph.preheader, %.preheader540, %17
  %.unpack431.unpack.unpack433 = phi i64 [ %11, %.lr.ph.preheader ], [ %11, %.preheader540 ], [ %.unpack431.unpack.unpack433.pre, %17 ]
  %.unpack = phi ptr [ %13, %.lr.ph.preheader ], [ %13, %.preheader540 ], [ %.unpack.pre, %17 ]
  %.not436 = icmp eq ptr %.unpack, null
  br i1 %.not436, label %23, label %.preheader

.preheader:                                       ; preds = %.loopexit541
  %21 = icmp sgt i64 %.unpack431.unpack.unpack433, 0
  br i1 %21, label %.lr.ph542.preheader, label %.loopexit

.lr.ph542.preheader:                              ; preds = %.preheader
  %22 = shl nuw i64 %.unpack431.unpack.unpack433, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 %.unpack, i8 0, i64 %22, i1 false), !tbaa !3
  br label %.loopexit

23:                                               ; preds = %.loopexit541
  %24 = call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.40cffa0c0a61be2818bb447128d1a1f1, i32 8)
  %.unpack504.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %25 = icmp eq i64 %.unpack431.unpack.unpack433, 0
  %26 = select i1 %25, i64 1, i64 %.unpack504.unpack.unpack
  store ptr null, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %26, ptr @_QFEa.7, align 8, !tbaa !7
  store i64 %.unpack431.unpack.unpack433, ptr @_QFEa.8, align 8, !tbaa !7
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph542.preheader, %.preheader, %23
  %27 = load i32, ptr %3, align 4, !tbaa !3
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph545, label %._crit_edge546

.lr.ph545:                                        ; preds = %.loopexit
  %29 = zext i32 %27 to i64
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  br label %30

30:                                               ; preds = %.lr.ph545, %._crit_edge
  %31 = phi i64 [ %29, %.lr.ph545 ], [ %86, %._crit_edge ]
  %32 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.40cffa0c0a61be2818bb447128d1a1f1, i32 11)
  %33 = call i1 @_FortranAioInputInteger(ptr %32, ptr nonnull %2, i32 4)
  %34 = call i32 @_FortranAioEndIoStatement(ptr %32)
  %35 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.40cffa0c0a61be2818bb447128d1a1f1, i32 12)
  %.unpack437 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack444.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %36 = load i32, ptr %2, align 4, !tbaa !3
  %37 = sub i64 1, %.unpack444.unpack.unpack
  %38 = call i32 @llvm.smax.i32(i32 %36, i32 0)
  %39 = zext i32 %38 to i64
  %40 = getelementptr i32, ptr %.unpack437, i64 %37
  store ptr %40, ptr %1, align 8, !tbaa !7
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  store i64 %39, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %41 = call i1 @_FortranAioInputDescriptor(ptr %35, ptr nonnull %1)
  %42 = call i32 @_FortranAioEndIoStatement(ptr %35)
  %43 = load i32, ptr %2, align 4, !tbaa !3
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph543, label %._crit_edge

.lr.ph543:                                        ; preds = %30
  %45 = zext i32 %43 to i64
  %_QFEans.promoted = load i32, ptr @_QFEans, align 4, !tbaa !3
  %.unpack449 = load ptr, ptr @_QFEsn.0, align 8, !tbaa !7
  %.unpack456.unpack.unpack = load i64, ptr @_QFEsn.7, align 8, !tbaa !7
  %.unpack461 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack468.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %xtraiter = and i64 %45, 1
  %46 = icmp eq i32 %43, 1
  br i1 %46, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph543.new

.lr.ph543.new:                                    ; preds = %.lr.ph543
  %unroll_iter = and i64 %45, 4294967294
  br label %47

47:                                               ; preds = %72, %.lr.ph543.new
  %indvars.iv = phi i64 [ 1, %.lr.ph543.new ], [ %indvars.iv.next.1, %72 ]
  %48 = phi i32 [ %_QFEans.promoted, %.lr.ph543.new ], [ %73, %72 ]
  %niter = phi i64 [ 0, %.lr.ph543.new ], [ %niter.next.1, %72 ]
  %49 = sub i64 %indvars.iv, %.unpack468.unpack.unpack
  %50 = getelementptr i32, ptr %.unpack461, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !3
  %52 = sext i32 %51 to i64
  %53 = sub i64 %52, %.unpack456.unpack.unpack
  %54 = getelementptr i32, ptr %.unpack449, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !3
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %47
  %58 = add i32 %48, 1
  store i32 %58, ptr @_QFEans, align 4, !tbaa !3
  br label %59

59:                                               ; preds = %57, %47
  %60 = phi i32 [ %58, %57 ], [ %48, %47 ]
  %61 = add i32 %55, 1
  store i32 %61, ptr %54, align 4, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %62 = sub i64 %indvars.iv.next, %.unpack468.unpack.unpack
  %63 = getelementptr i32, ptr %.unpack461, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !3
  %65 = sext i32 %64 to i64
  %66 = sub i64 %65, %.unpack456.unpack.unpack
  %67 = getelementptr i32, ptr %.unpack449, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !3
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %72

70:                                               ; preds = %59
  %71 = add i32 %60, 1
  store i32 %71, ptr @_QFEans, align 4, !tbaa !3
  br label %72

72:                                               ; preds = %70, %59
  %73 = phi i32 [ %71, %70 ], [ %60, %59 ]
  %74 = add i32 %68, 1
  store i32 %74, ptr %67, align 4, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %47

._crit_edge.loopexit.unr-lcssa:                   ; preds = %72, %.lr.ph543
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph543 ], [ %indvars.iv.next.1, %72 ]
  %.unr = phi i32 [ %_QFEans.promoted, %.lr.ph543 ], [ %73, %72 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %75 = sub i64 %indvars.iv.unr, %.unpack468.unpack.unpack
  %76 = getelementptr i32, ptr %.unpack461, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !3
  %78 = sext i32 %77 to i64
  %79 = sub i64 %78, %.unpack456.unpack.unpack
  %80 = getelementptr i32, ptr %.unpack449, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !3
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %._crit_edge.loopexit.epilog-lcssa

83:                                               ; preds = %.epil.preheader
  %84 = add i32 %.unr, 1
  store i32 %84, ptr @_QFEans, align 4, !tbaa !3
  br label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %83, %.epil.preheader
  %85 = add i32 %81, 1
  store i32 %85, ptr %80, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %30
  %86 = add nsw i64 %31, -1
  %87 = icmp sgt i64 %31, 1
  br i1 %87, label %30, label %._crit_edge546

._crit_edge546:                                   ; preds = %._crit_edge, %.loopexit
  %88 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.40cffa0c0a61be2818bb447128d1a1f1, i32 19)
  %89 = load i32, ptr %4, align 4, !tbaa !3
  %90 = load i32, ptr @_QFEans, align 4, !tbaa !3
  %91 = sub i32 %89, %90
  %92 = call i1 @_FortranAioOutputInteger32(ptr %88, i32 %91)
  %93 = call i32 @_FortranAioEndIoStatement(ptr %88)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare {} @_FortranAReportFatalUserError(ptr, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
