#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
int d, n, m, belong[100010], cnt[20];
bool no[1 << 20];
int main() {
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 0; i < m; i++) {
    int num, tmp;
    scanf("%d", &num);
    while (num--) {
      scanf("%d", &tmp);
      belong[tmp] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i > d) cnt[belong[i - d]]--;
    cnt[belong[i]]++;
    if (i >= d) {
      int sta = 0;
      for (int j = 0; j < m; j++)
        if (!cnt[j]) sta |= (1 << j);
      no[sta] = 1;
    }
  }
  int ans = m + 1;
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (no[i]) {
      for (int j = 0; j < m; j++)
        if (i & (1 << j)) no[i ^ (1 << j)] = 1;
    } else
      ans = min(ans, __builtin_popcount(i));
  }
  printf("%d\n", ans);
  return 0;
}
