#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
//const int mod = 998244353;

vector<vector<int>> to;
vector<int> used, col, vs;
ll now;

void dfs(int v){
    used[v] = 1;
    vs.push_back(v);
    for(int u : to[v]){
        if(used[u]) continue;
        dfs(u);
    }
}

void dfs2(int i){
    if(i == vs.size()){
        now++;
        return;
    }
    int v = vs[i];
    rep(c, 0, 3){
        col[v] = c;
        bool flag = 0;
        for(int u : to[v]){
            if(col[u] == c){
                flag = 1;
            }
        }
        if(flag) continue;
        dfs2(i+1);
    }
    col[v] = -1;
}


int main()
{
    int n, m;
    cin >> n >> m;
    to = vector<vector<int>> (n);
    used = vector<int> (n);
    col = vector<int> (n, -1);
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ll ans = 1;
    rep(v, 0, n){
        if(used[v]) continue;
        vs = vector<int> ();
        dfs(v);
        col[vs[0]] = 0;
        now = 0;
        dfs2(1);
        ans *= 3*now;
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    string s;
    cin >> s;
    int point = x;
    for(int i=0; i<s.size(); i++) {
        if(s[i] == 'x' and point!=0) point--;
        if(s[i] == 'o') point++;
    }
    cout << point << endl;

    return 0;
}

