#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    int m;
    scanf("%d", &m);
    for (int j = 0; j < m; j++) {
      int a;
      scanf("%d", &a);
      g[i].push_back(a);
    }
  }
  int fin = 0;
  int temp = 1;
  for (int i = 1; i <= k; i++) {
    if (g[i][0] != 1)
      fin += g[i].size() - 1;
    else {
      for (int j = 1; j < g[i].size(); j++) {
        if (g[i][j] == g[i][j - 1] + 1)
          temp++;
        else
          break;
      }
      fin += g[i].size() - temp;
    }
  }
  fin += n - temp;
  printf("%d\n", fin);
}
