#include <bits/stdc++.h>
int main() {
  int n;
  int m;
  std::vector<int> dsu;
  std::cin >> n >> m;
  dsu.resize(n);
  for (int i = 0; i < n; ++i) dsu[i] = i;
  long long ans = 1;
  for (int i = 0; i < m; ++i) {
    int x;
    int y;
    std::cin >> x >> y;
    --x;
    --y;
    while (x != dsu[x]) x = dsu[x];
    while (y != dsu[y]) y = dsu[y];
    if (x != y) ans *= 2;
    dsu[y] = x;
  }
  std::cout << ans << std::endl;
  return 0;
}
