#include <iostream>
#include <fstream>
#include <vector>
#include <set>
using namespace std;
#define MAX_N 22 #define MAX_VAL 22
ifstream fin("shut.in");
int N; vector<int> choices[MAX_VAL+1];
bool unmarked(int code, int p) {
return (code & (1 << (p-1))) > 0; }
bool legal(int code, int turn) {
return ((code & turn) == turn); }
int markPiece(int code, int p) {
return code | (1 << (p-1)); }
int reduce(int code, int turn) {
return (code ^ turn); }
int numMarked(int code) {
int total(0);
for (int p=1; p <= N; p++)
if (!unmarked(code,p))
total++;
return total;
}
int pegSum(int code) {
int total(0);
for (int p=1; p <= N; p++)
if (unmarked(code,p))
total += p;
return total;
}
void initChoices() {
int half = MAX_VAL / 2;
int halfcode = 1 << half;
for (int code = 0; code < halfcode; code++) {
int total = pegSum(code);
if (total <= MAX_VAL) {
choices[total].push_back(code);
for (int p = half+1; p <= MAX_VAL; p++) {
if (total + p <= MAX_VAL)
choices[total+p].push_back(markPiece(code,p));
else
break;
}
}
}
}
int main() {
int game(1);
N = MAX_N; initChoices();
while (true) {
int T;
vector<int> turns;
fin >> N >> T;
if (N == 0) break;
for (int k=0; k < T; k++) {
int temp;
fin >> temp;
turns.push_back(temp);
}
set<int> reachable;
int initial = (1 << N) - 1; int mostMarked(0);
reachable.insert(initial);
for (int t=0; t < T; t++) {
int turn = turns[t];
set<int> newReach;
for (set<int>::const_iterator it = reachable.begin(); it != reachable.end(); ++it) {
int curCode = *it;
for (int k = 0; k < choices[turn].size(); k++) {
int subset = choices[turn][k];
if (legal(curCode,subset)) {
int newCode = reduce(curCode,subset);
newReach.insert(newCode);
int score = numMarked(newCode);
if (score > mostMarked)
mostMarked = score;
}
}
}
reachable = newReach;
if (reachable.size() == 0) break; }
cout << "Game " << game++ << ": " << mostMarked << endl;
}
}