#include <bits/stdc++.h>
using namespace std;
int Mod = 1000000007;
double pi = acos(-1.0);
double eps = 1e-6;
typedef struct {
  int f, t, w, next;
} Edge;
Edge edge[1];
int head[1];
int kNum;
void addEdge(int f, int t, int w) {
  edge[kNum].f = f;
  edge[kNum].t = t;
  edge[kNum].w = w;
  edge[kNum].next = head[f];
  head[f] = kNum++;
}
int N, M;
void solve() {
  int cnt = 0;
  int ans = N - 1;
  for (int i = 0; i < M; i++) {
    int tag, pre = -10, num;
    cin >> tag;
    bool flag = false;
    ans += tag - 1;
    for (int j = 0; j < tag; j++) {
      cin >> num;
      if (num == 1 && pre == -10) flag = true;
      if (flag && num - pre == 1) {
        cnt++;
        ans -= 2;
      } else if (flag && pre != -10)
        flag = false;
      pre = num;
    }
  }
  cout << ans << endl;
}
int main() {
  while (cin >> N) {
    cin >> M;
    solve();
  }
  return 0;
}
