#include <bits/stdc++.h>
using namespace std;
map<int, int> edge[100001];
vector<int> comp[100001];
int belong[100001];
bool act[100001];
int nex[100001], bef[100001];
int ans;
void merge(int x, int y) {
  int i;
  act[y] = false;
  for (i = 0; i < comp[y].size(); i++)
    comp[x].push_back(comp[y][i]), belong[comp[y][i]] = x;
  nex[bef[y]] = nex[y], bef[nex[y]] = bef[y];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  int i, j;
  cin >> n >> m, ans = n - 1;
  for (i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    edge[x][y] = edge[y][x] = 1;
  }
  nex[0] = 1, bef[1] = 0;
  for (i = 1; i <= n; i++) {
    comp[i].push_back(i);
    belong[i] = i;
    act[i] = true;
    nex[i] = i + 1, bef[i] = i - 1;
  }
  for (i = 1; i <= n; i++) {
    int cur = nex[0];
    while (cur != n + 1) {
      if (cur != belong[i] && act[cur]) {
        for (j = 0; j < comp[cur].size(); j++) {
          if (edge[i][comp[cur][j]] == 0) {
            if (comp[belong[i]].size() < comp[cur].size())
              merge(cur, belong[i]);
            else
              merge(belong[i], cur);
            ans--;
            break;
          }
        }
      }
      cur = nex[cur];
    }
  }
  cout << ans << endl;
  return 0;
}
