#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
vector<unordered_set<int>> adj;
set<int> st;
int n;
void dfs(int v) {
  vector<int> a;
  for (auto to : st) {
    if (adj[v].find(to) == adj[v].end()) {
      a.push_back(to);
    }
  }
  for (int i = 0; i < a.size(); i++) st.erase(a[i]);
  for (int i = 0; i < a.size(); i++) dfs(a[i]);
}
void solve() {
  int m;
  cin >> n >> m;
  adj.resize(n + 1, unordered_set<int>());
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].insert(y);
    adj[y].insert(x);
  }
  for (int i = 1; i <= n; i++) st.insert(i);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (st.find(i) != st.end()) {
      ans++;
      dfs(i);
    }
  }
  cout << ans - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) solve();
}
