#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
inline void INP() {}
int find_parent(int *parent, int p) {
  if (parent[p] < 0) return p;
  return parent[p] = find_parent(parent, parent[p]);
}
void make_union(int *parent, int a, int b) {
  parent[a] += parent[b];
  parent[b] = a;
}
void solve() {
  int n, m;
  cin >> n >> m;
  int *parent = new int[n + 1];
  for (int i = 0; i < (n + 1); ++i) parent[i] = -1;
  for (int i = 0; i < (m); ++i) {
    int x, y;
    cin >> x >> y;
    int a = find_parent(parent, x);
    int b = find_parent(parent, y);
    if (a != b) {
      make_union(parent, a, b);
    }
  }
  ll ans = 1;
  for (int i = 1; i <= (n); ++i) {
    if (parent[i] < 0) {
      ll val = pow(2, (abs(parent[i]) - 1) * 1.0);
      ans *= val;
    }
  }
  cout << ans << '\n';
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
