#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n, k, m;
int main() {
  cin >> n >> k;
  int ans = k - 1, x, y;
  while (k--) {
    scanf("%d", &m);
    scanf("%d", &y);
    m--;
    while (m--) {
      scanf("%d", &x);
      if (x - y != 1) ans += 2;
      y = x;
    }
  }
  cout << ans << endl;
  return 0;
}
