#include <bits/stdc++.h>
using namespace std;
long long inv(long long a, long long b) {
  return (a > 1 ? b - inv(b % a, a) * b / a : 1);
}
const long double e = 2.71828182845904523536028747;
const long double PI = 3.14159265359;
const long long inf = (1LL << 62);
const int iinf = (1 << 30);
int n, m, cnt;
set<int> S;
map<int, int> M[100100];
void dfs(int q) {
  vector<int> v;
  for (auto it : S) {
    if (it == q) continue;
    if (!M[q][it]) v.push_back(it);
  }
  for (auto it : v)
    if (S.find(it) != S.end()) S.erase(it);
  for (auto it : v) dfs(it);
}
int main() {
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    M[x][y] = M[y][x] = 1;
  }
  for (int i = 1; i <= n; i++) S.insert(i);
  for (int i = 1; i <= n; i++)
    if (S.find(i) != S.end()) cnt++, dfs(i);
  cout << cnt - 1;
  return 0;
}
