#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e18;
const long long minN = -1e18;
const long long MOD = 1e9 + 7;
const long long MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const long double PI = acos(-1);
const long long limit = 2e5 + 5;
const long long limit1 = 1e6 + 5;
const long long limit2 = 1e3 + 5;
pair<long long, long long> dir[] = {{0, 1}, {1, 0},  {0, -1}, {-1, 0},
                                    {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
int n, m;
map<int, bool> check[limit];
set<int> s;
int root[limit];
int cur[limit];
int d = 0;
bool compo[limit];
long long ans = 0;
int findRoot(int u) { return (root[u] < 0) ? u : findRoot(root[u]); }
void mergeRoot(int u, int v) {
  u = findRoot(u);
  v = findRoot(v);
  if (u == v) return;
  if (root[u] > root[v]) swap(u, v);
  root[u] += root[v];
  root[v] = u;
}
void solveProblem() {
  queue<int> q;
  vector<int> cur;
  memset(root, -1, sizeof(root));
  for (int i = (1); i <= (n); ++i) s.insert(i);
  for (int i = (1); i <= (n); ++i) {
    if (s.count(i)) {
      s.erase(i);
      q.push(i);
      ++ans;
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto it : s) {
          if (check[it][u]) continue;
          cur.push_back(it);
          mergeRoot(u, it);
          q.push(it);
        }
        for (auto it : cur) s.erase(it);
        cur.clear();
      }
    }
  }
  cout << ans - 1 << '\n';
}
void fastInput() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void readInput() {
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    int u, v;
    cin >> u >> v;
    check[u][v] = true;
    check[v][u] = true;
  }
}
int main() {
  fastInput();
  readInput();
  solveProblem();
}
