#include <bits/stdc++.h>
using namespace std;
int work(int x) {
  int sum = 0;
  while (x != 0) {
    if (x % 2 == 1) sum++;
    x /= 2;
  }
  return sum;
}
int n, m, p, t, x, a[100005];
bool flag[2000000];
int s, dq;
int c[100];
int ans;
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &t);
    for (int j = 1; j <= t; ++j) {
      scanf("%d", &x);
      a[x] = i;
    }
  }
  s = (1 << m) - 1;
  memset(flag, true, sizeof(flag));
  t = p;
  for (int i = 1; i <= n; ++i) {
    c[a[i]]++;
    dq |= 1 << (a[i] - 1);
    if (i > t) {
      c[a[i - t]]--;
      if (c[a[i - t]] == 0) dq ^= 1 << (a[i - t] - 1);
    }
    if (i >= t) {
      dq ^= s;
      flag[dq] = false;
      dq ^= s;
    }
  }
  ans = 19950920;
  for (int i = s; i >= 0; --i) {
    if (flag[i])
      ans = min(ans, work(i));
    else {
      for (int j = 1; j <= m; ++j) {
        if ((i & (1 << (j - 1))) == 0) continue;
        flag[i - (1 << (j - 1))] = false;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
