#include <bits/stdc++.h>
using namespace std;
const int va = 100010;
int n, m, d, t, x, c[va], b, cnt[25], ans, bad[1 << 20];
int count(int x) {
  int cnt = 0;
  while (x) {
    if (x & 1) cnt++;
    x >>= 1;
  }
  return cnt;
}
int main() {
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &t);
    for (int j = 1; j <= t; j++) {
      scanf("%d", &x);
      c[x] = i;
    }
  }
  int maxn = (1 << m) - 1;
  ans = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    cnt[c[i]]++;
    b |= 1 << (c[i] - 1);
    if (i > d) {
      if (!(--cnt[c[i - d]])) {
        b ^= 1 << (c[i - d] - 1);
      }
    }
    if (i >= d) {
      bad[maxn ^ b] = true;
    }
  }
  for (int i = maxn; i >= 1; i--) {
    if (!bad[i])
      ans = min(ans, count(i));
    else {
      for (int j = 1; j <= m; j++) {
        if (i & (1 << (j - 1))) {
          int k = i ^ (1 << (j - 1));
          bad[k] = true;
        }
      }
    }
  }
  printf("%d", ans);
  return 0;
}
