#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(2 * mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vector<bool> visited(2 * mx);
	for(int u = mx; u < 2 * mx; u ++){
		visited[u] = true;
	}
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		visited[mx + u] = false;
		adj[mx + u].push_back(u);
		adj[mx - 1 - u].push_back(mx + u);
	}
	int res = 0;
	for(int u = mx; u < 2 * mx; u ++){
		if(!visited[u]){
			res ++;
			vi q{u};
			visited[u] = true;
			while(!q.empty()){
				int u = q.back();
				q.pop_back();
				for(auto v: adj[u]){
					if(!visited[v]){
						visited[v] = true;
						q.push_back(v);
					}
				}
			}
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vi visited(mx, 2);
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		visited[u] = 0;
	}
	function<void(int)> dfs = [&](int u){
		if(!(visited[mx - 1 - u] & 2)){
			visited[mx - 1 - u] |= 2;
			dfs(mx - 1 - u);
		}
		for(auto v: adj[u]){
			if(!(visited[v] & 1)){
				visited[v] |= 1;
				dfs(v);
			}
		}
	};
	int res = 0;
	for(int u = 0; u < mx; u ++){
		if(!(visited[u] & 2)){
			res ++;
			visited[u] |= 2;
			dfs(u);
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(2 * mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vi visited(2 * mx);
	for(int u = mx; u < 2 * mx; u ++){
		visited[u] = true;
	}
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		visited[mx + u] = false;
		adj[mx + u].push_back(u);
		adj[mx - 1 - u].push_back(mx + u);
	}
	function<void(int)> dfs = [&](int u){
		visited[u] = true;
		for(auto v: adj[u]){
			if(!visited[v]){
				dfs(v);
			}
		}
	};
	int res = 0;
	for(int u = mx; u < 2 * mx; u ++){
		if(!visited[u]){
			res ++;
			dfs(u);
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(2 * mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vector<bool> visited(2 * mx);
	for(int u = mx; u < 2 * mx; u ++){
		visited[u] = true;
	}
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		visited[mx + u] = false;
		adj[mx + u].push_back(u);
		adj[mx - 1 - u].push_back(mx + u);
	}
	function<void(int)> dfs = [&](int u){
		visited[u] = true;
		for(auto v: adj[u]){
			if(!visited[v]){
				dfs(v);
			}
		}
	};
	int res = 0;
	for(int u = mx; u < 2 * mx; u ++){
		if(!visited[u]){
			res ++;
			dfs(u);
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vector<bool> visited(mx), used(mx, 1);
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		used[u] = false;
	}
	function<void(int)> dfs = [&](int u){
		visited[u] = true;
		if(!used[mx - 1 - u]){
			used[mx - 1 - u] = true;
			dfs(mx - 1 - u);
		}
		for(auto v: adj[u]){
			if(!visited[v]){
				dfs(v);
			}
		}
	};
	int res = 0;
	for(int u = 0; u < mx; u ++){
		if(!used[u]){
			res ++;
			dfs(u);
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vi visited(mx, 2);
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		visited[u] = 0;
	}
	int res = 0;
	for(int u = 0; u < mx; u ++){
		if(!(visited[u] & 2)){
			res ++;
			visited[u] = 3;
			vi q{u};
			while(!q.empty()){
				int u = q.back();
				q.pop_back();
				if(!(visited[mx - 1 - u] & 2)){
					visited[mx - 1 - u] = 3;
					q.push_back(mx - 1 - u);
				}
				for(auto v: adj[u]){
					if(!(visited[v] & 1)){
						visited[v] |= 1;
						q.push_back(v);
					}
				}
			}
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	vi visited(mx, 2);
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		visited[u] = 0;
	}
	function<void(int)> dfs = [&](int u){
		visited[u] |= 1;
		if(!(visited[mx - 1 - u] & 2)){
			visited[mx - 1 - u] |= 2;
			dfs(mx - 1 - u);
		}
		for(auto v: adj[u]){
			if(!(visited[v] & 1)){
				dfs(v);
			}
		}
	};
	int res = 0;
	for(int u = 0; u < mx; u ++){
		if(!(visited[u] & 2)){
			res ++;
			visited[u] |= 2;
			dfs(u);
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	bitset<1 << 22> visited, used;
	used.set();
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		used.reset(u);
	}
	int res = 0;
	for(int u = 0; u < mx; u ++){
		if(!used[u]){
			res ++;
			visited[u] = used[u] = true;
			vi q{u};
			while(!q.empty()){
				int u = q.back();
				q.pop_back();
				if(!used[mx - 1 - u]){
					visited[mx - 1 - u] = used[mx - 1 - u] = true;
					q.push_back(mx - 1 - u);
				}
				for(int bit = 0; bit < n; bit ++){
					if(!(u & 1 << bit)){
						int v = u ^ 1 << bit;
						if(!visited[v]){
							visited[v] = true;
							q.push_back(v);
						}
					}
				}
			}
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	const int mx = 1 << n;
	vector<vi> adj(mx);
	for(int u = 0; u < mx; u ++){
		for(int bit = 0; bit < n; bit ++){
			if(!(u & 1 << bit)){
				adj[u].push_back(u ^ 1 << bit);
			}
		}
	}
	bitset<1 << 22> visited, used;
	used.set();
	for(int i = 0; i < m; i ++){
		int u;
		cin >> u;
		used.reset(u);
	}
	int res = 0;
	for(int u = 0; u < mx; u ++){
		if(!used[u]){
			res ++;
			visited[u] = used[u] = true;
			vi q{u};
			while(!q.empty()){
				int u = q.back();
				q.pop_back();
				if(!used[mx - 1 - u]){
					visited[mx - 1 - u] = used[mx - 1 - u] = true;
					q.push_back(mx - 1 - u);
				}
				for(auto v: adj[u]){
					if(!visited[v]){
						visited[v] = true;
						q.push_back(v);
					}
				}
			}
		}
	}
	cout << res;
	return 0;
}
/*
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int INF=1e8;
const int maxn=(1<<22),mod=1000007;
const double eps = 1e-12;
const long double PI = acos(0.0) * 2.0;
int n,m;
int li;
int id(int i,int j)
{
	return i+(j-1)*li;
}
pair<int,int>reid(int x)
{
	return mp(x-x/li*li,x/li);
}
vector<int>g[maxn<<1];
vector<int>a;
bool vi[maxn<<1];
void bfs(int i)
{
	queue<int>q;q.push(i);vi[i]=1;
	while(!q.empty())
	{
		int c=q.front();q.pop();
		for(auto nx:g[c])
		{
			if(!vi[nx])vi[nx]=1,q.push(nx);
		}
	}
}
int main()
{
	int r;
	fast;
	cin>>n>>m;
	li=(1<<n)-1;
	_for(t,0,m)
	{
		cin>>r;a.pb(r);
	}
	for(auto s:a)
	{
		g[id(s,1)].pb(id(s,2));
	}
	_for(t,0,1<<n)
	{
		_for(k,0,n)
		{
			if((t&(1<<k))==0)
			{
				g[id(t,2)].pb(id(t|(1<<k),2));
			}
		}
	}
	for(auto s:a)
	{
		g[id(li^s,2)].pb(id(s,1));
	}
	ms(vi);
	int cnt=0;
	for(auto s:a)
	{
		if(!vi[id(s,1)])
		{
			bfs(id(s,1));++cnt;
		}
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int INF=1e8;
const int maxn=(1<<22),mod=1000007;
const double eps = 1e-12;
const long double PI = acos(0.0) * 2.0;
int n,m;
int li;
inline int id(int i,int j)
{
	return i+(j-1)*li;
}
inline pair<int,int>reid(int x)
{
	return mp(x-x/li*li,x/li);
}
vector<int>g[maxn<<1];
vector<int>a;
bool vi[maxn<<1];
void bfs(int i)
{
	queue<int>q;q.push(i);vi[i]=1;
	while(!q.empty())
	{
		int c=q.front();q.pop();
		for(auto nx:g[c])
		{
			if(!vi[nx])vi[nx]=1,q.push(nx);
		}
		if(reid(c).second==1)
		{
			int r=reid(c).first;
			_for(t,0,n)
			{
				if(!(r&(1<<t)))
				{
					if(!vi[id(r|(1<<t),2)])
					{
						vi[id(r|(1<<t),2)]=1,q.push(id(r|(1<<t),2));
					}
				}
			}
		}
	}
}
int main()
{
	int r;
	fast;
	cin>>n>>m;
	if(n==0)
	{
		cout<<1;return 0;
	}
	li=(1<<n)-1;
	_for(t,0,m)
	{
		cin>>r;a.pb(r);
	}
	for(auto s:a)
	{
		g[id(s,1)].pb(id(s,2));
	}
	for(auto s:a)
	{
		g[id(li^s,2)].pb(id(s,1));
	}
	ms(vi);
	int cnt=0;
	for(auto s:a)
	{
		if(!vi[id(s,1)])
		{
			bfs(id(s,1));++cnt;
		}
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int INF=1e8;
const int maxn=(1<<22),mod=1000007;
const double eps = 1e-12;
const long double PI = acos(0.0) * 2.0;
int n,m;
int li;
inline int id(int i,int j)
{
	return i+(j-1)*li;
}
inline pair<int,int>reid(int x)
{
	return mp(x-x/li*li,x/li);
}
vector<int>g[maxn<<1];
vector<int>a;
bool vi[maxn<<1];
void bfs(int i)
{
	queue<int>q;q.push(i);vi[i]=1;
	while(!q.empty())
	{
		int c=q.front();q.pop();
		for(auto nx:g[c])
		{
			if(!vi[nx])vi[nx]=1,q.push(nx);
		}
		if(reid(c).second==1)
		{
			int r=reid(c).first;
			_for(t,0,n)
			{
				if(!(r&(1<<t)))
				{
					if(!vi[id(r|(1<<t),2)])
					{
						vi[id(r|(1<<t),2)]=1,q.push(id(r|(1<<t),2));
					}
				}
			}
		}
	}
}
int main()
{
	int r;
	fast;
	cin>>n>>m;
	li=(1<<n)-1;
	_for(t,0,m)
	{
		cin>>r;a.pb(r);
	}
	for(auto s:a)
	{
		g[id(s,1)].pb(id(s,2));
	}
	for(auto s:a)
	{
		g[id(li^s,2)].pb(id(s,1));
	}
	ms(vi);
	int cnt=0;
	for(auto s:a)
	{
		if(!vi[id(s,1)])
		{
			bfs(id(s,1));++cnt;
		}
	}
	cout<<cnt;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[(1<<22)],u,kq;
queue <int> q;
map <int,int> ts[23];
void Delete(int tt)
{
    int t=0;
    for(int i=m;i>=0;i--)
    {
        t+=((tt>>i)&1)*(1<<i);
        ts[i][t]--;
    }
}
void vet(int i,int tt)
{
    if(i<0) { q.push(tt); Delete(tt); return ; }
    for(int j=0;j<=1;j++)
    {
        if(j==1 && ((u>>i)&1)) continue;
        if(ts[i][tt+(1<<i)*j]>0) vet(i-1,tt+(1<<i)*j);
    }
}
void BFS(int tt)
{
    u=tt;
    q.push(u); Delete(u);
    while(!q.empty())
    {
        u=q.front(); q.pop();
        vet(m,0);
    }
}
int main()
{
    //freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>m>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        int t=0;
        for(j=m;j>=0;j--)
        {
            t+=((a[i]>>j)&1)*(1<<j);
            ts[j][t]++;
        }
    }
    for(i=1;i<=n;i++)
        if(ts[0][a[i]]>0)
        {
            BFS(a[i]);
            kq++;
        }
    cout<<kq;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[1000001],u,kq;
queue <int> q;
map <int,int> ts[23];
void Delete(int tt)
{
    int t=0;
    for(int i=m;i>=0;i--)
    {
        t+=((tt>>i)&1)*(1<<i);
        ts[i][t]--;
    }
}
void vet(int i,int tt)
{
    if(i<0) { q.push(tt); Delete(tt); return ; }
    for(int j=0;j<=1;j++)
    {
        if(j==1 && ((u>>i)&1)) continue;
        if(ts[i][tt+(1<<i)*j]>0) vet(i-1,tt+(1<<i)*j);
    }
}
void BFS(int tt)
{
    u=tt;
    q.push(u); Delete(u);
    while(!q.empty())
    {
        u=q.front(); q.pop();
        vet(m,0);
    }
}
int main()
{
    //freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>m>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        int t=0;
        for(j=m;j>=0;j--)
        {
            t+=((a[i]>>j)&1)*(1<<j);
            ts[j][t]++;
        }
    }
    for(i=1;i<=n;i++)
        if(ts[0][a[i]]>0)
        {
            BFS(a[i]);
            kq++;
        }
    cout<<kq;
}


#include <bits/stdc++.h>
using namespace std;
int ts[23][(1<<22)],n,m,i,j,a[1000001],u,kq;
queue <int> q;
void Delete(int tt)
{
    int t=0;
    for(int i=m;i>=0;i--)
    {
        t+=((tt>>i)&1)*(1<<i);
        ts[i][t]--;
    }
}
void vet(int i,int tt)
{
    if(i<0) { q.push(tt); Delete(tt); return ; }
    for(int j=0;j<=1;j++)
    {
        if(j==1 && ((u>>i)&1)) continue;
        if(ts[i][tt+(1<<i)*j]>0) vet(i-1,tt+(1<<i)*j);
    }
}
void BFS(int tt)
{
    u=tt;
    q.push(u); Delete(u);
    while(!q.empty())
    {
        u=q.front(); q.pop();
        vet(m,0);
    }
}
int main()
{
    //freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>m>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        int t=0;
        for(j=m;j>=0;j--)
        {
            t+=((a[i]>>j)&1)*(1<<j);
            ts[j][t]++;
        }
    }
    for(i=1;i<=n;i++)
        if(ts[0][a[i]]>0)
        {
            BFS(a[i]);
            kq++;
        }
    cout<<kq;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[(1<<22)+1],u,kq,d[(1<<22)+1];
queue <int> q;
struct trie
{
    int sl;
    trie *c[2];
};
trie *chen()
{
    trie *kq=new trie();
    kq->sl=0;
    kq->c[0]=kq->c[1]=NULL;
    return kq;
}
trie *node,*r;
void Delete(int tt)
{
    d[tt]=1;
    trie *node=r;
    for(int i=m-1;i>=0;i--)
    {
        int ch=(tt>>i)&1;
        node=node->c[ch];
        node->sl--;
    }
}
void vet(int i,int tt,trie *node)
{
    if(i<0) { q.push(tt); Delete(tt); return ; }
    for(int j=0;j<=1;j++)
    {
        if(j==1 && ((u>>i)&1)) continue;
        if(node->c[j]!=NULL && node->c[j]->sl>0) vet(i-1,tt+(1<<i)*j,node->c[j]);
    }
}
void BFS(int tt)
{
    u=tt;
    q.push(u); Delete(u);
    while(!q.empty())
    {
        u=q.front(); q.pop();
        vet(m-1,0,r);
    }
}
int main()
{
    //freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>m>>n;
    r=chen();
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        node=r;
        for(j=m-1;j>=0;j--)
        {
            int ch=(a[i]>>j)&1;
            if(node->c[ch]==NULL) node->c[ch]=chen();
            node=node->c[ch];
            node->sl++;
        }
    }
    for(i=1;i<=n;i++)
        if(d[a[i]]==0)
        {
            BFS(a[i]);
            kq++;
        }
    cout<<kq;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[(1<<22)+1],u,kq,d[(1<<22)+1];
queue <int> q;
struct trie
{
    int sl;
    trie *c[2];
};
trie *chen()
{
    trie *kq=new trie();
    kq->sl=0;
    kq->c[0]=kq->c[1]=NULL;
    return kq;
}
trie *node,*r;
void Delete(int tt)
{
    d[tt]=1;
    trie *node=r;
    for(int i=m-1;i>=0;i--)
    {
        int ch=(tt>>i)&1;
        node=node->c[ch];
        node->sl--;
    }
}
void vet(int i,int tt,trie *node)
{
    if(i<0) { q.push(tt); Delete(tt); return ; }
    for(int j=0;j<=1;j++)
    {
        if(j==1 && ((u>>i)&1)) continue;
        if(node->c[j]!=NULL && node->c[j]->sl>0) vet(i-1,tt+(1<<i)*j,node->c[j]);
    }
}
void BFS(int tt)
{
    u=tt;
    q.push(u); Delete(u);
    while(!q.empty())
    {
        u=q.front(); q.pop();
        vet(m-1,0,r);
    }
}
int main()
{
    //freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>m>>n; m++;
    r=chen();
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        node=r;
        for(j=m-1;j>=0;j--)
        {
            int ch=(a[i]>>j)&1;
            if(node->c[ch]==NULL) node->c[ch]=chen();
            node=node->c[ch];
            node->sl++;
        }
    }
    for(i=1;i<=n;i++)
        if(d[a[i]]==0)
        {
            BFS(a[i]);
            kq++;
        }
    cout<<kq;
}


#include<functional>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define md(x, y)  (x + y) / 2
#define ls(x)      x << 1
#define rs(x)      x << 1 | 1
#define fileopen freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout)
#define fileclose fclose(stdin); fclose(stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int MAXN = 5e6;
int n, m;
int pre[MAXN];
int loc[MAXN];
int a[MAXN];
int findRoot(int root)
{
    if(pre[root] == root)
        return root;
    return pre[root] = findRoot(pre[root]);
}
void dfs(int i, int u, int s)
{
    int ss = s + 1;
    while((u & (1 << ss)) == 0 && ss <= 30)
    {
        ss++;
    }
    if(ss > 24)
    {
        if(loc[u] != 0)                 //存在
        {
            int f1 = findRoot(i);
            int f2 = findRoot(loc[u]);
            if(f1 != f2)
            {
                pre[f1] = f2;
            }
        }
        return;
    }
    dfs(i, u & (~(1 << s)) ,ss);
    dfs(i, u, ss);
}
int main()
{
    while(scanf("%d%d", &n, &m) != EOF)
    {
        memset(loc, 0, sizeof loc);
        for(int i = 1; i <= m; i++) pre[i] = i;
        for(int i = 1; i <= m; i++)
        {
            scanf("%d", &a[i]);
            loc[a[i]] = i;          //位置，不存在则是0
        }
        for(int i = 1; i <= m; i++)
        {
            int temp = a[i];       //temp是a[i]的按位取反。
            //if(temp == 0)
              //  continue;           //没有子集。
            int s = 0;
            //1010
            int cnt = 0;
            int ret = 0;
            while(temp > 0)
            {
                cnt++;
                temp >>= 1;
                ret <<= 1;
                ret += 1;
            }
            temp = ~a[i] & ret;     //这才是正确的按位取反qaq
            if(temp == 0) continue;
            while((temp & (1 << s)) == 0)   //找到第一个1
            {
                s++;
            }

            //printf("a[i] = %d, s = %d\n",temp, s);
            dfs(i, temp, s);
        }
        int cnt = 0;
        for(int i = 1; i <= m; i++)
            if(pre[i] == i) cnt++;
        printf("%d\n", cnt);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define sort radix_sort(a,n)
int min(int p,int q)
{
    if(p>q) return q;
    else return p;
}
int max(int p,int q)
{
    if(p>q) return p;
    else return q;
}
typedef long long int ll;
  //n=inp();

void radix_sort(int a[], int n)
{
    int i, x[n+1], m = 0, exp = 1;
    for (i = 1; i <= n; i++)
        if (a[i] > m)
            m = a[i];
    while (m / exp > 0)
    {
        int box[10] = {0,0,0,0,0,0,0,0,0,0};
        for (i = 0; i < n; i++)
            box[a[i] / exp % 10]++;
        for (i = 1; i < 10; i++)
            box[i] += box[i - 1];
        for (i = n-1; i >= 0; i--)
        {
            x[--box[a[i] / exp % 10]] = a[i];
        }
        for (i = 0; i < n; i++)
        {
            a[i] = x[i];
        }
        exp *= 10;
    }
}
 int a[105][105];
int fun(n,m)
{
    int cnt=0,i,j;
     for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(a[i][j]==a[n-i+1][j])
            {
                cnt++;
            }
        }
    }
       if(cnt == (n*m))
       {
           return 1;
       }
       else
        return 0;
}
  //sort;
int main()
{
    int t,n,i,m,j,k;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        scanf("%d",&a[i][j]);int w=0,x;
        x=n;
   // while(x!=0)
    {
  //      x=x/2;
  //      w++;
    }
   // printf("w%d",w);
    if(n%2==0)
    {
       for(k=1;k<=x;k++)
       {
           t=fun(n,m);
           if(t==1)
                n=n/2;
            else
                break;
       }
    }
    printf("%d",n);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define sort radix_sort(a,n)
int min(int p,int q)
{
    if(p>q) return q;
    else return p;
}
int max(int p,int q)
{
    if(p>q) return p;
    else return q;
}
typedef long long int ll;
  //n=inp();

void radix_sort(int a[], int n)
{
    int i, x[n+1], m = 0, exp = 1;
    for (i = 1; i <= n; i++)
        if (a[i] > m)
            m = a[i];
    while (m / exp > 0)
    {
        int box[10] = {0,0,0,0,0,0,0,0,0,0};
        for (i = 0; i < n; i++)
            box[a[i] / exp % 10]++;
        for (i = 1; i < 10; i++)
            box[i] += box[i - 1];
        for (i = n-1; i >= 0; i--)
        {
            x[--box[a[i] / exp % 10]] = a[i];
        }
        for (i = 0; i < n; i++)
        {
            a[i] = x[i];
        }
        exp *= 10;
    }
}
 int a[105][105];
int fun(n,m)
{
    int cnt=0,i,j;
     for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(a[i][j]==a[n-i+1][j])
            {
                cnt++;
            }
        }
    }
       if(cnt == (n*m))
       {
           return 1;
       }
       else
        return 0;
}
  //sort;
int main()
{
    int t,n,i,m,j,k;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        scanf("%d",&a[i][j]);int w=0,x;
        x=n;
    while(x!=0)
    {
        x=x/2;
        w++;
    }
   // printf("w%d",w);
    while(n%2==0)
    {

           t=fun(n,m);
           if(t==1)
                n=n/2;
            else
                break;

    }
    printf("%d",n);
    return 0;
}


#include <stdio.h>

typedef int bool;
#define FALSE 0
#define TRUE 1

int a[100][100];

void readMatrix(int n, int m, int a[][100])
{
	int i, j;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &a[i][j]);
}

void writeMatrix(int n, int m, int a[][100])
{
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			printf("%d\t", a[i][j]);
		printf("\n");
	}
}

bool halvable(int a[][100], int n, int m)
{
	bool symmetric = n % 2 == 0;
	if (symmetric) {
		int i;
		for (i = 0; i < n / 2; i++) {
			int j = n - i - 1;
			if (!sameRow(a[i], a[j], m))
				symmetric = FALSE;

		}
	}
	return symmetric;
}

int rough(int a[][100], int n, int m)
{
	int n_;
	for (n_ = n; halvable(a, n_, m); n_ /= 2);
	return n_;
}

bool sameRow(int a[], int b[], int m)
{
	bool same = TRUE;
	int i;
	for (i = 0; i < m; i++)
		if (a[i] != b[i])
			same = FALSE;
	return same;
}

int main(void)
{
	int n, m;
	scanf("%d %d\n", &n, &m);
	readMatrix(n, m, a);
	// writeMatrix(n, m, a);
	int res = rough(a, n, m);
	printf("%d\n", res);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main ()
{
  int n, m, flag;
  scanf ("%i\n", &n);
  scanf ("%i\n", &m);
  int i, j;
  int *a = malloc (n * m * sizeof (int));

  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j)
      scanf("%i", a + i * m + j);

  while (n > 1)
  {
    flag = 1;
    if (n&1 == 1) break;
    for (i = 0; i < n/2; ++i)
      for (j = 0; j < m; ++j)
        if (a [i * m + j] != a[(n - i - 1) * m + j])
	{
	  flag = 0;
	  break;
	}
    if (!flag) break;
    else n = n/2;
  }

  printf ("%i\n", n);
  free (a);
  return 0;
}


#include <stdio.h>
int judge(int b[],int c[],int m)
{
  int i,ans=1;
  i=1;
  while(i<=m)
  {
  	if(b[i]!=c[i])
	{
		ans=0;
		break;
	}
	i++;
  }
  return ans;
}
int main(void)
{
	int n,m,a[105][105],i,j,ans;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	for(j=1;j<=m;j++)
	scanf("%d",&a[i][j]);
	if(n%2!=0)
	ans=n;
	else
	{
	 for(ans=n;n%2==0;n/=2)
	 {
	  for(j=n,i=1;i<=n/2;i++,j--)
	  if(!judge(a[i],a[j],m))
	  break;
	  if(i<=n/2)
	  break;
	  else
	  ans=n/2;
	 }
	}
	printf("%d\n",ans);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int a[200][200];
int cmp(int n,int m)
{
    int i,j,k;
    if(n%2==1)
        return n;
    for(i=0;i<=n/2-1;i++)
    {
        for(j=0;j<m;j++)
        {
            if(a[i][j]!=a[n-1-i][j])
                return n;
        }
    }
    cmp(n/2,m);
}
main()
{
    int n,m,i,j;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    printf("%d\n",cmp(n,m));
    return 0;
}


#include<stdio.h>
int get_min(int a[100][100] , int n , int m){
  if(n % 2 == 1) return n;
  if(n == 1) return 1;
  int i,j,min  = 0;
  for(i=0;i<n/2 ; i++){
    for(j=0;j<m;j++){
        if(a[i][j] != a[n-i-1][j]) return n;
    }
  }
  return get_min(a,n/2,m);
}
int main(){
    int n,m,min,i,j;
    scanf("%d %d",&n,&m);
    int a[100][100];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    min = get_min(a,n,m);
    printf("%d\n",min);
 return 0;
}


#include<stdio.h>
int m,a[101][101]={0};
int check(int x){
	int j,i;
	for(i=1;i<=x/2;i++)
		for(j=1;j<=m;j++)
			if(a[i][j] != a[x-i+1][j]){
//				printf("%d %d %d %d %d\n",i,x-i+1,j,a[i][j],a[x-i+1][j]);
				return 0;
			}
	return 1;
}
int main(){
	int i,k,j,l,n,tmp;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	tmp = n;
	while(1)
		if(tmp%2==1)
			break;
		else
			if(check(tmp) == 1)
				tmp = tmp/2;
			else
				break;
	printf("%d\n",tmp);
	return 0;
}


#include <stdio.h>
char s[200][400];
int main()
{
    int n,m,ans,i,flag=1;
    scanf("%d%d",&n,&m);
getchar();
    if(n%2==0)
    {
        for(i=0; i<n/2; i++)
        {
            scanf("%[^\n]s",s[i]);
            getchar();
        }
        for(; i<n; i++)
        {
            scanf("%[^\n]s",s[i]);
            getchar();
            if(strcmp(s[i],s[n-i-1]))
            {
                flag=0;
                break;
            }
        }

        for(i++; i<n; i++)
        {
            scanf("%[^\n]s",s[0]);
            getchar();
        }
        if(flag)
        {

            ans=n;
            n/=2;
            while(n%2==0&&flag)
            {
                for(i=0; i<n/2; i++)
                    if(strcmp(s[i],s[n-i-1]))
                    {

                        flag=0;
                        break;
                    }
        if(flag)
                  ans=n;
                n/=2;
            }
            printf("%d\n",ans/2);
        }
        else
        {
            printf("%d\n",n);
        }
    }
    else
        printf("%d\n",n);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define MAX 100

int mat[MAX][MAX];

int mirror(int mat[MAX][MAX],int n,int m){
  if(n==1){
  	return 1;
  }
  if(n%2==0){
    for(int i=0;i<n;i++){
  	 for(int j=0;j<m;j++){
  	   	if(!(mat[i][j]==mat[n-i-1][j])){
  		  	return n;
  		  }
    	}
    }
    return mirror(mat,n/2,m);
  }else return n;
}

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%d",&mat[i][j]);
		}
	}
	int num=mirror(mat,n,m);
	printf("%d\n",num);
}


#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

int main()	{

int n,m,i,j,k;
bool **mat;
int f,size;

scanf("%d %d",&n,&m);

mat=(bool**)malloc(sizeof(bool*)*n);

for(i=0;i<n;i++)	{
	mat[i]=(bool*)malloc(sizeof(bool)*m);
}

for(i=0;i<n;i++)	{
	for(j=0;j<m;j++)	{
		scanf("%d",&mat[i][j]);
	}
}

i=0;
f=0;
size=n;

while(!f)		{

k=n-1;

if( (k-i) %2 ==0)	{
	f=1;
}

while(i<k && !f)	{

for(j=0;j<m;j++)	{
if(mat[i][j]==mat[k][j])
continue;
else break;
}
if(j==m)	{
	i++;k--;
}
else 	f=1;

}

if(!f)
size=size/2;

}
printf("%d\n",size);

return 0;
}


#include<stdio.h>
int main()
{
    int flag,mat[110][110],n,m,i,j,k;
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        flag=1;
        for(i=0;i<n;i++)
        for(j=0;j<m;j++)
        scanf("%d",&mat[i][j]);
        if(n%2) printf("%d\n",n);
        else
        {
            while(n%2!=1)
            {for(i=0;i<n/2;i++)
            for(j=0;j<m;j++)
            if(mat[i][j]!=mat[n-1-i][j])
            {flag=0;goto loop;}
            loop:
            if(flag==0)
            break;
            else
            n=n/2;
            }
            printf("%d\n",n);
        }
    }
    return 0;
}


#include <stdio.h>

#define N 101

int arr[N][N] = {0};

void Swap(int *x, int *y)
{
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

int IsSymetric(int n, int m)
{
	int i, j;
	int i1;

	if (n % 2 != 0)
		return 0;

	i1 = n - 1;

	for (i = 0; i < n/2; ++i, --i1)
	{
		for (j = 0; j < m; ++j)
		{
			if (arr[i][j] != arr[i1][j])
				return 0;
		}
	}

	return 1;
}
int main(void)
{
	int i, j;
	int n, m;
	int tmp;

	scanf("%i %i", &n, &m);

	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < m; ++j)
		{
			scanf("%i", &tmp);
			arr[i][j] = tmp;
		}
	}

	while (IsSymetric(n, m))
	{
		n /= 2;
	}

	printf("%i\n", n);

	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{ int n,m,i,j,k;

    scanf("%d%d",&n,&m);
    int sum[n];
    for(i=0;i<n;i++)
    sum[i]=0;
    if(n%2==1)
    {
        printf("%d",n);

        return 0;
    }
    int arr[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {   scanf("%d",&arr[i][j]);
            sum[i]+=pow(2,m-j-1)*arr[i][j];

        }
    }
    for(k=1;k<=n/2;k*=2)
    {

for(i=0;i<n/k;i++)

{
    if(sum[i]!=sum[n/k-1-i])
    {printf("%d",(n/k));
     return 0;
    }
}

    }
    printf("1");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{ int n,m,i,j,k;

    scanf("%d%d",&n,&m);
    int sum[n];
    for(i=0;i<n;i++)
    sum[i]=0;
    if(n%2==1)
    {
        printf("%d",n);

        return 0;
    }
    int arr[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {   scanf("%d",&arr[i][j]);
            sum[i]+=pow(2,m-j-1)*arr[i][j];

        }
    }
    for(k=1;k<=n/2;k*=2)
    {

for(i=0;i<n/k;i++)

{
    if(sum[i]!=sum[n/k-1-i])
    {printf("%d\n",(n/k));
     return 0;
    }
}

    }
    while(n%2==0)
    n/=2;
    printf("%d",n);
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{ int n,m,i,j,k;

    scanf("%d%d",&n,&m);
    int sum[n];
    for(i=0;i<n;i++)
    sum[i]=0;
    if(n%2==1)
    {
        printf("%d",n);

        return 0;
    }
    int arr[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {   scanf("%d",&arr[i][j]);
            sum[i]+=pow(2,m-j-1)*arr[i][j];

        }
    }
    for(k=1;k<=n/2;k*=2)
    {

for(i=0;i<n/k;i++)
{
    if(sum[i]!=sum[n/k-1-i])
    {printf("%d",(n/k));
     return 0;
    }
}

    }
    printf("1");
    return 0;
}


#include <stdio.h>

int main(void)
{
	int a[100][100];
	int i,j,n,m,flag=0,min=0,k;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
			scanf("%d",&a[i][j]);
	}
	if(n%2!=0)
		printf("%d",n);
	else
	{
		i=n-1;
		while(i>0)
		{
			for(k=0;k<n/2;k++)
			{
				for(j=0;j<m;j++)
				if(a[k][j]==a[i-k][j])
					flag=1;
				else
					break;
				if(flag==1)
				{
					min=i+1;
					i=(i-1)/2;
					flag=0;
				}
				else
				{
					printf("%d",min/2);
					break;
				}
			}

		}
	}
	return 0;
}


#include <stdio.h>

int main(void)
{
	int a[100][100];
	int i,j,n,m,flag=0,min=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
			scanf("%d",&a[i][j]);
	}
	if(n%2!=0)
		printf("%d",n);
	else
	{
		i=n-1;
		while(i>0)
		{
			for(j=0;j<m;j++)
				if(a[0][j]==a[i][j])
					flag=1;
				else
					break;
			if(flag==1)
			{
				min=i+1;
				i=(i-1)/2;
				flag=0;
			}
			else
			{
				printf("%d",min/2);
				break;
			}
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>

int jg(int n,char s[][105])
{
    int i,j;
    int flag=0;
    for(i=1,j=n;i<=n;i++,j--)
             {
                 if(strcmp(s[i],s[j])!=0)
                 {
                     flag=1;
                 }
             }
             if(flag==1) return 0;
       else
     return 1;
}

int main()
{
    char s[105][105];
    int i,flag;
    int n,m,t;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        getchar();
        flag=0;
        t=1;
        for(i=1;i<=n;i++)
            {
                gets(s[i]);
            }
        if(n%2==1)
            printf("%d\n",n);
        else
        {
            while(jg(n,s)==1)
            {
                n=n/2;
                if(n%2==1)
                    break;
            }

         printf("%d\n",n);
        }

    }
    return 0;
}


#include<stdio.h>
#include<string.h>

int jg(int n,char s[][105])
{
    int i,j;
    int flag=0;
    for(i=1,j=n;i<=n;i++,j--)
             {
                 if(strcmp(s[i],s[j])!=0)
                 {
                     flag=1;
                 }
             }
             if(flag==1) return 0;
       else
     return 1;
}

int main()
{
    char s[105][105];
    int i,flag;
    int n,m,t;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(s,0,sizeof(s));
        getchar();
        flag=0;
        t=1;
        for(i=1;i<=n;i++)
            {
                gets(s[i]);
            }
        if(n%2==1)
            printf("%d\n",n);
        else
        {
            while(jg(n,s)==1)
            {
                n=n/2;
                if(n%2==1)
                    break;
            }

         printf("%d\n",n);
        }

    }
    return 0;
}


#include<stdio.h>
#include<string.h>

int jg(int n,char s[][205])
{
    int i,j;
    int flag=0;
    for(i=1,j=n;i<=n;i++,j--)
             {
                 if(strcmp(s[i],s[j])!=0)
                 {
                     flag=1;

                 }
             }
             if(flag==1) return 0;
       else
     return 1;
}

int main()
{
    char s[105][205];
    int i,flag;
    int n,m,t;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(s,0,sizeof(s));
        getchar();
        flag=0;
        t=1;
        for(i=1;i<=n;i++)
            {
                gets(s[i]);
            }
        if(n%2==1)
            printf("%d\n",n);
        else
        {
            while(jg(n,s)==1)
            {
                n=n/2;
                if(n%2==1)
                    break;
            }

         printf("%d\n",n);
        }

    }
    return 0;
}


#include<stdio.h>
#include<string.h>

int jg(int n,char s[][105])
{
    int i,j;
    int flag=0;
    for(i=1,j=n;i<=n;i++,j--)
             {
                 if(strcmp(s[i],s[j])!=0)
                 {
                     flag=1;
                 }
             }
             if(flag==1) return 0;
       else
     return 1;
}

int main()
{
    char s[105][105];
    int i,flag;
    int n,m,t;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        getchar();
        flag=0;
        t=1;
        for(i=1;i<=n;i++)
            {
                gets(s[i]);
            }
        if(n%2==1)
            printf("%d\n",n);
        else
        {
            while(jg(n,s)==1)
            {
                n=n/2;
                if(n==1)
                    break;
            }

         printf("%d\n",n);
        }

    }
    return 0;
}


#include<stdio.h>
#include<string.h>

int jg(int n,char s[][205])
{
    int i,j;
    int flag=0;
    for(i=1,j=n;i<=n;i++,j--)
             {
                 if(strcmp(s[i],s[j])!=0)
                 {
                     flag=1;
                     printf("%d:%s %d:%s\n",i,s[i],j,s[j]);
                 }
             }
             if(flag==1) return 0;
       else
     return 1;
}

int main()
{
    char s[105][205];
    int i,flag;
    int n,m,t;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(s,0,sizeof(s));
        getchar();
        flag=0;
        t=1;
        for(i=1;i<=n;i++)
            {
                gets(s[i]);
            }
        if(n%2==1)
            printf("%d\n",n);
        else
        {
            while(jg(n,s)==1)
            {
                n=n/2;
                if(n%2==1)
                    break;
            }

         printf("%d\n",n);
        }

    }
    return 0;
}


#include<stdio.h>
#include<string.h>

int jg(int n,char s[][105])
{
    int i,j;

    for(i=1;i<=n/2;i++)
             for(j=n/2;j>=1;j--)
             {
                 if(strcmp(s[i],s[j])!=0)
                     return 0;
             }
            return 1;
}

int main()
{
    char s[105][105];
    int num[105][105];
    int i,j;
    int n,m,t;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        getchar();
        t=1;
        for(i=1;i<=n;i++)
            {
                gets(s[i]);
            }
        if(n%2==1)
            printf("%d\n",n);
        else
        {
            while(jg(n,s)==0)
                n=n/2;

         printf("%d\n",n);
        }

    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

int main( void ) {
     int n, m;
     char mi[100][110];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          fgets(mi[i], 100, stdin);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     for( i = 1; i < n; i++ )
          if( strcmp(mi[i], mi[0]) ) break;

     if( i == n ) {
          int k = 1;

          for( k = 1; k <= 10; k++ )
               if( pow(2,k) == n ) {
                     printf("1\n");
                     return 0;
               }
     }

     while( (n % 2) == 0 ) {

          for( i = 0, j = n-1; i < j; i++, j-- )
               if( strcmp(mi[i], mi[j]) ) {
                    printf("%i\n", n);
                    return 0;
               }

          n /= 2;
     }

     printf("%i\n", n);

     return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

int main( void ) {
     int n, m;
     char mi[100][110];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          gets(mi[i]);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     for( i = 1; i < n; i++ )
          if( strcmp(mi[i], mi[0]) ) break;

     if( i == n ) {
          int k = 1;

          for( k = 1; k <= 10; k++ )
               if( pow(2,k) == n ) {
                     printf("1\n");
                     return 0;
               }
     }

     while( (n % 2) == 0 ) {

          for( i = 0, j = n-1; i < j; i++, j-- )
               if( strcmp(mi[i], mi[j]) ) {
                    printf("%i\n", n);
                    return 0;
               }

          n /= 2;
     }

     printf("%i\n", n);

     return 0;
}


#include <stdio.h>
#include <string.h>

int main( void ) {
     int n, m;
     char mi[100][110];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          gets(mi[i]);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     while( n%2 == 0 ) {

        int flag = 0;
        for( i = 0, j = n-1; i < j; i++, j-- )
          if( strcmp(mi[i], mi[j]) ) {
               break;
               flag = 1;
          }

          if( flag ) break;

          n /= 2;
     }

     printf("%i\n", n*2);

     return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

int main( void ) {
     int n, m;
     char mi[100][1100];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          fgets(mi[i], 1000, stdin);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     for( i = 1; i < n; i++ )
          if( strcmp(mi[i], mi[0]) ) break;

     if( i == n ) {
          int k = 1;

          for( k = 1; k <= 10; k++ )
               if( pow(2,k) == n ) {
                     printf("1\n");
                     return 0;
               }
     }

     while( (n % 2) == 0 ) {

          for( i = 0, j = n-1; i < j; i++, j-- )
               if( strcmp(mi[i], mi[j]) ) {
                    printf("%i\n", n);
                    return 0;
               }

          n /= 2;
     }

     printf("%i\n", n);

     return 0;
}


#include <stdio.h>
#include <string.h>

int main( void ) {
     int n, m;
     char mi[100][110];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          gets(mi[i]);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     while( 1 ) {

        for( i = 0, j = n-1; i < j; i++, j-- )
          if( strcmp(mi[i], mi[j]) ) {
              printf("%i\n", n);
              return 0;
          }

          n /= 2;

          if( n == 0 ) {
               printf("1\n");
               return 0;
          }

          if( n == 1 ) continue;
          else if( n%2 ==1 ) break;
     }

     printf("%i\n", n*2);

     return 0;
}


#include <stdio.h>
#include <string.h>

int main( void ) {
     int n, m;
     char mi[100][110];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          gets(mi[i]);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     for( i = 1; i < n; i++ )
          if( strcmp(mi[i], mi[0]) ) break;

     if( i == n ) {
          printf("1\n");
          return 0;
     }

     while( (n % 2) == 0 ) {

          for( i = 0, j = n-1; i < j; i++, j-- )
               if( strcmp(mi[i], mi[j]) ) {
                    printf("%i\n", n);
                    return 0;
               }

          n /= 2;
     }

     printf("%i\n", n*2);

     return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

int main( void ) {
     int n, m;
     char mi[100][1100];

     scanf("%i %i\n", &n, &m);

     int i, j;
     for( i = 0; i < n; i++ )
          fgets(mi[i], 100, stdin);

     if( (n%2) == 1 ) {
          printf("%i\n", n);
          return 0;
     }

     for( i = 1; i < n; i++ )
          if( strcmp(mi[i], mi[0]) ) break;

     if( i == n ) {
          int k = 1;

          for( k = 1; k <= 10; k++ )
               if( pow(2,k) == n ) {
                     printf("1\n");
                     return 0;
               }
     }

     while( (n % 2) == 0 ) {

          for( i = 0, j = n-1; i < j; i++, j-- )
               if( strcmp(mi[i], mi[j]) ) {
                    printf("%i\n", n);
                    return 0;
               }

          n /= 2;
     }

     printf("%i\n", n);

     return 0;
}


#include <stdio.h>

int divideMat(int mat[200][200],int n,int m){
	int i,j;
	for(i=0;i<n/2;i++){
		for(j=0;j<m;j++){
			if(mat[i][j] == mat[n-1-i][j]){
				return divideMat(mat,n/2,m);
			}
			else return n;
		}
	}
}
int main(){
	int m,n;
	int i,j,min;
	int mat[200][200];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++)
			scanf("%d",&mat[i][j]);
	}

	if(n%2 != 0) printf("%d\n",n);
	else {min = divideMat(mat,n,m); printf("%d\n",min);}
	return 0;
}


#include <stdio.h>

int divideMat(int mat[200][200],int n,int m){
	int i,j;
	if(n%2 != 0) return n;

	for(i=0;i<n/2;i++){
		for(j=0;j<m;j++){
			if(mat[i][j] == mat[n-1-i][j]){
				return divideMat(mat,n/2,m);
			}
			else return n;
		}
	}
}
int main(){
	int m,n;
	int i,j,min;
	int mat[200][200];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++)
			scanf("%d",&mat[i][j]);
	}

	min = divideMat(mat,n,m);
    printf("%d\n",min);
	return 0;
}


#include <stdio.h>

int divideMat(int mat[200][200],int n,int m){
	int i,j;
	int igual = 1;
	if(n%2 != 0) return n;

	for(i=0;i<n/2;i++){
		for(j=0;j<m;j++){
			if(mat[i][j] == mat[n-1-i][j] && igual) igual =1;
			else igual=0;
		}
	}
	if(igual)return divideMat(mat,n/2,m);
	else return n;
}
int main(){
	int m,n;
	int i,j,min;
	int mat[200][200];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++)
			scanf("%d",&mat[i][j]);
	}

	min = divideMat(mat,n,m);
    printf("%d\n",min);
	return 0;
}


#include <stdio.h>

#define N	100

int main() {
	static int aa[N][N];
	int n, m, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &aa[i][j]);
	while (n % 2 == 0) {
		int i1, i2, good;

		good = 1;
		for (i1 = n / 2 - 1, i2 = n / 2; i1 >= 0 && i2 < n; i1--, i2++)
			for (j = 0; j < m; j++)
				if (aa[i1][j] != aa[i2][j]) {
					good = 0;
					break;
				}
		if (!good)
			break;
		n /= 2;
	}
	printf("%d\n", n);
	return 0;
}


#include <stdio.h>

#define N	100

int equal(int *aa, int *bb, int n) {
	int i;

	for (i = 0; i < n; i++)
		if (aa[i] != bb[i])
			return 0;
	return 1;
}

int solve(int aa[][N], int n, int m) {
	int i, j;

	if (n % 2 == 1)
		return n;
	for (i = 0, j = n - 1; i < j; i++, j--)
		if (!equal(aa[i], aa[j], m))
			return n;
	return solve(aa, n / 2, m);
}

int main() {
	static int aa[N][N];
	int n, m, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &aa[i][j]);
	printf("%d\n", solve(aa, n, m));
	return 0;
}


#include <stdio.h>

int mirror_check_and_return(int arr[][101],int n,int m)
{
    int arr2[101][101];
    int i,j;
    if(n%2==1)
        return n;
    for(i=0;i<n/2;i++)
    {
        for(j=0;j<m;j++)
        {
            arr2[i][j]=arr[i][j];
            if(arr[i][j]!=arr[n-1-i][j])
                return n;
        }

    }
    return mirror_check_and_return(arr2,n/2,m);

}

int main(void) {
    int i,j,n,m,arr[101][101];
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            scanf("%d",&arr[i][j]);
    printf("%d",mirror_check_and_return(arr,n,m));

    return 0;
}


#include<stdio.h>

int main(){
	int n,m,i,j,k,f=0,min,mitad;
	int v[100][100];
	scanf("%d%d",&n,&m);
	min = n;
	for(i=0 ; i<n ;i++)
		for(j=0 ; j<m ; j++)
			scanf("%d",&v[i][j]);
	if(n%2!=0)	printf("%d",min);
	else{
		mitad = n;
		while( mitad%2==0 ){
			mitad = mitad/2;
			for(i=0,k=2*mitad-1 ; i<mitad ; i++,k--)
				for(j=0 ; j<m ; j++)
					if( v[i][j]!=v[k][j] )	f=1;
			if( f==0 )	min = mitad;
			else break;
		}
		printf("%d",min);
	}
	return 0;
}


#include <stdio.h>

int mat[105][105];

int main(void) {
    int n, m;
    int i, j;
    int p;
    int mid;
    int sim;

    scanf(" %d %d", &n, &m);

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf(" %d", &mat[i][j]);
        }
    }

    while(n % 2 == 0) {
        mid = n / 2;
        sim = 1;
        for (i = 0, p = n - 1; i < mid; i++, p--) {
            for (j = 0; j < m; j++) {
                if (mat[i][j] != mat[p][j]) {
                    sim = 0;
                    i = mid;
                    break;
                }
            }
        }
        if (sim == 0) {
            break;
        } else {
            n = n / 2;
        }
    }
    printf("%d\n", n);
    return 0;
}


#include <string.h>
#include <ctype.h>
int main()
{
    int m,n,i,j;
    scanf("%d %d",&m,&n);
    char arr[100][1000];
    getchar();
    for(i=0;i<m;i++)
    {

        gets(arr[i]);
    }
    while(m%2==0)
    {
        int st=0,en=m-1;
        for(st=0;st<(m/2);st++)
        {
            if(strcmp(arr[st],arr[en])!=0)
            {
                printf("%d",m);
                return 0;
            }
            en--;
        }
        m=m/2;
    }
    printf("%d",m);

    return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#define N 102

int mx[N][N];
int n,m;

int check(int pos){
	int u = 0, v = pos-1;
	while(u < v){
		for(int j = 0; j < m; j ++){
			if(mx[u][j] != mx[v][j]) return 0;
		}
		u++; v--;
	}
	return 1;
}

int go(int pos){
	if(pos%2 == 1) return pos;
	else{
		if(check(pos)) return go(pos/2);
		else return pos;
	}
}

int main(){
	 scanf("%d %d",&n,&m);
	for(int i = 0; i < n; i ++){
		for(int j = 0 ; j < m; j ++){
			scanf("%d",&mx[i][j]);
		}
	}
	int res = go(n);
	printf("%d\n",res);
	return 0;
}


#include <stdio.h>

int main(void) {
    int n,m,i,j,k,l,x,a[105][105],b[500],out,tmp,flag,flag1,flag2;
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    flag=0;out=n;
    while(1)
    {
        if(out%2==0)
        {
            for(i=1;i<=out/2;i++)
            {
                for(j=1;j<=m;j++)
                {
                    if(a[i][j]!=a[out+1-i][j])
                    flag=1;
                }
            }
            if(flag==1)
            break;
            else
            out=out/2;
        }
        else
        break;
    }
    printf("%d\n",out);
    return 0;
}


#include<stdio.h>
int a[100][100],b[100][100],c[100][100];
int main()
{
	int n,m,i,j,line,temp=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			scanf("%d",&a[i][j]);
	line=n;
	while(!(line%2))
	{
		for(i=0;i<line/2;i++)
			for(j=0;j<m;j++)
				if(a[i][j]!=a[line-1-i][j])
					temp++;
		if(temp)
			break;
		else
			line/=2;
		temp =0;
	}
	printf("%d\n",line);
return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define MAX 120
int main()
{
    int n,m,i,j,r,flag;
    int a[MAX][MAX];
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
        scanf("%d",&a[i][j]);
    r=n;
    while(1)
    {

        if(r%2)break;
        r/=2;
        flag=0;
        for(i=0;i<r;i++)
        {
            for(j=0;j<m;j++)
              if(a[i][j]!=a[2*r-1-i][j]){
                    flag=1;
                    break;
              }
            if(flag)break;
        }

        if(flag){
                r*=2;
                break;
        }
    }
    printf("%d\n",r);
    return 0;
}