#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
inline T russian(T a, T b, T mod) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (a + a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const long long T = 1 << 20;
const long long INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1e18 + 7;
const long long N = 1e6 + 7;
const int LOG = 17;
long long n, m, k, q;
int w[N];
vector<set<int>> G(N);
int rep[N];
int c;
int Find(int x) {
  if (x != rep[x]) rep[x] = Find(rep[x]);
  return rep[x];
}
void Union(int a, int b) {
  a = Find(a);
  b = Find(b);
  if (a == b) return;
  c--;
  rep[a] = b;
}
int odw[N];
set<int> nieuzyte;
void bfs(int start) {
  queue<int> kol;
  odw[start] = 1;
  kol.push(start);
  while ((int)(kol).size()) {
    auto akt = kol.front();
    kol.pop();
    vector<int> wywal;
    for (auto &u : nieuzyte) {
      if (G[akt].count(u)) {
        continue;
      }
      wywal.push_back(u);
    }
    for (auto &u : wywal) {
      Union(akt, u);
      nieuzyte.erase(u);
      kol.push(u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  c = n;
  for (int i = 1; i <= n; i++) nieuzyte.insert(i);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].insert(b);
    G[b].insert(a);
  }
  for (int i = 1; i <= n; i++) rep[i] = i;
  for (int i = 1; i <= n; i++) {
    if (!nieuzyte.count(i)) continue;
    nieuzyte.erase(i);
    bfs(i);
  }
  cout << c - 1 << '\n';
}
