#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long euclid(long long a, long long b) {
  if (b == 0) return a;
  return euclid(b, a % b);
}
tuple<long long, long long, long long> euclidian_theorem(long long a,
                                                         long long b) {
  if (b == 0) {
    return {a, 1, 0};
  }
  long long g, x, y;
  tie(g, x, y) = euclidian_theorem(b, a % b);
  return {g, y, x - ((a * y) / b)};
}
pair<long long, long long> diophentane(long long a, long long b, long long c) {
  long long g = euclid(a, b);
  long long x, y;
  if (c % g != 0) return {0, 0};
  tie(g, x, y) = euclidian_theorem(a, b);
  long long k = c / g;
  x = x * k;
  y = y * k;
  return {x, y};
}
long long modulo_inverse(long long a, long long m) {
  long long g, x, y;
  tie(g, x, y) = euclidian_theorem(a, m);
  if (g != 1) return 0;
  x = (x % m + m) % m;
  return x;
}
long long chinese_remainder_theorem(vector<long long> a, vector<long long> m) {
  long long ans = 0;
  long long n = m.size();
  for (long long i = 0; i < n; ++i)
    for (long long j = i + 1; j < n; ++j)
      if (euclid(m[i], m[j]) != 1) return 0;
  long long mul_m = 1;
  for (int i = 0; i < n; ++i) mul_m *= m[i];
  for (long long i = 0; i < n; i++) {
    long long mk = mul_m / m[i];
    long long xk = a[i] * mk * modulo_inverse(mk, m[i]);
    ans += xk;
  }
  return ans % mul_m;
}
class GRAPH {
 public:
  map<long long, vector<long long>> h;
  set<long long> visit;
  long long var = 0;
  GRAPH() {
    this->var = 0;
    this->h.clear();
  }
  void add(long long a, long long b) {
    h[a].push_back(b);
    h[b].push_back(a);
  }
  void dsu(long long s) {
    visit.insert(s);
    var++;
    for (auto x : h[s]) {
      if (!visit.count(x)) {
        dsu(x);
      }
    }
  }
};
long long FPOW(long long a, long long n) {
  if (n == 0) return 1;
  long long aa = FPOW(a, n / 2);
  aa = aa * aa;
  if (n & 1) return aa * a;
  return aa;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  GRAPH g;
  for (long long i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    g.add(a, b);
  }
  for (long long i = 1; i <= n; i++) {
    if (!g.visit.count(i)) {
      g.dsu(i);
      g.var--;
    }
  }
  cout << FPOW(2, g.var) << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
