#include <bits/stdc++.h>
using namespace std;
int main() {
  istream& is = cin;
  int n;
  is >> n;
  int k;
  is >> k;
  vector<vector<int>> chains(k);
  for (int i = 0; i < k; i++) {
    int count;
    is >> count;
    chains[i].resize(count);
    for (int j = 0; j < count; j++) {
      is >> chains[i][j];
    }
  }
  int parts = 0;
  int seconds = 0;
  for (size_t i = 0; i < chains.size(); i++) {
    if (chains[i][0] != 1) {
      parts += chains[i].size();
      seconds += chains[i].size() - 1;
    } else {
      int tmp = 0;
      for (size_t j = 0; j < chains[i].size(); j++) {
        if (j + 1 == chains[i][j]) {
          tmp++;
        } else {
          break;
        }
      }
      parts += chains[i].size() - tmp + 1;
      seconds += chains[i].size() - tmp;
    }
  }
  cout << parts + seconds - 1;
  return 0;
}
