#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int n, m;
int vis[N];
set<int> g[N], mp;
void dfs(int u) {
  vector<int> vec;
  for (auto it : mp) {
    if (g[u].find(it) == g[u].end()) vec.push_back(it);
  }
  for (auto it : vec) mp.erase(it);
  for (auto it : vec) dfs(it);
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) mp.insert(i);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (mp.find(i) != mp.end()) dfs(i), ans++;
  cout << ans - 1 << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
