#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int res=0;
	bool zf=0;
	char c;
	while(((c=getchar())<'0'||c>'9')&&c!='-');
	if(c=='-')zf=1;
	else res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
	if(zf)return -res;
	return res;
}
const int N=2e5+5;
int dta[N];
vector<int>G[N];
int ct,vi[N];
void dfs(int x){
	vi[x]=1,++ct;
	for(register int i=0;i<G[x].size();++i){
		int v=G[x][i];
		if(!vi[v]){
			dfs(v);
		}
	}
	return;
}
signed main(){
	int n=read();
	for(register int i=1;i<=n;++i){
		dta[i]=read();
	}
	for(register int i=1;i<n-i+1;++i){
		G[dta[i]].push_back(dta[n-i+1]),
		G[dta[n-i+1]].push_back(dta[i]);
	}
	int A=0;
	for(register int i=1;i<=200000;++i){
		if(vi[i]){
			continue;
		}
		ct=0;
		dfs(i);
		A+=ct-1;
	}
	printf("%d\n",A);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using pii = pair<i64, i64>;
#define rep(i, n) for (i64 i = 0; i < i64(n); i++)
#define per(i, n) for (i64 i = n - 1; i >= 0; i--)
#define REP(i, a, b) for (i64 i = a; i < i64(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#ifdef LOCAL
#define dbg(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug(__VA_ARGS__)
#else
#define dbg(...)
#endif
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
    os << '(' << pa.first << ',' << pa.second << ')'; return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (auto& x : vec) { os << x << ' '; } return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &mat) {
    os << endl; for (auto& vec : mat) { os << vec << endl; } return os;
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail> void debug(Head H, Tail... T) {
    cerr << " " << H; debug(T...);
}
template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1 << 30) - 1;
const i64 LINF = (1LL << 62) - 1;

int n, m;
vector<int> G[20];
vector<int> color(20, -1);

i64 dfs(vector<int> &component, int pos = 0) {
    if (pos == (int) component.size()) {
        return 1;
    }

    i64 ret = 0;

    int now = component[pos];

    rep(i, 3) {
        bool ok = 1;
        for (auto& to : G[now]) {
            if (color[to] == i) ok = 0;
        }
        color[now] = i;
        if (ok) {
            ret += dfs(component, pos + 1);
        }
        color[now] = -1;
    }
    return ret;
}

vector<vector<int>> components;
bool visited[20];

vector<int> bfs(int v) {
    vector<int> ret;
    visited[v] = 1;
    queue<int> que;
    ret.push_back(v);
    que.push(v);
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        for (int& to : G[now]) {
            if (visited[to]) continue;
            visited[to] = 1;
            que.push(to);
            ret.push_back(to);
        }
    }
    return ret;
}

void solve() {
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    rep(i, n) {
        if (!visited[i]) {
            components.push_back(bfs(i));
        }
    }

    i64 ans = 1;
    for (auto &component : components) {
        ans *= dfs(component);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}
