#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  map<int, int> mp, vis;
  vector<vector<int>> v;
  long long n, k, ans = 0;
  cin >> n >> k;
  while (k--) {
    int m;
    cin >> m;
    vector<int> ve;
    while (m--) {
      int x;
      cin >> x;
      ve.push_back(x);
    }
    v.push_back(ve);
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size() - 1; j++) {
      mp[v[i][j]] = v[i][j + 1];
    }
  }
  for (int i = 1; i < n; i++) {
    if (mp[i] == 0 && mp[i + 1] == 0) {
      ans++;
      mp[i] = i + 1;
    } else if (mp[i] == 0 && mp[i + 1] != 0) {
      ans += 2;
      mp[i + 1] = 0;
      mp[i] = i + 1;
    } else if (mp[i] - 1 != i && mp[i + 1] != 0) {
      ans += 3;
      mp[i + 1] = 0;
      mp[i] = i + 1;
    } else if (mp[i] - 1 != i && mp[i + 1] == 0) {
      ans += 2;
      mp[i] = i + 1;
    }
  }
  cout << ans;
  return 0;
}
