Problem:
Score : 200 points

Problem Statement

N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.

There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.

Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N

Input

Input is given from Standard Input in the following format:

N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K}

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2

Solution in C (GCC 9.2.1) (judge verdict: Accepted)

#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int compare_base(const void *b, const void *f) {
  return (*(int *)b - *(int *)f);
}

int main(void) {
  int scan; // scanf result
  int *answer; // to output 
  int n; // to input 
  int k; // to input 
  int *d;
  int **ad;
  int count;

  scan = scanf("%d", &n);
  scan = scanf("%d", &k);

  d = (int *)malloc(sizeof(int) * k);
  ad = (int **)malloc(sizeof(int *) * k);
  for (int i = 0; i < k; i++) {
    scan = scanf("%d", &d[i]);
    ad[i] = (int *)malloc(sizeof(int) * d[i]);
    for (int m = 0; m < d[i]; m++) {
      scan = scanf("%d", &ad[i][m]);
    }
  }

  int dsum = 0;
  for (int i = 0; i < k; i++) {
      dsum += d[i];
  }

//  printf("dsum: %d\n", dsum);

  answer = (int *)malloc(sizeof(int) * k * dsum);
  count = 0; 
  for (int y = 0; y < k; y++) {
    for (int x = 0; x < d[y]; x++) {
      answer[count] = ad[y][x];
      count++;
    }
  }
  
  qsort(answer, k * dsum, sizeof(int), compare_base);

//  for (int i = 0; i < k * dsum; i++) {
//    printf("a: %d\n", answer[i]);
//  }

  int answercount = 0;
  for (int i = 0; i < k * dsum; i++) {
    if ((i == 0 || (i >= 1 && answer[i - 1] != answer[i])) && answer[i] != 0) {
      answercount++;
    }
  }

//  printf("answer count: %d\n", answercount); 

  printf("%d", (n - answercount));
  return (0);
}