#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int par[10005];
int size[10005];
int find_set(int x) {
  if (x != par[x]) par[x] = find_set(par[x]);
  return (par[x]);
}
void union_set(int a, int b) {
  int x = find_set(a);
  int y = find_set(b);
  if (x != y) {
    if (size[x] < size[y]) swap(x, y);
    par[y] = x;
    size[x] += size[y];
  }
}
int main() {
  int n, m;
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  for (int i = 1; i < n + 1; i++) {
    par[i] = i;
    size[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d", &a);
    ;
    scanf("%d", &b);
    ;
    union_set(a, b);
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    if (find_set(i) == i) ans += size[i] - 1;
  }
  long long ans1 = pow(2, ans);
  printf("%lld\n", ans1);
  ;
  return (0);
}
