#include <bits/stdc++.h>
using namespace std;
const int def = 0x3f3f3f3f;
int a[100000];
int main() {
  int i, j, h;
  int n, m, r;
  int len = 0;
  int shuchu = 0;
  scanf("%d %d", &n, &m);
  for (j = 1; j <= m; j++) {
    int flag = 0;
    scanf("%d", &h);
    for (i = 1; i <= h; i++) {
      scanf("%d", &a[i]);
      if (a[i] == 1) flag = 1;
    }
    if (flag)
      for (i = 1; i <= h; i++) {
        if (a[i] != i)
          break;
        else
          len++;
      }
    if (flag)
      shuchu += h - len;
    else
      shuchu += h - 1;
  }
  printf("%d\n", shuchu + n - len);
}
