#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  int can = 0;
  int cang = 0;
  for (int i = 0; i < k; i++) {
    int m;
    scanf("%d", &m);
    vector<int> grupo;
    vector<int> cg(m);
    bool entro = false;
    for (int j = 0; j < m; j++) {
      int a;
      scanf("%d", &a);
      grupo.push_back(a);
    }
    int cang2 = 0;
    int val = grupo[0];
    cg[0]++;
    for (int j = 1; j < m; j++) {
      if (val + 1 == grupo[j]) {
        val++;
      } else {
        cang2++;
        val = grupo[j];
      }
      if (cang2 >= 1) {
        can++;
        entro = true;
        cang++;
      }
      cg[cang2]++;
    }
    cang++;
    cang2++;
  }
  can += (cang - 1);
  printf("%d\n", can);
}
