#include <bits/stdc++.h>
using namespace std;
const bool testing = false;
void program() {
  int n, k;
  cin >> n >> k;
  int r = 0;
  for (int i = 0; i < k; i++) {
    int c;
    cin >> c;
    r += c - 1;
    bool g = true;
    int x = 0;
    for (int j = 0; j < c; j++) {
      int t;
      cin >> t;
      if (g && t == j + 1) {
        x++;
      } else
        g = false;
    }
    if (x) r -= (x - 1) * 2;
  }
  r += n - 1;
  cout << r << endl;
}
int main() {
  if (!testing) {
    program();
    return 0;
  }
  FILE* fin = NULL;
  fin = fopen("in.txt", "w+");
  fprintf(fin, "3 2\n2 1 2\n1 3\n");
  fclose(fin);
  freopen("in.txt", "r", stdin);
  printf("test case(1) => expected : \n");
  printf("1\n");
  printf("test case(1) => founded  : \n");
  program();
  fin = fopen("in.txt", "w+");
  fprintf(fin, "7 3\n3 1 3 7\n2 2 5\n2 4 6\n");
  fclose(fin);
  freopen("in.txt", "r", stdin);
  printf("test case(2) => expected : \n");
  printf("10\n");
  printf("test case(2) => founded  : \n");
  program();
  return 0;
}
