#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int p[N], cnt[21];
bool bad[1 << 20];
inline int getcount(int x) {
  int ret = 0;
  while (x) {
    x &= (x - 1);
    ret++;
  }
  return ret;
}
int main() {
  int n, d, m;
  cin >> n >> m >> d;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    for (int j = 0; j < x; j++) {
      scanf("%d", &y);
      p[y] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    cnt[p[i]]++;
    if (i > d) cnt[p[i - d]]--;
    if (i >= d) {
      int tmp = 0;
      for (int j = 0; j < m; j++) {
        if (!cnt[j]) tmp |= 1 << j;
      }
      bad[tmp] = true;
    }
  }
  int ans = m;
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (!bad[i])
      ans = min(ans, getcount(i));
    else {
      for (int j = 0; j < m; j++) {
        if (i & (1 << j)) bad[i - (1 << j)] = true;
      }
    }
  }
  cout << ans << endl;
}
