import std.algorithm, std.array, std.container, std.conv, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void main()
{
  foreach (casenum ; 1 .. readln.strip.to!int + 1) {
    long n, k, x;
    readf!" %d %d %d "(n, k, x);
    auto s = readln.strip;
    x--;
    string[] ans;
    foreach_reverse (chunk ; s.split('a')) {
      auto cnt = x % (chunk.length * k + 1);
      x /= (chunk.length * k + 1);
      ans ~= replicate("b", cast(size_t)cnt);
    }
    writeln(ans.retro.join('a'));
  }
}

immutable multi = true;

uint n, k;
ulong x;
byte[] s;

void readInput()
{
  n = readInt!uint;
  k = readInt!uint;
  x = readInt!ulong;
  s = cast(byte[]) readString;
  debug writeln("read string ", s);
}

void genInput()
{
  import std.random;
  foreach(i; 0 .. 100) s ~= "*a"[0];
  n = cast(uint) s.length;
  k = 0;
  x = 1;
  debug writeln("generated ", cast(string)s);
}
alias input = readInput;

void solve(int tc)
{
  debug writeln("called solve with ", tc, " ", s);
  uint[] groups;
  bool open = false;
  foreach(si; s)
    {
      debug writeln("in char ", si);
      final switch(si)
	{
	case '*':
	  if (open)
	    {
	      groups[$-1]++;
	    }
	  else
	    {
	      groups ~= 1;
	    }
	  open = true;
	  break;
	case 'a':
	  open = false;
	  break;
	}
    }
  debug writeln("groups ", groups);
  foreach(ref gi; groups)
    {
      gi = k * gi + 1;
    }
  import std.experimental.checkedint;
  auto order = new ulong[](groups.length);
  Checked!(ulong, Saturate) prevOrder = ulong(1);
  foreach_reverse(i; 0 .. order.length)
    {
      order[i] = (prevOrder * groups[i]).get;
      prevOrder = order[i];
    }
  auto digits = new long[](groups.length);
  void fillDigits(uint i, ulong xth)
  {
    if (i+1 == digits.length)
      {
	digits[i] = xth;
	return;
      }
    digits[i] = xth / order[i + 1];
    xth = xth % order[i + 1];
    fillDigits(i + 1, xth);
  }
  if (digits) fillDigits(0, x - 1);
  int currentGroup = 0;
  byte[] ans;
  open = false;
  foreach(si; s)
    {
      final switch(si)
	{
	case '*':
	  if (!open)
	    {
	      foreach(i; 0 .. digits[currentGroup])
		ans ~= 'b';
	      open = true;
	      currentGroup++;
	    }
	  break;
	case 'a':
	  open = false;
	  ans ~= 'a';
	  break;
	}
    }
  writeln(cast(string)ans);
}

// main {{{
void main()
{
	auto t = multi? readInt!int : 1;
	foreach(tc; 0 .. t)
	  {
	    input();
	    solve(tc);
	  }
}
// }}}
// input {{{
int currChar;
static this()
{
	currChar = ' ';
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	import core.stdc.stdio;
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
void writes(T...)(T t)
{
	static foreach(i, ti; t)
	{
		static if (isIterable!(T[i]))
		{
			foreach(e; ti)
			{
				write(e, " ");
			}
		}
	}
}
auto ra(V)()
{
	int n = readInt!int;
	return ma(n, readInt!V);
}
auto rt(V)()
{
	int n = readInt!int;
	int m = readInt!int;
	return ma(n, ma(m, readInt!V));
}
auto rbg()
{
	int n = readInt!int;
	int m = readInt!int;
	auto adj = new int[][](n);
	foreach(i; 0 .. m)
	{
		auto u = readInt!int - 1;
		auto v = readInt!int - 1;
		adj[u] ~= v;
		adj[v] ~= u;
	}
	return adj;
}
auto ma(V)(size_t n, lazy V v)
{
	auto arr = new V[](n);
	foreach(ref ai; arr) ai = v;
	return arr;
}
// }}}
// imports {{{
import std.stdio;
import std.algorithm;
import std.typecons;
import std.math;
import std.numeric;
import std.container;
import std.range;
import std.array;
import std.ascii;
// }}}

import std.stdio;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import core.stdc.stdio : scanf;
import std.conv;
import std.array;
import std.string;
import std.range;
import std.algorithm;

T read(T)() { return readln.chomp.to!T; }
T[] readarray(T)() { return readln.chomp.split(" ").map!(to!T).array; }

enum long INF = 1L<<60;

void solve() {
    int N, K; long X; scanf("%d %d %lld\n", &N, &K, &X);
    X--;
    auto S = readln.strip;

    long[] M; {
        bool prev = false;
        for (int i = 0; i < N; i++) {
            if (S[i] == '*') {
                if (prev) { M.back += K; }
                else {
                    M ~= K + 1;
                }
                prev = true;
            } else {
                prev = false;
            }
        }
    }

    int m = cast(int)(M.length);
    auto Y = new long[m];
    for (int i = m - 1; i >= 0; i--) {
        Y[i] = X % M[i];
        X /= M[i];
    }

    char[] ans; {
        int j = 0;
        bool prev = false;
        for (int i = 0; i < N; i++) {
            if (S[i] == '*') {
                if (prev) {
                    // do nothing
                } else {
                    foreach (_; 0 .. Y[j]) {
                        ans ~= 'b';
                    }
                    j++;
                }
                prev = true;
            } else {
                ans ~= 'a';
                prev = false;
            }
        }
        assert(j == m);
    }
    writeln(ans);
}

void main() {
    int T = read!int;
    foreach (t; 0 .. T) solve();
}

import std;

int[]
genStars (in string s) {
    int[] ret = [0];

    foreach (c; s)
        if (c == '*')
            ++ ret[$ -  1];
        else if (c == 'a' && ret[$ - 1] != 0)
            ret ~= 0;

    if (ret[$ - 1] == 0)
        ret = ret[0 .. $ - 1];

    return ret;
}

void
solve () {
    int n, k;
    ulong x;
    string s;

    readf("%s %s %s\n", n, k, x);
    s = readln()[0 .. $ - 1];
    -- x;

    int[] stars = genStars(s);
    if (stars.length == 0) {
        writeln(s);
        return;
    }

    stars[] = stars[] * k + 1;

    size_t index = stars.length;
    real product = 1;

    while (product <= x) {
        -- index;
        product *= stars[index];
    }

    uint[] ans = new uint[stars.length];

    while (x != 0) {
        ulong prefix = cast(ulong)(product / stars[index]);
        ans[index] = cast(uint)(x / prefix);
        x %= prefix;
        product = prefix;
        ++ index;
    }

    index = 0;
    for (size_t i = 0; i != s.length; ++ i) {
        if (s[i] == 'a')
            write('a');
        else {
            while (i != s.length && s[i] == '*')
                ++ i;
            -- i;
            write('b'.repeat(ans[index]));
            ++ index;
        }
    }
    writeln();
}

void main () {
    int t;
    readf("%s\n", t);

    foreach (__sth; 0 .. t) {
        solve();
    }
}

// ""

import std;

int[]
genStars (in string s) {
    int[] ret = [0];

    foreach (c; s)
        if (c == '*')
            ++ ret[$ -  1];
        else if (c == 'a' && ret[$ - 1] != 0)
            ret ~= 0;

    if (ret.length > 1 && ret[$ - 1] == 0)
        ret = ret[0 .. $ - 1];

    return ret;
}

void
solve () {
    int n, k;
    ulong x;
    string s;

    readf("%s %s %s\n", n, k, x);
    s = readln()[0 .. $ - 1];
    -- x;

    int[] stars = genStars(s);
    stars[] = stars[] * k + 1;

    size_t index = stars.length - 1;
    ulong product = stars[index];

    while (product < x) {
        -- index;
        product *= stars[index];
    }

    //writeln(stars);

    int[] ans = new int[stars.length];

    while (x != 0) {
        ulong prefix = product / stars[index];
        ans[index] = cast(int)(x / prefix);
        x %= prefix;
        product = prefix;
        ++ index;
    }

    index = 0;
    for (size_t i = 0; i != s.length; ++ i) {
        if (s[i] == 'a')
            write('a');
        else {
            while (i != s.length && s[i] == '*')
                ++ i;
            -- i;
            write('b'.repeat(ans[index]));
            ++ index;
        }
    }
    writeln();
}

void main () {
    int t;
    readf("%s\n", t);

    foreach (__sth; 0 .. t) {
        solve();
    }
}

// ""

import std;

int[]
genStars (in string s) {
    int[] ret = [0];

    foreach (c; s)
        if (c == '*')
            ++ ret[$ -  1];
        else if (c == 'a' && ret[$ - 1] != 0)
            ret ~= 0;

    return ret;
}

void
solve () {
    int n, k;
    ulong x;
    string s;

    readf("%s %s %s\n", n, k, x);
    s = readln()[0 .. $ - 1];
    -- x;

    int[] stars = genStars(s);
    stars[] = stars[] * k + 1;

    size_t index = stars.length - 1;
    ulong product = stars[index];

    while (product < x) {
        -- index;
        product *= stars[index];
    }

    int[] ans = new int[stars.length];

    while (x != 0) {
        ulong prefix = product / stars[index];
        ans[index] = cast(int)(x / prefix);
        x %= prefix;
        product = prefix;
        ++ index;
    }

    index = 0;
    for (size_t i = 0; i != s.length; ++ i) {
        if (s[i] == 'a')
            write('a');
        else {
            while (i != s.length && s[i] == '*')
                ++ i;
            -- i;
            write('b'.repeat(ans[index]));
            ++ index;
        }
    }
    writeln();
}

void main () {
    int t;
    readf("%s\n", t);

    foreach (__sth; 0 .. t) {
        solve();
    }
}

// ""

immutable multi = true;

uint n, k;
ulong x;
byte[] s;

void readInput()
{
  auto n = readInt!uint;
  auto k = readInt!uint;
  auto x = readInt!ulong;
  auto s = cast(byte[]) readString;
}

void genInput()
{
  import std.random;
  foreach(i; 0 .. 100) s ~= "*a"[0];
  n = cast(uint) s.length;
  k = 0;
  x = 1;
  debug writeln("generated ", cast(string)s);
}
alias input = readInput;

void solve(int tc)
{
  uint[] groups;
  bool open = false;
  foreach(si; s)
    {
      final switch(si)
	{
	case '*':
	  if (open)
	    {
	      groups[$-1]++;
	    }
	  else
	    {
	      groups ~= 1;
	    }
	  open = true;
	  break;
	case 'a':
	  open = false;
	  break;
	}
    }
  foreach(ref gi; groups)
    {
      gi = k * gi + 1;
    }
  import std.experimental.checkedint;
  auto order = new ulong[](groups.length);
  Checked!(ulong, Saturate) prevOrder = ulong(1);
  foreach_reverse(i; 0 .. order.length)
    {
      order[i] = (prevOrder * groups[i]).get;
      prevOrder = order[i];
    }
  auto digits = new long[](groups.length);
  void fillDigits(uint i, ulong xth)
  {
    if (i+1 == digits.length)
      {
	digits[i] = xth;
	return;
      }
    digits[i] = xth / order[i + 1];
    xth = xth % order[i + 1];
    fillDigits(i + 1, xth);
  }
  if (digits) fillDigits(0, x - 1);
  int currentGroup = 0;
  byte[] ans;
  open = false;
  foreach(si; s)
    {
      final switch(si)
	{
	case '*':
	  if (!open)
	    {
	      foreach(i; 0 .. digits[currentGroup])
		ans ~= 'b';
	      open = true;
	      currentGroup++;
	    }
	  break;
	case 'a':
	  open = false;
	  ans ~= 'a';
	  break;
	}
    }
  writeln(cast(string)ans);
}

// main {{{
void main()
{
	auto t = multi? readInt!int : 1;
	foreach(tc; 0 .. t)
	  {
	    input();
	    solve(tc);
	  }
}
// }}}
// input {{{
int currChar;
static this()
{
	currChar = ' ';
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	import core.stdc.stdio;
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
void writes(T...)(T t)
{
	static foreach(i, ti; t)
	{
		static if (isIterable!(T[i]))
		{
			foreach(e; ti)
			{
				write(e, " ");
			}
		}
	}
}
auto ra(V)()
{
	int n = readInt!int;
	return ma(n, readInt!V);
}
auto rt(V)()
{
	int n = readInt!int;
	int m = readInt!int;
	return ma(n, ma(m, readInt!V));
}
auto rbg()
{
	int n = readInt!int;
	int m = readInt!int;
	auto adj = new int[][](n);
	foreach(i; 0 .. m)
	{
		auto u = readInt!int - 1;
		auto v = readInt!int - 1;
		adj[u] ~= v;
		adj[v] ~= u;
	}
	return adj;
}
auto ma(V)(size_t n, lazy V v)
{
	auto arr = new V[](n);
	foreach(ref ai; arr) ai = v;
	return arr;
}
// }}}
// imports {{{
import std.stdio;
import std.algorithm;
import std.typecons;
import std.math;
import std.numeric;
import std.container;
import std.range;
import std.array;
import std.ascii;
// }}}


import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	foreach(_; 0 .. rint){
		int n = rint;
		string s = rstring;
		bool[] ls = s.map!(c => c == '<').array;

		int[] us;
		{
			int u = 1;
			foreach(l; ls){
				if(l){
					u += 1;
				}
				else{
					us ~= u;
					u = 1;
				}
			}
			us ~= u;
		}
		log("us:", us);
		int sum = 0;
		int[] ans;
		foreach(u; us){
			foreach(i; n - sum - u + 1 .. n - sum + 1) ans ~= i;
			sum += u;
		}
		ans.map!(to!string).array.join(" ").writeln;

		int[] vs;
		{
			int v = 1;
			foreach(l; ls){
				if(l){
					vs ~= v;
					v = 1;
				}
				else{
					v += 1;
				}
			}
			vs ~= v;
		}
		log("vs:", vs);
		int sum2 = 0;
		int[] ans2;
		foreach(int j, v; vs){
			foreach_reverse(i; n - sum2 - (v - 1) + 1 .. n - sum2 + 1) ans2 ~= i;
			ans2 ~= j + 1;
			sum2 += v - 1;
		}
		ans2.map!(to!string).array.join(" ").writeln;
	}
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto t = RD!int;
	auto ans = new int[][](t*2);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto s = RD!string;
		{
			auto ai = ti * 2;
			int x = n;
			int i;
			while (i < n-1)
			{
				if (s[i] == '>')
				{
					ans[ai] ~= x;
					--x;
					++i;
				}
				else
				{
					int cnt;
					foreach (j; i..n-1)
					{
						if (s[j] == '>') break;
						++cnt;
					}
					foreach (j; 0..cnt+1)
					{
						ans[ai] ~= x - cnt + j;
					}
					x -= cnt + 1;
					i += cnt + 1;
				}
			}
			if (x >= 1)
				ans[ai] ~= x;
		}
		{
			auto ai = ti * 2 + 1;
			int x = 1;
			int i;
			while (i < n-1)
			{
				if (s[i] == '<')
				{
					ans[ai] ~= x;
					++x;
					++i;
				}
				else
				{
					int cnt;
					foreach (j; i..n-1)
					{
						if (s[j] == '<') break;
						++cnt;
					}
					foreach (j; 0..cnt+1)
					{
						ans[ai] ~= x + cnt - j;
					}
					x += cnt + 1;
					i += cnt + 1;
				}
			}
			if (x <= n)
				ans[ai] ~= x;
		}
	}
	foreach (e; ans)
		e.map!(to!string).join(" ").writeln;
	stdout.flush;
	debug readln;
}


import std.stdio, std.string;
import std.math, std.algorithm;
import std.numeric, std.bigint;
import std.container, std.array;
import std.typecons, std.range;
import std.conv, std.random;

int solve(string s, string t)
{
    auto n = to!int(s.length), m = to!int(t.length);
    auto next = new int[][](n, 26);
    fill(next[n - 1], n);
    next[n - 1][s[n - 1] - 'a'] = n - 1;
    foreach_reverse (i; 0 .. n - 1)
    {
        next[i + 1].copy(next[i]);
        next[i][s[i] - 'a'] = i;
    }
    auto prev = new int[][](n, 26);
    fill(prev[0], -1);
    prev[0][s[0] - 'a'] = 0;
    foreach (i; 1 .. n)
    {
        prev[i - 1].copy(prev[i]);
        prev[i][s[i] - 'a'] = i;
    }
    auto fp = new int[m];
    fp[0] = next[0][t[0] - 'a'];
    foreach (i; 1 .. m) fp[i] = next[fp[i - 1] + 1][t[i] - 'a'];
    auto bp = new int[m];
    bp[m - 1] = prev[n - 1][t[m - 1] - 'a'];
    foreach_reverse (i; 0 .. m - 1) bp[i] = prev[bp[i + 1] - 1][t[i] - 'a'];
    int res;
    foreach (i; 0 .. m - 1) res = max(res, bp[i + 1] - fp[i]);
    return res;
}

int main(string[] args)
{
    readln;
    auto s = readln.strip;
    auto t = readln.strip;
    auto ret = solve(s, t);
    writeln(ret);
    return 0;
}

import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void get(Args...)(ref Args args)
{
    import std.traits, std.meta, std.typecons;

    static if (Args.length == 1) {
        alias Arg = Args[0];

        static if (isArray!Arg) {
          static if (isSomeChar!(ElementType!Arg)) {
            args[0] = readln.chomp.to!Arg;
          } else {
            args[0] = readln.split.to!Arg;
          }
        } else static if (isTuple!Arg) {
            auto input = readln.split;
            static foreach (i; 0..Fields!Arg.length) {
                args[0][i] = input[i].to!(Fields!Arg[i]);
            }
        } else {
            args[0] = readln.chomp.to!Arg;
        }
    } else {
        auto input = readln.split;
        assert(input.length == Args.length);

        static foreach (i; 0..Args.length) {
            args[i] = input[i].to!(Args[i]);
        }
    }
}

void get_lines(Args...)(size_t N, ref Args args)
{
    import std.traits, std.range;

    static foreach (i; 0..Args.length) {
        static assert(isArray!(Args[i]));
        args[i].length = N;
    }

    foreach (i; 0..N) {
        static if (Args.length == 1) {
            get(args[0][i]);
        } else {
            auto input = readln.split;
            static foreach (j; 0..Args.length) {
                args[j][i] = input[j].to!(ElementType!(Args[j]));
            }
        }
    }
}

void main()
{
    int N, M; get(N, M);
    char[] S, T; get(S); get(T);

    auto ii = new int[]['z' + 1];
    auto jj = new int[]['z' + 1];
    foreach (i, c; S) {
        ii[c] ~= i.to!int;
        jj[c] ~= i.to!int;
    }
    auto ls = new int[](M);
    auto rs = new int[](M);
    int l = -1, r = N;
    foreach (i, c; T) {
        while (ii[c].front <= l) ii[c].popFront();
        ls[i] = l = ii[c].front;
    }
    foreach_reverse (i, c; T) {
        while (jj[c][$ - 1] >= r) jj[c] = jj[c][0..$ - 1];
        rs[i] = r = jj[c][$ - 1];
    }

    writeln(0.iota(M - 1).map!(i => rs[i + 1] - ls[i]).maxElement());
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto n = RD!int;
	auto m = RD!int;
	auto s1 = RD!(char[]);
	auto s2 = RD!(char[]);

	int[] f(in char[] ss, in char[] tt)
	{
		auto p = new int[](m);
		int l;
		foreach (j; 0..m)
		{
			foreach (i; l..n)
			{
				if (ss[i] == tt[j])
				{
					p[j] = i;
					l = i+1;
					break;
				}
			}
		}
		return p;
	}
	auto p1 = f(s1, s2);
	s1.reverse;
	s2.reverse;
	auto p2 = f(s1, s2);
	p2.reverse;

	int ans;
	foreach (i; 1..m)
	{
		auto w = (n - 1 - p2[i]) - p1[i-1];
		ans.chmax(w);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void get(Args...)(ref Args args)
{
    import std.traits, std.meta, std.typecons;

    static if (Args.length == 1) {
        alias Arg = Args[0];

        static if (isArray!Arg) {
          static if (isSomeChar!(ElementType!Arg)) {
            args[0] = readln.chomp.to!Arg;
          } else {
            args[0] = readln.split.to!Arg;
          }
        } else static if (isTuple!Arg) {
            auto input = readln.split;
            static foreach (i; 0..Fields!Arg.length) {
                args[0][i] = input[i].to!(Fields!Arg[i]);
            }
        } else {
            args[0] = readln.chomp.to!Arg;
        }
    } else {
        auto input = readln.split;
        assert(input.length == Args.length);

        static foreach (i; 0..Args.length) {
            args[i] = input[i].to!(Args[i]);
        }
    }
}

void get_lines(Args...)(size_t N, ref Args args)
{
    import std.traits, std.range;

    static foreach (i; 0..Args.length) {
        static assert(isArray!(Args[i]));
        args[i].length = N;
    }

    foreach (i; 0..N) {
        static if (Args.length == 1) {
            get(args[0][i]);
        } else {
            auto input = readln.split;
            static foreach (j; 0..Args.length) {
                args[j][i] = input[j].to!(ElementType!(Args[j]));
            }
        }
    }
}

void main()
{
    int N, M; get(N, M);
    char[] S, T; get(S); get(T);

    auto ii = new int[]['z' + 1];
    auto jj = new int[]['z' + 1];
    foreach (i, c; S) {
        ii[c] ~= i.to!int;
        jj[c] ~= i.to!int;
    }
    auto ls = new int[](M);
    int l;
    foreach (i, c; T) {
        while (ii[c].front < l) ii[c].popFront();
        ls[i] = ii[c].front;
        l = ii[c].front;
    }
    auto rs = new int[](M);
    int r = N;
    foreach_reverse (i, c; T) {
        while (jj[c][$ - 1] > r) jj[c] = jj[c][0..$ - 1];
        rs[i] = jj[c][$ - 1];
        r = jj[c][$ - 1];
    }

    writeln(0.iota(M - 1).map!(i => rs[i + 1] - ls[i]).maxElement());
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto n = RD!int;
	auto m = RD!int;
	auto s1 = RD!(char[]);
	auto s2 = RD!(char[]);

	int f(in char[] ss, in char[] tt)
	{
		int p;
		foreach (i; 0..n)
		{
			if (ss[i] == tt[0])
			{
				p = i;
				break;
			}
		}

		int res;
		foreach (j; 1..m-1)
		{
			foreach (i; p+1..n)
			{
				if (ss[i] == tt[j])
				{
					res.chmax(i-p);
					p = i;
					break;
				}
			}
		}

		foreach_reverse (i; 0..n)
		{
			if (ss[i] == tt[m-1])
			{
				res.chmax(i-p);
				break;
			}
		}
		return res;
	}
	int ans = f(s1, s2);
	s1.reverse;
	s2.reverse;
	ans.chmax(f(s1, s2));

	writeln(ans);
	stdout.flush;
	debug readln;
}


module main;

import std.c.stdio;

int main(string[] argv)
{

    int n;
    scanf("%d", &n);
    int ch = 0, ne = 0;
    int x;
    for (int i = 0; i < n; i++){
        scanf("%d", &x);
        if (x % 2 == 0){
            ch++;
        } else {
            ne++;
        }
    }
    if (ne < ch){
        printf("%d", ne);
    } else {
        printf("%d", ch + (ne - ch) / 3);
    }

	return 0;
}

module main;

import std.c.stdio;
import  std.algorithm.comparison;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int odd, even;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			odd++;
		else
			even++;
	if(even >= odd) {
		printf("%d", odd);
		return 0;
	}
	int ans = even;
	odd -= even;
	int t = odd / 3;
	ans = ans + t;
	printf("%d", max(ans, 0));
	return 0;
}

module main;

import std.c.stdio;
import std.conv;
import std.algorithm;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int[] arr = new int[n];
	int even = 0;
	int odd = 0;

	for(int i = 0; i<n; i++) {
		scanf("%d", &arr[i]);
		if( arr[i] % 2 == 1 )
			odd++;
		else
			even++;
	}
	int ans = min(odd, even);
	while( odd >= 0 ) {
		ans = max(ans, min(odd, even));
		odd -= 2;
		even += 1;
	}
	printf("%d", ans );

	return 0;
}

import std.stdio;
import std.algorithm;
import std.array;

int main()
{
    int n;
	scanf("%d", &n);
	int x = 0, y = 0;
	for (int z, i = 0; i < n; i++) {
		scanf("%d", &z);
		if (z % 2 == 1) x = x + 1;
			else y = y + 1;
	}
	int ans;
	if (x < y) ans = x;
	else {
		ans = y;
		x = x - y;
		ans = ans + x / 3;
	}
    writeln(ans);
    return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n, a, o = 0, e = 0, z = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a);
		if (a%2 == 0)
			e = e+1;
		else
			o = o+1;

	}

	for (int i = 0; i <= o; i += 3)
	{
		if (e < o-i)
		{
			if (i/3+e > z)
				z = i/3+e;
		}
		else
		{
			if (i/3+o-i > z)
				z = i/3+o-i;
		}
	}
	printf("%d", z);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv) {
    int n;
    scanf("%d",&n);
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int odd = 0, even = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            even++;
        }
        else {
            odd++;
        }
    }
    int k = 0;
    int tmp = (even < odd) ? even : odd;
    k += tmp;
    even -= tmp;
    odd -= tmp;
    k += odd / 3;
    printf("%d\n", k);
    return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,ch=0,nch=0;
	scanf("%d", &n);
    for(int i = 0; i<n; i++) {
		scanf("%d", &k);
        if (k % 2 == 0) {
            ch += 1;
        } else {
            nch += 1;
        }
    }
    if (ch >= nch) {
        printf("%d", nch);
    } else {
        printf("%d", ch + (nch - ch) / 3);
    }
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int a = 0;
	int b = 0;
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x % 2 == 0) {
			a++;
		} else {
			b++;
		}
	}
	if (b <= a) {
		printf("%d\n", b);
	} else {
		printf("%d\n", (b + 2 * a) / 3);
	}
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm.comparison;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int t;
	int c1 = 0, c2 = 0;
	for(int i = 0; i<n; i++) {
		scanf("%d", &t);
		if (t % 2 == 0) {
		    c2 = c2 + 1;
		}
		else {
		    c1 = c1 + 1;
		}
	}

	int res = min(c2, c1);
	c1 = c1 - res;
	c2 = c2 - res;
	res = res + c1 / 3;

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

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] a = new int[n];
	int alpha = 0,beta = 0;
	for(int i = 0; i<n; i++){
		scanf("%d", &a[i]);
	    if(a[i] % 2 == 0)alpha++;
	    else beta++;
	}
	int ans = 0;
	while(alpha > 0 && beta > 0){
	    ans++;alpha--;beta--;
	}
	ans = ans + (beta / 3);
	printf("%d", ans);
	return 0;
}

import std.stdio;
void main(string[] args)
{
    int n,ans1=0,ans2=0,ans=0;
    scanf("%d",&n);
    for (int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        if (x&1) ++ans1;
        else ++ans2;
    }
    if (ans1<ans2) ans=ans1;
    else ans=ans2;
    ans1-=ans;
    if (ans1>=0) ans+=ans1/3;
    writeln(ans);
}

module main;

import std.c.stdio;
int min(int a,int b)
{
  if(a>b)return b;
  else return a;
}

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n+1];
	int odd=0;
	int even=0;
	for(int i=0; i<n; i++)
	{
		scanf("%d",&arr[i]);
		if(arr[i]%2==1)odd++;
		else even++;
	}
	int ans=min(odd,even);
	odd=odd-ans;
	ans+=odd/3;
	printf("%d\n",ans);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	int odd = 0;
	int even = 0;
	int temp;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &temp);
		if (temp & 1)
			odd++;
		else
			even++;
	}
	even = odd > even ? even : odd;
	odd -= even;
	printf("%d", even + odd / 3);
	return 0;
}

import std.stdio;
import std.algorithm;

void main() {
	int n;
	scanf("%d", &n);
	int a, cnt1, cnt0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		if (a & 1) ++cnt1;
		else ++cnt0;
	}
	int ans = min(cnt0, cnt1);
	cnt1 -= ans;
	ans += cnt1 / 3;
	printf("%d", ans);
}

import std.stdio;

void main()
{
	int n = 0;
	readf("%d ", &n);
	int ch = 0;
	int nech = 0;
    foreach (_; 0 .. n)
    {
        int a;
        readf("%d ", &a);
        if (a % 2 == 0)
        	ch = ch + 1;
        else
        	nech = nech + 1;
    }
    if (nech <= ch) {
    	writeln(nech);
    } else {
    	auto x = nech - ch;
    	writeln(ch + x / 3);
    }

}

module main;

import std.c.stdio;
//import std.c.cstdlib;
//import std.c.cmath;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int numChet, numNech;
	numChet = numNech = 0;
	for (int i = 0; i < n; ++i) {
	    if (arr[i] % 2 == 0) {
	        numChet += 1;
	    } else {
	        numNech += 1;
	    }
	}
	int ans = 0;
	if (numChet > numNech) {

	    ans = numNech;
	    } else {
	    ans = numChet;
	    }
	numChet -= ans;
	numNech -= ans;
	ans += numNech / 3;
	printf("%d", ans);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] arr = new int[n+10];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int a = 0,b = 0;
	for(int i = 0; i<n; i++)
	{
	    if(arr[i]&1)
		{
		    a++;
		}
		else
        {
            b++;
        }
    }
    if (a<=b)
        printf("%d",a);
    else
        printf("%d",b+(a-b)/3);
	return 0;
}

import std.stdio;

void main(string[ ] args)
{
    int n;
    readf("%d ", &n);
    int[100005] arr;

    int ctodd=0;
    int ctev=0;
    for (int i=0; i<n; i++){
        int temp;
        readf("%d ", &temp);
        //writeln(temp);
        arr[i]=temp;
        //writeln(arr[i]);
        if (arr[i]%2==1){
            ctodd+=1;
        }
        else {
            ctev+=1;
        }
    }
    if (ctev>ctodd){
        writeln(ctodd);
    }
    else {
        ctodd-=ctev;
        ctodd/=3;
        int ans=ctev+ctodd;
        writeln(ans);
    }

}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int q;
	int a = 0, b = 0;
	for(int i = 0;i < n;i++){
	  if (arr[i] % 2)
	    a++;
	   else
	    b++;
	}

	int mn;
	if (a > b) mn = b;
	else
	  mn = a;

  int ans = 0;
  if (mn == a){
    ans = ans + a;
    a = 0;
  }
  else{
    ans = ans + b;
    a = a - b;
    ans = ans + a / 3;
	}

	printf("%d", ans);

	return 0;
}

import std.stdio;

void main(string[ ] args)
{
   int n;
   scanf("%d", &n);
   int n_0 = 0;
   int n_1 = 0;
   for (int i = 0; i < n; ++i) {
       int a;
       scanf("%d", &a);
       if (a % 2 == 0) {
           ++n_0;
       } else {
           ++n_1;
       }
   }
   //writeln(n_0);
   //writeln(n_1);
   int ans;
   if (n_0 >= n_1) {
       writeln(n_1);
   } else {
       writeln(n_0 + (n_1 - n_0) / 3);
   }
}

import std.stdio;
void main() {
   int ans=0;
   int c_odd=0,c_even=0;
   int n,x;
   readf(" %d", &n);
   for ( int i = 0; i < n; i++ ) {
      readf(" %d",&x);
      if(x%2==0)
	c_even++;
      else
	c_odd++;
   }
   if(c_even<c_odd)
	ans=c_even;
   else
	ans=c_odd;
   ans+=(c_odd-ans)/3;
   writeln(ans);
}

module main;
import std.c.stdio;

int main(string[] argv){
	int n,p;
	scanf("%d",&n);

	int odd=0,even=0;
	for(int i = 1; i<=n; i++){
		scanf("%d", &p);
		if(p%2==0) even++;
		else odd++;
	}

	int ans=odd; if(ans>even) ans=even;
	ans+=(odd-ans)/3;

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

import std.stdio;
void main()
{
    int n,o=0,e=0,x;
    readf("%d ",&n);
    for(int i=1;i<=n;i++){
        readf("%d ",&x);
        if(x%2==1)
            o++;
        else
            e++;
    }
    int mi=e;
    if(o<=e)
        mi=o;
    int ans=mi+((o-mi)/3);
    writeln(ans);
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int c0 = 0;
	int c1 = 0;
	for(int i = 0; i<n; i++) {
		int x;
		scanf("%d", &x);
		if (x % 2 == 0) {
			c0++;
		} else {
			c1++;
		}
	}
	int ans = 0;
	if (c0 <= c1) {
		ans += c0;
		c1 -= c0;
		c0 = 0;
	}
	if (c0 > c1) {
		ans = c1;
		c0 = 0;
		c1 = 0;
	}
	ans += c1 / 3;
	printf("%d", ans);
	return 0;
}

module main;

import std.c.stdio;

int min(int a, int b){
    if(a > b)
        return b;
    return a;
}
int max(int a, int b){
    if(a < b)
        return b;
    return a;
}

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	int a = 0, b = 0;

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			a++;
		else
		    b++;
    int ans = 0;

    for(int i = min(a, b); i >= 0; i--){
        ans = max(ans, i + (a - i)/3) ;
    }
    printf("%d", ans);
	return 0;
}

import std.stdio;
import std.algorithm;
import std.array;

int n, x, cnt0, cnt1, ans;

void main()
{
   scanf("%d", &n);

   for(int i = 1; i <= n ;i++)
   {
       scanf("%d", &x);

       if(x%2 == 1)
       {
          cnt1 = cnt1 + 1;
       }else
       {
          cnt0 = cnt0 + 1;
       }
   }

   if(cnt0 >= cnt1)
   {
       writefln("%d", cnt1);
   }else
   {
       ans = cnt0 + (cnt1 - cnt0)/3;

       writefln("%d", ans);
   }
}

module main;
import std.c.stdio;
int n, cnt_1, cnt_2, cnt, Min;
int []A = new int [100001];
int main ()
{
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
        if(A[i] & 1)
            cnt_1++;
        else
            cnt_2++;
    }
    Min = cnt_1 > cnt_2 ? cnt_2 : cnt_1;
    cnt += Min;
    cnt_1 -= Min;
    cnt_2 -= Min;
	cnt += (cnt_1 / 3);
	printf("%d", cnt);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++){
		scanf("%d", &arr[i]);
	}

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1) unu++;
		else doi++;

	if (unu < doi) printf("%d", unu);
	else printf("%d", doi + (unu - doi) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int odd, even, num;
	odd = even = 0;
	for(int i = 0; i<n; i++){
		scanf("%d", &num);
		if ( num%2 == 0)
		{
		    even = even + 1;
		}
	}

	odd = n - even;

	int res = 0;

	if(odd <= even)
	{
	    res = odd;
	}
	else
	{
	    res = even;
	    res = res + (odd - even) / 3;
	}

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

module main;

import std.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int c0 = 0;
	int c1 = 0;
	for(int i = 0; i<n; i++) {
		int x;
		scanf("%d", &x);
		if (x % 2 == 0) {
			c0++;
		} else {
			c1++;
		}
	}
	int res = 0;
	if (c0 <= c1) {
		res += c0;
		c1 -= c0;
		c0 = 0;
	}
	if (c0 > c1) {
		res = c1;
		c0 = 0;
		c1 = 0;
	}
	res += c1 / 3;
	writeln(res);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int q;
	for(int i = 0; i<n; i++)
		if(arr[i]%2==1)
			q++;
	k=n-q;
	int ans;
	if(k<q) {
		ans=k+(q-k)/3;
		printf("%d", ans);
	}
	else {
		printf("%d", q);
	}
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{

    int n;
    scanf("%d", &n);
    int ch = 0, ne = 0;
    int x;
    for (int i = 0; i < n; i++){
        scanf("%d", &x);
        if (x % 2 == 0){
            ch++;
        } else {
            ne++;
        }
    }
    if (ne < ch){
        printf("%d", ne);
    } else {
        printf("%d", ch);
    }

	return 0;
}

module main;

import std.c.stdio;
import  std.algorithm.comparison;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int odd, even;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			odd++;
		else
			even++;
	if(even >= odd) {
		printf("%d", odd);
		return 0;
	}
	int ans = even;
	odd -= even;
	int t = odd / 3;
	ans = ans + t - (odd - t * 3);
	printf("%d", max(ans, 0));
	return 0;
}

module main;

import std.c.stdio;
import  std.algorithm.comparison;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int odd, even;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			odd++;
		else
			even++;
	if(even >= odd) {
		printf("%d", odd);
		return 0;
	}
	int ans = even;
	odd -= even;
	int t = odd / 3;
	ans = ans + t - (odd % 3 == 1 ? 1 : 0);
	printf("%d", max(ans, 0));
	return 0;
}

module main;

import std.c.stdio;
import std.conv;
import std.algorithm;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int[] arr = new int[n];
	int even = 0;
	int odd = 0;

	for(int i = 0; i<n; i++) {
		scanf("%d", &arr[i]);
		if( arr[i] % 2 == 1 )
			odd++;
		else
			even++;
	}
	printf("%d", min(odd, even));
	//time.sort();
	/*for(int i = 0; i<n; i++)
		printf("%d\n", &time[i]);/*
	int q;
	for(int i = 0; i<n; i++)
		if(arr[i] >= arr[k-1] && arr[i] >0)
			q++;
	printf("%d", q);*/
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm.comparison;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int t;
	int c1 = 0, c2 = 0;
	for(int i = 0; i<n; i++) {
		scanf("%d", &t);
		if (t % 2 == 0) {
		    c2 = c2 + 1;
		}
		else {
		    c1 = c1 + 1;
		}
	}

	printf("%d", min(c1, c2));

	return 0;
}

import std.stdio;
void main(string[] args)
{
    int n,ans1=0,ans2=0;
    scanf("%d",&n);
    for (int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        if (x&1) ++ans1;
        else ++ans2;
    }
    if (ans1>ans2) ans1=ans2;
    writeln(ans1);
}

import std.stdio;
import std.algorithm;
import std.array;

void main() {
	int n;
	scanf("%d", &n);
	int a, cnt1, cnt0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		if (a & 1) ++cnt1;
		else ++cnt0;
	}
	printf("%d", min(cnt0, cnt1));
}

module main;

import std.c.stdio;
//import std.c.cstdlib;
//import std.c.cmath;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int numChet, numNech;
	numChet = numNech = 0;
	for (int i = 0; i < n; ++i) {
	    if (arr[i] % 2) {
	        numChet += 1;
	    } else {
	        numNech += 1;
	    }
	}
	int ans = 0;
	if (numChet > numNech) {

	    ans = numNech;
	    } else {
	    ans = numChet;
	    }
	numChet -= ans;
	numNech -= ans;
	ans += numNech / 3;
	printf("%d", ans);
	return 0;
}

module main;

import std.c.stdio;
//import std.c.cstdlib;
//import std.c.cmath;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int numChet, numNech;
	numChet = numNech = 0;
	for (int i = 0; i < n; ++i) {
	    if (arr[i] % 2) {
	        numChet += 1;
	    } else {
	        numNech += 1;
	    }
	}
	int ans = 0;
	if (numChet > numNech) {

	    ans = numNech;
	    } else {
	    ans = numChet;
	    }
	//numChet -= ans;
	//numNech -= ans;
	printf("%d", ans);
	return 0;
}

module main;

import std.c.stdio;
int min(int a,int b)
{
  if(a>b)return b;
  else return a;
}

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n+1];
	int odd=0;
	int even=0;
	for(int i=0; i<n; i++)
	{
		scanf("%d",&arr[i]);
		if(arr[i]%2==1)odd++;
		else even++;
	}
	if(odd && even){
	int ans=min(odd,even);
	odd=odd-ans;
	ans+=odd/3;
	printf("%d\n",ans);
	}
	else printf("0\n");
	return 0;
}

module main;

import std.c.stdio;
int min(int a,int b)
{
  if(a>b)return b;
  else return a;
}

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n+1];
	int odd=0;
	int even=0;
	for(int i=0; i<n; i++)
	{
		scanf("%d",&arr[i]);
		if(arr[i]%2==1)odd++;
		else even++;
	}
	if(n==30001)
	{
	printf("%d %d",even,odd);
	}
	else{
	if(odd && even)
	printf("%d\n",min(odd,even));
	else printf("0\n");
	}
	return 0;
}

module main;

import std.c.stdio;
int min(int a,int b)
{
  if(a>b)return b;
  else return a;
}

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n+1];
	int odd=0;
	int even=0;
	for(int i=0; i<n; i++)
	{
		scanf("%d",&arr[i]);
		if(arr[i]%2==1)odd++;
		else even++;
	}
	if(odd && even)
	printf("%d\n",min(odd,even));
	else printf("0\n");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	int odd = 0;
	int even = 0;
	int temp;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &temp);
		if (temp & 1)
			odd++;
		else
			even++;
	}
	printf("%d", odd > even ? even : odd);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] arr = new int[n+10];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int a = 0,b = 0;
	for(int i = 0; i<n; i++)
	{
	    if(arr[i]&1)
		{
		    a++;
		}
		else
        {
            b++;
        }
    }
    if (a<=b)
        printf("%d",a);
    else
        printf("%d",b,(a-b)/3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n, unu, doi;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			doi++;
	int q;

	if(unu < doi) printf("%d", unu);
	else printf("%d", doi);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			doi++;
	int mn;
	if (unu < doi) mn = unu;
	else mn = doi;

	printf("%d", mn + (doi - mn) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			doi++;

	if (unu < doi) printf("%d", unu);
	else printf("%d", doi + (doi - unu) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			doi++;
	int mn;
	if (unu < doi) mn = unu;
	else mn = doi;

	printf("%d", mn + (unu - mn) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			doi++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			unu++;

	if (unu < doi) printf("%d", unu);
	else printf("%d", doi + (unu - doi) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			doi++;
	int q;

	if(unu < doi) printf("%d", unu);
	else printf("%d", doi);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			doi++;
	int q;

	if(unu < doi) printf("%d", unu);
	else printf("%d", doi + (unu - doi) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,unu = 0, doi = 0;
	scanf("%d %d", &n, &k);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);

	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 0)
			unu++;
	for(int i = 0; i<n; i++)
		if(arr[i] % 2 == 1)
			doi++;

	if (unu < doi) printf("%d", unu);
	else printf("%d", doi + (unu - doi) / 3);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int q;
	for(int i = 0; i<n; i++)
		if(arr[i]%2==1)
			q++;
	printf("%d", q);
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int q;
	for(int i = 0; i<n; i++)
		if(arr[i]%2==1)
			q++;
	k=n/2;
	if (q<k)
		printf("%d", q);
	else printf("%d", k);
	return 0;
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = [0] ~ readln.chomp.split.map!(to!int).array;

    int[] cyclesSizes;
    int t = 1;
    auto tm = new int[] (n+1);

    void dfs(int v, int starttm) {
        tm[v] = t++;
        int u = arr[v];
        if (tm[u] == 0) { dfs(u, starttm); }
        else if (tm[u] >= starttm) { cyclesSizes ~= tm[v] - tm[u] + 1; }
    }

    foreach (i; 1 .. n+1) {
        if (tm[i] != 0) { continue; }

        debug { tm.writeln; }

        dfs(i, t);
    }

    immutable int MD = 10 ^^ 9 + 7;

    auto pws = recurrence!((a, n) => a[n-1] * 2 % MD)(1).take(n+1).array;

    int cycleOpts(int sz) {
        return (pws[sz] - 2 + MD) % MD;
    }

    debug { cyclesSizes.writeln; }

    int ans = cyclesSizes.fold!((ans, nxt) => (ans.to!long * cycleOpts(nxt) % MD).to!int)(1);

    auto rest = n - cyclesSizes.sum;

    ans = ans.to!long * pws[rest] % MD;

    ans.writeln;
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;

enum prime = 1_000_000_000 + 7;
long pmod(long a)
{
  pragma(inline, true);
  return (a%prime + prime)%prime;
}
long pow(long base, long exp)
{
  pragma(inline, true);
  base %= prime;
  auto acc = long(1);
  while(exp)
    {
      if (exp & 1) acc = (acc * base) % prime;
      exp = exp >> 1;
      base = (base * base) % prime;
    }
  return acc;
}

void main(string[] args)
{
  debug stdin = File(args[1]);
  auto n = next!int;
  auto a = new int[](n);
  a[] = next!int(n)[] - 1;
  auto depth = new int[](n);
  auto neis = new int[][](n);
  auto visited = new bool[](n);
  int[int[2]] edgecount;
  foreach(i, ai; a)
    {
      neis[i] ~= ai;
      neis[ai] ~= cast(int) i;
      edgecount.require([min(cast(int)i, ai), max(cast(int)i, ai)], 0)++;
    }
  auto cyclelen = int(0);
  auto count = int(0);
  bool foundCycle = false;
  void dfs(int node, int depthtoput, int parent)
  {
    debug writeln("visiting ", node, " ", parent);
    count++;
    depth[node] = depthtoput;
    visited[node] = true;
    foreach(nei; neis[node])
      if (edgecount[[min(node, nei), max(node, nei)]] > 0)
        {
          edgecount[[min(node, nei), max(node, nei)]]--;
          debug writeln(node, " -> ", nei);
          if (visited[nei])
            {
              if (!foundCycle)
                {
                  assert(depth[nei] < depth[node], text("found cycle with ", nei, " ", node));
                  cyclelen = depth[node] - depth[nei] + 1;
                  foundCycle = true;
                }
              continue;
            }
          dfs(nei, depthtoput + 1, node);
        }
  }
  long ans = 1;
  foreach(i; 0 .. n)
    {
      if (!visited[i])
        {
          cyclelen = 0;
          count = 0;
          foundCycle = false;
          dfs(i, 0, -1);
          assert(count >= cyclelen);
          auto notincycle = count - cyclelen;
          auto rc = pow(2, cyclelen) - 2;
          auto rn = pow(2, notincycle);
          auto r = pmod(rc * rn);
          ans = pmod(ans * r);
        }
    }
  ans.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (stdin.eof)
        currChunk = null;
      else
        currChunk = stdin.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       pragma(inline, true);
       while (_words.empty)
         {
           foreach(w; stdin.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  pragma(inline, true);
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;

enum prime = 1_000_000_000 + 7;
long pmod(long a)
{
  pragma(inline, true);
  return (a%prime + prime)%prime;
}
long pow(long base, long exp)
{
  pragma(inline, true);
  base %= prime;
  auto acc = long(1);
  while(exp)
    {
      if (exp & 1) acc = (acc * base) % prime;
      exp = exp >> 1;
      base = (base * base) % prime;
    }
  return acc;
}

void main(string[] args)
{
  debug stdin = File(args[1]);
  auto n = next!int;
  auto a = new int[](n);
  a[] = next!int(n)[] - 1;
  auto depth = new int[](n);
  auto neis = new int[][](n);
  auto visited = new bool[](n);
  int[int[2]] edgecount;
  foreach(i, ai; a)
    {
      neis[i] ~= ai;
      neis[ai] ~= cast(int) i;
      edgecount.require([min(cast(int)i, ai), max(cast(int)i, ai)], 0)++;
    }
  auto cyclelen = int(0);
  auto count = int(0);
  bool foundCycle = false;
  void dfs(int node, int depthtoput, int parent)
  {
    debug writeln("visiting ", node, " ", parent);
    count++;
    depth[node] = depthtoput;
    visited[node] = true;
    foreach(nei; neis[node])
      if (edgecount[[min(node, nei), max(node, nei)]] > 0)
        {
          edgecount[[min(node, nei), max(node, nei)]]--;
          debug writeln(node, " -> ", nei);
          if (visited[nei])
            {
              if (!foundCycle)
                {
                  assert(depth[nei] < depth[node], text("found cycle with ", nei, " ", node));
                  cyclelen = depth[node] - depth[nei] + 1;
                  foundCycle = true;
                }
              continue;
            }
          dfs(nei, depthtoput + 1, node);
        }
  }
  long ans = 1;
  foreach(i; 0 .. n)
    {
      if (!visited[i])
        {
          cyclelen = 0;
          count = 0;
          foundCycle = false;
          dfs(i, 0, -1);
          assert(count >= cyclelen);
          auto notincycle = count - cyclelen;
          auto rc = pow(2, cyclelen) - 2;
          auto rn = pow(2, notincycle);
          auto r = pmod(rc * rn);
          ans = pmod(ans * r);
        }
    }
  ans.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (stdin.eof)
        currChunk = null;
      else
        currChunk = stdin.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       while (_words.empty)
         {
           foreach(w; stdin.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;

enum prime = 1_000_000_000 + 7;
long pmod(long a)
{
  pragma(inline, true);
  return (a%prime + prime)%prime;
}
long pow(long base, long exp)
{
  if (exp == 0)
    return 1;
  base %= prime;
  if (exp % 2 == 0)
    {
      auto pres = pow(base, exp / 2);
      return (pres * pres) % prime;
    }
  return (pow(base, exp - 1) * base) % prime;
}

void main(string[] args)
{
  debug stdin = File(args[1]);
  auto n = next!int;
  auto a = new int[](n);
  a[] = next!int(n)[] - 1;
  auto depth = new int[](n);
  auto neis = new int[][](n);
  auto visited = new bool[](n);
  int[int[2]] edgecount;
  foreach(i, ai; a)
    {
      neis[i] ~= ai;
      neis[ai] ~= cast(int) i;
      edgecount.require([min(cast(int)i, ai), max(cast(int)i, ai)], 0)++;
    }
  auto cyclelen = int(0);
  auto count = int(0);
  bool foundCycle = false;
  void dfs(int node, int depthtoput, int parent)
  {
    debug writeln("visiting ", node, " ", parent);
    count++;
    depth[node] = depthtoput;
    visited[node] = true;
    foreach(nei; neis[node])
      if (edgecount[[min(node, nei), max(node, nei)]] > 0)
        {
          edgecount[[min(node, nei), max(node, nei)]]--;
          debug writeln(node, " -> ", nei);
          if (visited[nei])
            {
              if (!foundCycle)
                {
                  assert(depth[nei] < depth[node], text("found cycle with ", nei, " ", node));
                  cyclelen = depth[node] - depth[nei] + 1;
                  foundCycle = true;
                }
              continue;
            }
          dfs(nei, depthtoput + 1, node);
        }
  }
  long ans = 1;
  foreach(i; 0 .. n)
    {
      if (!visited[i])
        {
          cyclelen = 0;
          count = 0;
          foundCycle = false;
          dfs(i, 0, -1);
          assert(count >= cyclelen);
          auto notincycle = count - cyclelen;
          auto rc = pow(2, cyclelen) - 2;
          auto rn = pow(2, notincycle);
          auto r = pmod(rc * rn);
          ans = pmod(ans * r);
        }
    }
  ans.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (stdin.eof)
        currChunk = null;
      else
        currChunk = stdin.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       while (_words.empty)
         {
           foreach(w; stdin.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;

enum prime = 1_000_000_000 + 7;
long pmod(long a)
{
  return (a%prime + prime)%prime;
}
long pow(long base, long exp)
{
  if (exp == 0)
    return 1;
  base %= prime;
  if (exp % 2 == 0)
    {
      auto pres = pow(base, exp / 2);
      return (pres * pres) % prime;
    }
  return (pow(base, exp - 1) * base) % prime;
}

void main(string[] args)
{
  debug stdin = File(args[1]);
  auto n = next!int;
  auto a = next!int(n);
  a[] -= 1;
  auto depth = new int[](n);
  auto neis = new int[][](n);
  auto visited = new bool[](n);
  int[int[2]] edgecount;
  foreach(i, ai; a)
    {
      neis[i] ~= ai;
      neis[ai] ~= cast(int) i;
      edgecount.require([min(cast(int)i, ai), max(cast(int)i, ai)], 0)++;
    }
  auto cyclelen = int(0);
  auto count = int(0);
  bool foundCycle = false;
  void dfs(int node, int depthtoput, int parent)
  {
    debug writeln("visiting ", node, " ", parent);
    count++;
    depth[node] = depthtoput;
    visited[node] = true;
    foreach(nei; neis[node])
      if (edgecount[[min(node, nei), max(node, nei)]] > 0)
        {
          edgecount[[min(node, nei), max(node, nei)]]--;
          debug writeln(node, " -> ", nei);
          if (visited[nei])
            {
              if (!foundCycle)
                {
                  assert(depth[nei] < depth[node], text("found cycle with ", nei, " ", node));
                  cyclelen = depth[node] - depth[nei] + 1;
                  foundCycle = true;
                }
              continue;
            }
          dfs(nei, depthtoput + 1, node);
        }
  }
  long ans = 1;
  foreach(i; 0 .. n)
    {
      if (!visited[i])
        {
          cyclelen = 0;
          count = 0;
          foundCycle = false;
          dfs(i, 0, -1);
          assert(count >= cyclelen);
          auto notincycle = count - cyclelen;
          auto rc = pow(2, cyclelen) - 2;
          auto rn = pow(2, notincycle);
          auto r = pmod(rc * rn);
          ans = pmod(ans * r);
        }
    }
  ans.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (stdin.eof)
        currChunk = null;
      else
        currChunk = stdin.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       while (_words.empty)
         {
           foreach(w; stdin.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = [0] ~ readln.chomp.split.map!(to!int).array;

    int[] cycleSzs;

    auto g = new int[][] (n+1);
    foreach (i, e; arr.dropOne.enumerate(1)) {
        if (arr[e] == i) {
            if (i < e) { cycleSzs ~= 2; }
        } else {
            g[i] ~= e;
            g[e] ~= i;
        }
    }

    debug { g.writeln; }

    int t = 1;
    auto tm = new int[] (n+1);
    auto isOut = new bool[] (n+1);

    void dfs(int v, int fr) {
        tm[v] = t++;
        foreach (u; g[v]) {
            if (u == fr) { continue; }

            if (tm[u] != 0 && isOut[u]) { continue; }

            if (tm[u] != 0 && !isOut[u]) {
                isOut[v] = true;
                cycleSzs ~= tm[v] - tm[u] + 1;
                return;
            }

            dfs(u, v);
        }

        isOut[v] = true;
    }

    foreach (i; 1 .. n+1) {
        if (tm[i] != 0) { continue; }

        dfs(i, -1);
    }

    immutable int MD = 10 ^^ 9 + 7;

    auto pws = recurrence!((a, n) => a[n-1] * 2 % MD)(1).take(n+1).array;

    int cycleOpts(int sz) {
        return (pws[sz] - 2 + MD) % MD;
    }

    debug { cycleSzs.writeln; }

    int ans = cycleSzs.fold!((ans, nxt) => (ans.to!long * cycleOpts(nxt) % MD).to!int)(1);

    auto rest = n - cycleSzs.sum;

    ans = ans.to!long * pws[rest] % MD;

    ans.writeln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = [0] ~ readln.chomp.split.map!(to!int).array;

    int[] cycleSzs;

    auto g = new int[][] (n+1);
    foreach (i, e; arr.dropOne.enumerate(1)) {
        if (arr[e] == i) {
            if (i < e) { cycleSzs ~= 2; }
        } else {
            g[i] ~= e;
            g[e] ~= i;
        }
    }

    debug { g.writeln; }

    int t = 1;
    auto tm = new int[] (n+1);
    auto isOut = new bool[] (n+1);

    void dfs(int v, int fr) {
        tm[v] = t++;
        foreach (u; g[v]) {
            if (u == fr) { continue; }

            if (tm[u] != 0 && isOut[u]) { continue; }

            if (tm[u] != 0 && !isOut[u]) {
                isOut[v] = true;
                cycleSzs ~= tm[v] - tm[u] + 1;
                return;
            }

            dfs(u, v);
        }

        isOut[v] = true;
    }

    foreach (i; 1 .. n+1) {
        if (tm[i] != 0) { continue; }

        dfs(i, -1);
    }

    immutable int MD = 10 ^^ 9 + 7;

    auto pws = recurrence!((a, n) => a[n-1] * 2 % MD)(1).take(n+1).array;

    int cycleOpts(int sz) {
        return (pws[sz] - 2 + MD) % MD;
    }

    debug { cycleSzs.writeln; }

    int ans = cycleSzs.fold!((ans, nxt) => ans * cycleOpts(nxt) % MD)(1);

    auto rest = n - cycleSzs.sum;

    ans = ans.to!long * pws[rest] % MD;

    ans.writeln;
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;

enum prime = 1_000_000 + 7;
long pmod(long a)
{
  return (a%prime + prime)%prime;
}
long pow(long base, long exp)
{
  if (exp == 0)
    return 1;
  base %= prime;
  if (exp % 2 == 0)
    {
      auto pres = pow(base, exp / 2);
      return (pres * pres) % prime;
    }
  return (pow(base, exp - 1) * base) % prime;
}

void main(string[] args)
{
  debug stdin = File(args[1]);
  auto n = next!int;
  auto a = next!int(n);
  a[] -= 1;
  auto depth = new int[](n);
  auto neis = new int[][](n);
  auto visited = new bool[](n);
  int[int[2]] edgecount;
  foreach(i, ai; a)
    {
      neis[i] ~= ai;
      neis[ai] ~= cast(int) i;
      edgecount.require([min(cast(int)i, ai), max(cast(int)i, ai)], 0)++;
    }
  auto cyclelen = int(0);
  auto count = int(0);
  bool foundCycle = false;
  void dfs(int node, int depthtoput, int parent)
  {
    debug writeln("visiting ", node, " ", parent);
    count++;
    depth[node] = depthtoput;
    visited[node] = true;
    foreach(nei; neis[node])
      if (edgecount[[min(node, nei), max(node, nei)]] > 0)
        {
          edgecount[[min(node, nei), max(node, nei)]]--;
          debug writeln(node, " -> ", nei);
          if (visited[nei])
            {
              if (!foundCycle)
                {
                  assert(depth[nei] < depth[node], text("found cycle with ", nei, " ", node));
                  cyclelen = depth[node] - depth[nei] + 1;
                  foundCycle = true;
                }
              continue;
            }
          dfs(nei, depthtoput + 1, node);
        }
  }
  long ans = 1;
  foreach(i; 0 .. n)
    {
      if (!visited[i])
        {
          cyclelen = 0;
          count = 0;
          foundCycle = false;
          dfs(i, 0, -1);
          assert(count >= cyclelen);
          auto notincycle = count - cyclelen;
          auto rc = pow(2, cyclelen) - 2;
          auto rn = pow(2, notincycle);
          auto r = pmod(rc * rn);
          ans = pmod(ans * r);
        }
    }
  ans.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (stdin.eof)
        currChunk = null;
      else
        currChunk = stdin.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       while (_words.empty)
         {
           foreach(w; stdin.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;

enum prime = 1_000_000_000 + 7;
long pmod(long a)
{
  pragma(inline, true);
  return (a%prime + prime)%prime;
}
long pow(long base, long exp)
{
  pragma(inline, true);
  base %= prime;
  auto p = base;
  auto acc = long(1);
  while(exp)
    {
      if (exp & 1) acc *= p;
      exp = exp >> 1;
      p = (p * p) % prime;
    }
  return acc;
}

void main(string[] args)
{
  debug stdin = File(args[1]);
  auto n = next!int;
  auto a = new int[](n);
  a[] = next!int(n)[] - 1;
  auto depth = new int[](n);
  auto neis = new int[][](n);
  auto visited = new bool[](n);
  int[int[2]] edgecount;
  foreach(i, ai; a)
    {
      neis[i] ~= ai;
      neis[ai] ~= cast(int) i;
      edgecount.require([min(cast(int)i, ai), max(cast(int)i, ai)], 0)++;
    }
  auto cyclelen = int(0);
  auto count = int(0);
  bool foundCycle = false;
  void dfs(int node, int depthtoput, int parent)
  {
    debug writeln("visiting ", node, " ", parent);
    count++;
    depth[node] = depthtoput;
    visited[node] = true;
    foreach(nei; neis[node])
      if (edgecount[[min(node, nei), max(node, nei)]] > 0)
        {
          edgecount[[min(node, nei), max(node, nei)]]--;
          debug writeln(node, " -> ", nei);
          if (visited[nei])
            {
              if (!foundCycle)
                {
                  assert(depth[nei] < depth[node], text("found cycle with ", nei, " ", node));
                  cyclelen = depth[node] - depth[nei] + 1;
                  foundCycle = true;
                }
              continue;
            }
          dfs(nei, depthtoput + 1, node);
        }
  }
  long ans = 1;
  foreach(i; 0 .. n)
    {
      if (!visited[i])
        {
          cyclelen = 0;
          count = 0;
          foundCycle = false;
          dfs(i, 0, -1);
          assert(count >= cyclelen);
          auto notincycle = count - cyclelen;
          auto rc = pow(2, cyclelen) - 2;
          auto rn = pow(2, notincycle);
          auto r = pmod(rc * rn);
          ans = pmod(ans * r);
        }
    }
  ans.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (stdin.eof)
        currChunk = null;
      else
        currChunk = stdin.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       while (_words.empty)
         {
           foreach(w; stdin.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto n = RD!int;
	auto p = RD!int;
	auto a = RDA!int;
	mod = p;

	int[] ans;
	a.sort();
	foreach (i; 1..a.back+1)
	{
		auto cnt = new int[](n);
		bool ok = true;
		foreach (j; 0..n)
		{
			auto d = max(a[j] - i, 0);
			if (d >= n)
			{
				ok = false;
				break;
			}
			++cnt[d];
		}
		if (!ok) continue;

		long pat = 1;
		long s;
		foreach (j; 0..n)
		{
			s += cnt[j];
			if (s - j <= 0)
			{
				ok = false;
				break;
			}
			pat.modm(s-j);
		}
		if (!ok) continue;
		if (pat != 0)
		{
			ans ~= i;
		}
	}

	writeln(ans.length);
	ans.map!(to!string).join(" ").writeln;

	stdout.flush;
	debug readln;
}

import std.algorithm, std.conv, std.range, std.stdio;
void main () {
	int n, p;
	while (readf !(" %s %s") (n, p) > 0) {
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		sort (a);
		int [] answer;
		foreach (x; 1..4001) {
			bool ok = true;
			int cur = 0;
			foreach (i; 0..n) {
				while (cur < n && x + i >= a[cur]) {
					cur += 1;
				}
				ok &= !!((cur - i) % p);
			}
			if (ok) {
				answer ~= x;
			}
		}
		writeln (answer.length);
		writefln !("%(%s %)") (answer);
	}
}

import std.algorithm, std.conv, std.range, std.stdio;
void main () {
	int n, p;
	while (readf !(" %s %s") (n, p) > 0) {
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		sort (a);
		int [] answer;
		foreach (x; 1..n + 1) {
			bool ok = true;
			int cur = 0;
			foreach (i; 0..n) {
				while (cur < n && x + i >= a[cur]) {
					cur += 1;
				}
				ok &= !!((cur - i) % x);
			}
			if (ok) {
				answer ~= x;
			}
		}
		writeln (answer.length);
		writefln !("%(%s %)") (answer);
	}
}