#include <bits/stdc++.h>
using namespace std;
int n, m, d;
int bel[111111];
int vis[(1 << 21)];
int ct[30];
int main() {
  cin >> n >> m >> d;
  int x;
  for (int i = 0; i < m; i++) {
    cin >> x;
    int y;
    while (x--) {
      cin >> y;
      bel[y] = i;
    }
  }
  for (int i = 1; i <= d; i++) {
    ct[bel[i]]++;
  }
  int tmp = 0;
  for (int i = 0; i < m; i++)
    if (ct[i]) tmp += (1 << i);
  vis[tmp] = 1;
  for (int i = d + 1; i <= n; i++) {
    if (ct[bel[i]] == 0) {
      tmp += (1 << bel[i]);
    }
    ct[bel[i]]++;
    if (ct[bel[i - d]] == 1) tmp -= (1 << bel[i - d]);
    ct[bel[i - d]]--;
    vis[tmp] = 1;
  }
  for (int s = 0; s < (1 << m); s++)
    if (vis[s]) {
      for (int i = 0; i < m; i++) vis[s | (1 << i)] = 1;
    }
  int s, ans = 0;
  for (s = (1 << m) - 1; s >= 0; s--)
    if (vis[s] == 0) {
      int q = 0;
      for (int i = 0; i < m; i++)
        if (s & (1 << i)) q++;
      if (q > ans) ans = q;
    }
  cout << m - ans << endl;
  ;
}
