#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int t_dis = 0;
  for (int i = 0; i < k; ++i) {
    int m;
    int flag = 0;
    int dis = 0;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int foo;
      cin >> foo;
      if (foo == j + 1 && flag == 0) {
        dis++;
      } else {
        flag = 1;
      }
    }
    if (dis > 0) {
      ans += m - dis;
    } else {
      ans += m - 1;
    }
    t_dis += dis;
  }
  if (t_dis > 0) {
    ans += n - t_dis;
  } else {
    ans += n - 1;
  }
  cout << ans << endl;
  return 0;
}
