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.datetime.stopwatch;
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;

    int ans = n-1;
    foreach (i; 2 .. n/2 + 1) {
        int a = i, b = n - i;
        if (gcd(a, b) != 1) { continue; }

        int steps = 1;
        while (a != 1 && b != 1) {
            if (a < b) { swap(a, b); }

            steps += a / b;
            a %= b;
        }
        if (a > 1 || b > 1) { steps += a-1 + b-1; }

        ans = min(ans, steps);
    }

    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;
import std.range;
import std.numeric;

void main(string[] args)
{
  inputFile = stdin;
  int stepsTo(int a, int b)
  {
    if (gcd(a, b) != 1) return int.max;
    if (a > b) swap(a, b);
    if (a == 1) return b - 1;
    return (b/a) + stepsTo(b % a, a);
  }
  auto n = next!int;
  if (n == 1) return writeln("0");
  (1 + iota(0, n).map!(i => stepsTo(i, n - i)).fold!min).writeln;
}
ulong bitCnt(long x)
{
  ulong cnt = 0;
  while(x) {cnt += x & 1; x>>=1;}
  return cnt;
}
alias Arr(T) = Mat!(T, 1);
struct Mat(T, size_t dimension)
{
  T[] _baseArray;
  T[] _slice;
  size_t[dimension] _sizes; size_t dim(size_t i) {return _sizes[i];}
  size_t[dimension] _indexer;
  this(T[] baseArray, size_t[dimension] sizes)
  {
    _baseArray = baseArray;
    _sizes = sizes;
    _indexer[dimension - 1] = 1;
    static foreach_reverse(i; 0 .. dimension - 1)
      _indexer[i] = _indexer[i + 1] * _sizes[i + 1];
    auto requiredSize = _indexer[0] * _sizes[0];
    debug assert(_baseArray.length >= requiredSize);
    _slice = _baseArray[0 .. requiredSize];
  }
  this(size_t[dimension] sizes)
  {
    size_t reqSize = 1;
    static foreach(i; 0 .. dimension)
      reqSize *= sizes[i];
    this(new T[](reqSize), sizes);
  }
  ref auto opIndex()
  {
    pragma(inline, true);
    return _slice[];
  }
  ref auto opIndex(I...)(I i)
  {
    pragma(inline, true);
    debug assert(i.length <= dimension);
    size_t index = mixin(iota(0, i.length).map!(j => text("i[", j, "]*_indexer[", j, "]")).join("+"));
    static if (i.length == dimension)
      {
	return _slice[index];
      }
    else
      {
	enum sliceDimension = dimension - i.length;
	size_t[sliceDimension] remSizes = _sizes[i.length .. $];
	auto basePortion = _slice[index .. index + _indexer[i.length - 1]];
 	return Mat!(T, sliceDimension)(basePortion, remSizes);
      }
  }
  static if (dimension == 2)
    {
      auto identity()
      {
	debug assert(dim(0) == dim(1));
	auto n = dim(0);
	auto id = Mat!(T, 2)([n, n]);
	foreach(k; 0 .. n)
	  id[k, k] = T(1);
	return id;
      }
      bool canMultiply(Mat!(T, 2) b)
      {
	return this.dim(1) == b.dim(0);
      }
      auto opBinary(string op)(Mat!(T, 2) b)
	if (op == "*")
	  {
	    debug assert(canMultiply(b));
	    auto res = Mat!(T, 2)([this.dim(0), b.dim(1)]);
	    foreach(i; 0 .. res.dim(0))
	      foreach(k; 0 .. this.dim(1))
		foreach(j; 0 .. res.dim(1))
		  res[i, j] = res[i, j] + this[i, k] * b[k, j];
	    return res;
	  }
      auto opBinary(string op)(ulong exp)
	if (op == "^^")
	  {
	    return this.pow(identity, exp);
	  }
      mixin interiorBinPow;
    }
}

struct Mod(T, ulong mod)
{
  alias This = Mod!(T, mod);
  T _rep; T rep() {return _rep;}
  this(W)(W w)
  {
    _rep = ((cast(T) w)%mod + mod) % mod;
  }
  static auto plainConstruct(T t)
  {
    pragma(inline, true);
    debug assert(t >= 0 && t < mod);
    auto res = Mod!(T, mod).init;
    res._rep = t;
    return res;
  }
  string toString()
  {
    return to!string(rep);
  }
  debug invariant
  {
    assert(_rep >= 0 && _rep < mod);
  }
  auto opBinary(string op)(This b)
  {
    static if (op == "+")
      {
	T resrep = _rep + b._rep;
	if (resrep >= mod) resrep -= mod;
	return This.plainConstruct(resrep);
      }
    else static if (op == "-")
      {
	T resrep = _rep - b._rep;
	if (resrep < 0) resrep += mod;
	return This.plainConstruct(resrep);
      }
    else static if (op == "*")
      {
	return This(_rep * b._rep);
      }
  }
}

mixin template interiorBinPow()
{
  alias ThisType = typeof(this);
  auto pow(ThisType res, ulong exp)
    {
      if (exp < 0) debug assert(0);
      auto pow = this;
      while(exp)
	{
	  if (exp & 1)
	    res = res * pow;
	  pow = pow * pow;
	  exp >>= 1;
	}
      return res;
    }
}

// INPUT
File inputFile;
DList!string _words;
void _wordsFill()
{
  while (_words.empty) _words.insertBack(inputFile.readln.split);
}
string popWord()
{
  _wordsFill;
  auto word = _words.front;
  _words.removeFront;
  return word;
}
string peekWord()
{
  _wordsFill;
  return _words.front;
}
T next(T)()
{
  return to!T(popWord);
}
T peek(T)()
{
  return to!T(peekWord);
}
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.string;

int main(string[] argv)
{
	string line = stdin.readln();
	if (line[line.length - 1] == '\n')
		line.length--;

	if (indexOf(line, "H") != -1
	 || indexOf(line, "Q") != -1
	 || indexOf(line, "9") != -1)
	{
		write("YES");
	} else {
		write("NO");
	}
	return 0;
}

import std.stdio;
import std.algorithm;

void main()
{
    (readln.any!(a => canFind(['H','Q','9'],a))
         ? "YES" : "NO")
        .writeln;
}

import std.stdio;
import std.algorithm;
import std.conv;
import std.range;
import std.string;
import std.regex;

void main() {
  if (!match(readln, regex(`[HQ9]`)).empty) {
    "YES".writeln;
  } else {
    "NO".writeln;
  }
}

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main(){
  auto source = readln.chomp;
  auto hq = "HQ9";
  auto res = "NO";
  foreach(s; hq){
    if(source.find(s).length){
      res = "YES";
      break;
    }
  }
  res.writeln;
}

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main(){
  auto source = readln.chomp;
  auto hq = "HQ9+";
  auto res = "NO";
  foreach(s; hq){
    if(source.find(s).length){
      res = "YES";
      break;
    }
  }
  res.writeln;
}


import std.stdio;
import std.math;
import std.algorithm;
import std.array;
import std.string;
import std.conv;

void main() {

	auto elemanSayisi = stdin.readln.strip.to!int();
	auto sayilar = stdin.readln.strip.split().map!(a => to!int(a)).array();
	auto sırayaDizilmişSayılar = sayilar.sort();

	int sonuç =  0;
	int birÖncekiEleman = sırayaDizilmişSayılar[0];
	int geçiciSonuç = 0;
	//1 , 2, 4 ,3 ,3 ,2 ,1
	for ( int i = 0 ; i < sırayaDizilmişSayılar.length; i++ )
	{
		int şuandakiEleman = sırayaDizilmişSayılar[i];
		if ( şuandakiEleman ==  birÖncekiEleman)
		{
			geçiciSonuç++;
			if ( geçiciSonuç > sonuç )
				sonuç = geçiciSonuç;
		}
		else
		{

			geçiciSonuç = 1;
			birÖncekiEleman = şuandakiEleman;
		}
	}
	writeln(sonuç);

}

module acmd;

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

int main () {
   version (offline_judje) {
      stdin.reopen ("input.txt", "rt");
   }
   int n;
   readf!" %d" (n);
   int[128] cnt;
   foreach (i; 0 .. n) {
      int num;
      readf!" %d" (num);
      cnt[num]++;
   }
   writeln (maxElement (cnt[]));

   return 0;
}

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

void main()
{
    readln;

    auto arr = readln.chomp.split.map!(to!int).array;

    int [int] cnt;
    arr.each!(x => ++cnt[x]);

    auto ans = cnt.values.maxElement;
    ans.writeln;
}

import std.stdio;
int main()
{
	int a=0;
	readf(" %d", &a);
	int[] m = new int[a];
	for (int i=0; i<a; i++)
	{
		readf(" %d", &m[i]);
	}
	int[100] n;
	for (int i=0; i<100; i++)
	{
		n[i]=0;
	}
	for (int i=0; i<100; i++)
	{
		int count=0;
		for (int j=0; j<a; j++)
		{
			if (m[j]==i+1)
			{
				count=count+1;
			}
		}
		n[i]=count;
	}
	int max=-1;
	for (int i=0; i<100; i++)
	{
		if (n[i]>max)
		{
			max=n[i];
		}
	}
	writeln(max);
	return 0;
}

import std.stdio;
import std.math;
import std.algorithm;
import std.array;
import std.string;
import std.conv;

void main() {

	auto elemanSayisi = stdin.readln.strip.to!int();
	auto sayilar = stdin.readln.strip.split().map!(a => to!int(a)).array();
	auto sırayaDizilmişSayılar = sayilar.sort();

	int sonuç =  0;
	int birÖncekiEleman = sırayaDizilmişSayılar[0];
	int geçiciSonuç = 0;
	//1 , 2, 4 ,3 ,3 ,2 ,1
	for ( int i = 0 ; i < sırayaDizilmişSayılar.length; i++ )
	{
		int şuandakiEleman = sırayaDizilmişSayılar[i];
		if ( şuandakiEleman ==  birÖncekiEleman)
		{
			geçiciSonuç++;
		}
		else
		{
			if ( geçiciSonuç > sonuç )
				sonuç = geçiciSonuç;
			geçiciSonuç = 0;
			birÖncekiEleman = şuandakiEleman;
		}
	}
	writeln(sonuç);

}

import std.stdio;
import std.math;
import std.algorithm;
import std.array;
import std.string;
import std.conv;

void main() {

	auto elemanSayisi = stdin.readln.strip.to!int();
	auto sayilar = stdin.readln.strip.split().map!(a => to!int(a)).array();
	auto sırayaDizilmişSayılar = sayilar.sort();

	int sonuç =  0;
	int birÖncekiEleman = sırayaDizilmişSayılar[0];
	int geçiciSonuç = 0;
	//1 , 2, 4 ,3 ,3 ,2 ,1
	for ( int i = 0 ; i < sırayaDizilmişSayılar.length; i++ )
	{
		int şuandakiEleman = sırayaDizilmişSayılar[i];
		if ( şuandakiEleman ==  birÖncekiEleman)
		{
			geçiciSonuç++;
		}
		else
		{
			if ( geçiciSonuç > sonuç )
				sonuç = geçiciSonuç;
			geçiciSonuç = 1;
			birÖncekiEleman = şuandakiEleman;
		}
	}
	writeln(sonuç);

}


module sigod.codeforces.p281A;

import std.stdio;
import std.string;
import std.conv;

void main()
{

	stdout.write(solve(stdin.readln().strip()));
}

string solve(string str)
{
	return toUpper(str[0].to!string) ~ str[1 .. $];
}

unittest {
	assert(solve("ApPLe") == "ApPLe");
	assert(solve("konjac") == "Konjac");
}

import std.stdio;
import std.algorithm;
import std.range;
import std.ascii;

void main()
{
    string word = readln;
    (cast(char)word[0].toUpper~word[1..$]).writeln;
}

import std.stdio;
import std.string;
import std.typecons : Yes;
import std.algorithm.mutation : copy;
import std.conv : to;

void main() {
    foreach(string s; stdin.byLineCopy(Yes.keepTerminator)) {
        (s[0].toUpper.to!string ~ s[1 .. $]).copy(stdout.lockingTextWriter);
    }
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;

int main(string[] argv)
{
	string line = readln();
	if (line[line.length - 1] == '\n') line.length--;
	write(capitalize("" ~ line[0]) ~ line[1..line.length]);
	return 0;
}

//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.numeric;
pragma(inline,true);

void main(){
    dchar[] s=readln.strip.to!(dchar[]);
    writeln(toUpper(s[0]),s[1..$]);
}

//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.numeric;
pragma(inline,true);

void main(){
    dchar[] s=readln.strip.to!(dchar[]);
    writeln(toUpper(s[0])~s[1..$]);
}

import std.stdio;
import std.algorithm;
import std.conv;
import std.range;
import std.string;
import std.regex;

void main() {
  string s = readln;

  if (!match(s[0].to!string, regex(`[a-z]`)).empty) {
    (s[0].to!string.toUpper ~ s[1..$]).write;
  } else {
    s.write;
  }
}

import std.stdio;
import std.string;
import std.typecons : Yes;
import std.algorithm.mutation : copy;

void main() {
    foreach(string s; stdin.byLineCopy(Yes.keepTerminator)) {
        s.capitalize.copy(stdout.lockingTextWriter());
    }
}


// Code By H~$~C

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

void _Main() {
  long k;
  readf!" %s"(k);
  if (k <= 1024) {
    int p = 1, c = 0;
    while (p < k) {
      p *= 2, c += 1;
    }
    foreach(i; "codeforces") {
      write(i);
      if (c) {
        write(i);
        c--;
      }
    }
  }
  else {
    long p = 2;
    while (true) {
      if (pow(p, 10) < k) {
        ++p;
      }
      else break;
    }
    --p;
    long r = pow(p, 10);
    int c = 0;
    while (r < k) {
      c += 1;
      r = r / p * (p + 1);
    }
    foreach(i; "codeforces") {
      foreach(j; 0 .. p) write(i);
      if (c) {
        write(i);
        c--;
      }
    }
  }
}

void main(string[] args) {
  int tests = 1;
//  readf!" %d"(tests);
  foreach (test; 0 .. tests) _Main();
}

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

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

// floor(a^(1/k))
ulong floorKthRoot(ulong a, ulong k) {
  import core.bitop : bsr;
  import std.algorithm : min;
  if (a == 0) {
    return 0;
  } else if (k <= 1) {
    return a;
  } else if (k == 2) {
    ulong b = a, x = 0, y = 0;
    for (int e = bsr(a) & ~1; e >= 0; e -= 2) {
      x <<= 1;
      y <<= 1;
      if (b >= (y | 1) << e) {
        b -= (y | 1) << e;
        x |= 1;
        y += 2;
      }
    }
    return x;
  } else if (k <= 40) {
    // min x s.t. x^k >= 2^64
    enum ulong[] HIS =
        [0, 0, 4294967296UL, 2642246, 65536, 7132, 1626, 566, 256, 139, 85, 57,
         41, 31, 24, 20, 16, 14, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 5,
         4, 4, 4, 4, 4, 4, 4, 4, 4];
    ulong lo = 1UL << (bsr(a) / k);
    ulong hi = min(1UL << (bsr(a) / k + 1), HIS[cast(size_t)(k)]);
    for (; lo + 1 < hi; ) {
      const ulong mid = (lo + hi) / 2;
      ulong b = mid * mid;
      foreach (i; 2 .. k) b *= mid;
      ((b <= a) ? lo : hi) = mid;
    }
    return lo;
  } else if (k <= 63) {
    return ((1UL << k) <= a) ? 2 : 1;
  } else {
    return 1;
  }
}

enum S = "codeforces";
enum L = cast(int)(S.length);

void main() {
  try {
    for (; ; ) {
      const K = readLong();

      const long a = floorKthRoot(K, L);
      foreach (m; 0 .. L + 1) {
        long prod = 1;
        foreach (i; 0 .. L) {
          prod *= ((i < m) ? (a + 1) : a);
        }
        if (prod >= K) {
          foreach (i; 0 .. L) {
            foreach (_; 0 .. ((i < m) ? (a + 1) : a)) {
              write(S[i]);
            }
          }
          writeln();
          break;
        }
      }
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.numeric;
import std.stdio;
import std.typecons;

immutable string answer = "codeforces";
immutable int len = 10;

void main ()
{
	long k;
	while (readf !(" %s") (k) > 0)
	{
		long [len] s;
		s[] = 1;
		long total = 1;
		for (int i = 0; total < k; i = (i + 1) % len)
		{
			total /= s[i];
			s[i] += 1;
			total *= s[i];
		}
		foreach (i; 0..len)
		{
			foreach (j; 0..s[i])
			{
				write (answer[i]);
			}
		}
		writeln;
	}
}


import std.stdio;
import core.stdc.stdio;
import std.algorithm;
import std.math;
import std.array;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int initial_sum = 0;
	int[] bits; bits.length = n;
	foreach (int i; 0..n)
	{
		int b;
		scanf("%d", &b);
		initial_sum += (b == 0 ? 0 : 1);
		bits[i] = b;
	}
	int[][] dp; dp.length = n;
	foreach (int i; 0..n)
	{
		dp[i].length = n;
	}
	int max = int.min;
	foreach (int i; 0..n)
	{
		foreach (int j; 0..(i+1))
		{
			int cm = (i > 0 && j < i ? dp[i-1][j] : initial_sum);
			dp[i][j] = cm - bits[i] + (1 - bits[i]);
			if (dp[i][j] > max)
				max = dp[i][j];
		}
	}
	printf("%d", max);
	return 0;
}

import std.stdio;

bool[] a;
byte n, max, ans;

void maxone(int x, int y) {
	max = 0;
	bool[] b = a[].dup;
	foreach (i; x .. y)
		b[i] ^= 1;
	foreach (i; 0 .. n)
		if (b[i])
			max += 1;
}

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

	bool c;
	foreach (i; 0 .. n) {
		readf(" %b", &c);
		a ~= c;
	}

	foreach (i; 0 .. n)
		foreach (j; i .. n) {
			maxone(i, j + 1);
			if (max > ans)
				ans = max;
		}

	writeln(ans);
}

import std.stdio;
import core.stdc.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int initial_sum = 0;
	int[] bits; bits.length = n;
	foreach (int i; 0..n)
	{
		int b;
		scanf("%d", &b);
		initial_sum += (b == 0 ? 0 : 1);
		bits[i] = b;
	}
	int[] dp; dp.length = n;
	foreach (int i; 0..n)
	{
		dp[i] = initial_sum;
	}
	int max = int.min;
	foreach (int i; 0..n)
	{
		foreach (int j; 0..(i+1))
		{
			dp[j] = dp[j] - bits[i] + (1 - bits[i]);
			if (dp[j] > max)
				max = dp[j];
		}
	}
	printf("%d", max);
	return 0;
}

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

void main() {
    int n; readf("%d\n", &n);
    int[] xs = readln.split.map!(to!int).array;
    int[][] cs = new int[][n + 1];
    for (int i = 0; i < n + 1; i++) {
        cs[i] = new int[n + 1];
    }
    for (int i = 0; i < n + 1; i++) {
        cs[i][i] = 0;
        for (int j = i; j < n; j++) {
            cs[i][j + 1] = cs[i][j] + xs[j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n + 1; j++) {
            ans = max(
                ans,
                cs[0][i] + (j - i) - cs[i][j] + cs[j][n]
            );
        }
    }
    ans.writeln;
}

import std.algorithm;
import std.stdio;
import std.array;
import std.conv;
import std.string;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.map!(x => x.to!int).array;
    int maxima = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= i; j++) {
            int ones = 0;
            for(int idx = 0; idx < n; idx++) {
                if(idx >= j && idx <= i)
                    ones += 1-a[idx];
                else
                    ones += a[idx];
            }
            maxima = max(maxima,ones);
        }
    }
    maxima.writeln;
}

import std.stdio;

bool[] a;
byte ans, one;

void main() {
	byte n;

	readf(" %s", &n);

	bool c;
	foreach (i; 0 .. n) {
		readf(" %b", &c);
		a ~= c;
		if (c)
			one +=1;
	}

	foreach (i; 0 .. n - 1) {
		if (!a[i]) {
			ans += 1;
			if (a[i + 1])
				break;
		}
	}

	byte temp = 0;
	foreach (i; 0 .. n - 1) {
		if (!a[i]) {
			temp += 1;
			if (a[i + 1]) {
				if (temp > ans)
					ans = temp;
				temp = 0;
			}
		}
	}

	writeln(ans + one);
}

import std.algorithm;
import std.stdio;
import std.array;
import std.conv;
import std.string;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.map!(x => x.to!int).array;
    int maxima = -1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; j++) {
            int ones = 0;
            for(int idx = 0; idx < n; idx++) {
                if(idx >= j && idx <= i)
                    ones += 1-a[idx];
                else
                    ones += a[idx];
            }
            maxima = max(maxima,ones);
        }
    }
    maxima.writeln;
}

import std.algorithm;
import std.stdio;
import std.array;
import std.conv;
import std.string;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.map!(x => x.to!int).array;
    int maxima = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; j++) {
            int ones = 0;
            for(int idx = 0; idx < n; idx++) {
                if(idx >= j && idx <= i)
                    ones += 1-a[idx];
                else
                    ones += a[idx];
            }
            maxima = max(maxima,ones);
        }
    }
    if(n == 1)
        if(a[0] == 0)
            maxima = 1;
    maxima.writeln;
}

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

void main() {
    int n; readf("%d\n", &n);
    int[] xs = readln.split.map!(to!int).array;
    int[][] cs = new int[][n + 1];
    for (int i = 0; i < n + 1; i++) {
        cs[i] = new int[n + 1];
    }
    for (int i = 0; i < n + 1; i++) {
        cs[i][i] = 0;
        for (int j = i; j < n; j++) {
            cs[i][j + 1] = cs[i][j] + xs[j];
        }
    }
    int ans = max(cs[0][n], n - cs[0][n]);
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n + 1; j++) {
            ans = max(
                ans,
                cs[0][i] + (j - i) - cs[i][j] + cs[j][n]
            );
        }
    }
    ans.writeln;
}

import std.stdio;

bool[] a;
byte ans, one;

void main() {
	byte n;

	readf(" %s", &n);

	bool c;
	foreach (i; 0 .. n) {
		readf(" %b", &c);
		a ~= c;
		if (c)
			one +=1;
	}

	foreach (i; 0 .. n - 1) {
		if (!a[i]) {
			ans += 1;
			if (a[i + 1])
				break;
		}
	}

	byte temp = 0;
	foreach (i; 0 .. n - 1) {
		if (!a[i]) {
			temp += 1;
			if (a[i + 1]) {
				if (temp > ans)
					ans = temp;
				temp = 0;
			}
		}
	}

	if (n == 1 && a[0] == 1)
		writeln(0);
	else
		writeln(ans + one);
}

import std.stdio;

bool[] a;
byte ans, one;

void main() {
	byte n;

	readf(" %s", &n);

	bool c;
	foreach (i; 0 .. n) {
		readf(" %b", &c);
		a ~= c;
		if (c)
			one +=1;
	}

	foreach (i; 0 .. n - 1) {
		if (!a[i]) {
			ans += 1;
			if (a[i + 1])
				break;
		}
	}

	byte temp = 0;
	foreach (i; 0 .. n - 1) {
		if (!a[i]) {
			temp += 1;
			if (a[i + 1]) {
				if (temp > ans)
					ans = temp;
				temp = 0;
			}
		}
	}

	if (n == 1 && a[0] == 1)
		writeln(0);
	else
		if (n == 1 && a[0] == 0)
			writeln(1);
		else
			writeln(ans + one);
}


import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main()
{
  auto input = readln().split().map!(to!int)();
  int[][] times;
  foreach (s; stdin.byLine()) {
  	times ~= s.split().map!(to!int)().array();
  }
  foreach (i, t; times) {
  	int sum;
  	foreach (tt; times[0 .. i]) {
  		sum += tt[1];
  	}
  	while (sum + t[1] > input[1]) {
  		if (t[1] - 1 >= t[0]) {
  			t[1]--;
  		} else {
  			auto minu = sum + t[1] - input[1];
  			foreach_reverse (tt; times[0 .. i]) {
  				while (minu) {
  					if (tt[0] == tt[1]) break;
  					else {
  						tt[1]--;
  						minu--;
  						sum--;
  					}
  				}
  			}

  			if (minu) {
  				writeln("NO");
  				return;
  			}
  		}
  	}
  }

  int sum;
  foreach (tt; times) {
  	sum += tt[1];
  }
  if (sum != input[1]) {
  	writeln("NO");
  	return;
  }
  writeln("YES");
  foreach (t; times[0 .. $-1]) {
  	write(t[1], " ");
  }
  writeln(times[$-1][1]);

}

import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main()
{
  auto input = readln().split().map!(to!int)();
  int[][] times;
  foreach (i; 0 .. input[0]) {
    times ~= readln().split().map!(to!int)().array();
  }
  foreach (i, t; times) {
    int sum;
    foreach (tt; times[0 .. i]) {
        sum += tt[1];
    }
    while (sum + t[1] > input[1]) {
        if (t[1] - 1 >= t[0]) {
            t[1]--;
        } else {
            auto minu = sum + t[1] - input[1];
            foreach_reverse (tt; times[0 .. i]) {
                while (minu) {
                    if (tt[0] == tt[1]) break;
                    else {
                        tt[1]--;
                        minu--;
                        sum--;
                    }
                }
            }

            if (minu) {
                writeln("NO");
                return;
            }
        }
    }
  }

  int sum;
  foreach (tt; times) {
    sum += tt[1];
  }
  if (sum != input[1]) {
    writeln("NO");
    return;
  }
  writeln("YES");
  foreach (t; times[0 .. $-1]) {
    write(t[1], " ");
  }
  writeln(times[$-1][1]);

}

import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main()
{
  int[][] times;
  int sum, diff;

  auto input = readln().split().map!(to!int)();

  a:foreach (s; stdin.byLine()) {
  	auto t = s.split().map!(to!int)().array();

  	while (sum + t[1] > input[1]) {
  		if (t[1] - 1 >= t[0]) {
  			t[1]--;
  		} else {
  			diff = sum + t[1] - input[1];
  			foreach_reverse (tt; times) {
  				while (tt[0] != tt[1] && diff) {
  					tt[1]--;
  					diff--;
  					sum--;
  				}
  			}
  		}
  		if (diff) break a;
  	}

  	times ~= t;
  	sum += t[1];
  }

  if (sum != input[1] || diff) {
  	writeln("NO");
  } else {
  	writeln("YES");
  	foreach (t; times[0 .. $-1]) {
  		write(t[1], " ");
  	}
  	writeln(times[$-1][1]);
  }

}

import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main()
{
  int[][] times;
  int sum, diff;

  auto input = readln().split().map!(to!int)();

  a:foreach (s; stdin.byLine()) {
    auto t = s.split().map!(to!int)().array();

    while (sum + t[1] > input[1]) {
        if (t[1] - 1 >= t[0]) {
            t[1]--;
        } else {
            diff = sum + t[1] - input[1];
            foreach_reverse (tt; times) {
                while (tt[0] != tt[1]) {
                    tt[1]--;
                    diff--;
                    sum--;
                }
            }
        }
        if (diff) break a;
    }

    times ~= t;
    sum += t[1];
  }

  if (sum != input[1] || diff) {
    writeln("NO");
  } else {
    writeln("YES");
    foreach (t; times[0 .. $-1]) {
        write(t[1], " ");
    }
    writeln(times[$-1][1]);
  }

}

import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main()
{
  int[][] times;
  int sum, diff;

  auto input = readln().split().map!(to!int)();

  a:foreach (s; stdin.byLine()) {
  	auto t = s.split().map!(to!int)().array();

  	while (sum + t[1] > input[1]) {
  		if (t[1] - 1 >= t[0]) {
  			t[1]--;
  		} else {
  			diff = sum + t[1] - input[1];
  			foreach_reverse (tt; times) {
  				while (tt[0] != tt[1] && diff) {
  					tt[1]--;
  					diff--;
  					sum--;
  				}
  			}
  		}
  		if (diff) {writeln("u");break a;}
  	}

  	times ~= t;
  	sum += t[1];
  }

  if (sum != input[1] || diff) {
  	writeln("NO");
  } else {
  	writeln("YES");
  	foreach (t; times[0 .. $-1]) {
  		write(t[1], " ");
  	}
  	writeln(times[$-1][1]);
  }

}

import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main()
{
  auto input = readln().split().map!(to!int)();
  int[][] times;
  foreach (i; 0 .. input[0]) {
    times ~= readln().split().map!(to!int)().array();
  }
  foreach (i, t; times) {
    int sum;
    foreach (tt; times[0 .. i]) {
        sum += tt[1];
    }
    while (sum + t[1] > input[1]) {
        if (t[1] - 1 >= t[0]) {
            t[1]--;
        } else {
            auto minu = sum + t[1] - input[1];
            foreach_reverse (tt; times[0 .. i]) {
                while (minu) {
                    if (tt[0] == tt[1]) break;
                    else {
                        tt[1]--;
                        minu--;
                    }
                }
            }

            if (minu) {
                writeln("NO");
                return;
            }
        }
    }
  }

  int sum;
  foreach (tt; times) {
    sum += tt[1];
  }
  if (sum != input[1]) {
    writeln("NO");
    return;
  }
  writeln("YES");
  foreach (t; times[0 .. $-1]) {
    write(t[1], " ");
  }
  writeln(times[$-1][1]);

}


import std.math;
import std.stdio;

void main() {
	uint n;
	readf(`%u`, &n);
	uint[] res;

	while(n) {
		int k = cast(int)log10(n).floor.lrint, m = 10 ^^ k;

		loop: foreach(_; 0..n / m) {
			foreach(ref p; res)
				if(p / m % 10 == 0) {
					p += m;
					continue loop;
				}

			res ~= m;
		}

		n %= m;
	}

	writef("%u\n%(%u %)", res.length, res);
}

import std.stdio;
import std.range;
import std.string;
import std.algorithm;

void main() {
  string s = readln.chomp;
  int n = s.minPos!"a > b"[0] - 48;
  n.writeln;
  n.iota
    .map!(i => s.map!(c => c > i + 48 ? "1" : "0").join.find!"a!=48").join(" ").writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.functional;
import std.algorithm;
import std.container;
import std.conv;

char[] n;
long[] result;

void main() {
	n = cast(char[])(readln().strip);
	for (;;) {
		string t;
		for (int i = 0; i < n.length; ++i)
			if (n[i] == '0')
				t ~= '0';
			else {
				t ~= '1';
				--n[i];
			}
		if (to!long(t))
			result ~= to!long(t);
		else
			break;
	}
	writeln(result.length);
	writefln("%(%s %)", result);
}

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

int N;
int[] Q;

void main() {
    N = readln.chomp.to!int;

    int q = 1;
    while (format("%b", q).to!int <= 10^^6) {
        Q ~= format("%b", q).to!int;
        q++;
    }

    auto dp = new int[](N+1);
    fill(dp, 1 << 30);
    dp[0] = 0;
    auto fukugen = new int[](N+1);

    foreach (i; 0..N+1) {
        foreach (j; 0..Q.length.to!int) {
            if (i + Q[j] <= N && dp[i]+1 < dp[i+Q[j]]) {
                dp[i+Q[j]] = dp[i]+1;
                fukugen[i+Q[j]] = Q[j];
            }
        }
    }

    dp[N].writeln;
    int[] ans;
    int a = N;
    while (a > 0) {
        ans = fukugen[a] ~ ans;
        a -= fukugen[a];
    }
    ans.map!(to!string).join(" ").writeln;
}

import std.algorithm;
import std.range;
import std.stdio;
import std.string;

immutable int MAX_N = 1_000_003;
immutable int BASE  =        10;

void main ()
{
	int [] d;
	foreach (i; 0..MAX_N)
	{
		bool ok = true;
		int v = i;
		while (v > 0)
		{
			ok &= (v % BASE) < 2;
			v /= BASE;
		}
		if (ok)
		{
			d ~= i;
		}
	}

	auto f = new int [MAX_N];
	f[1..$] = int.max >> 1;
	auto p = new int [MAX_N];
	p[] = 0;
	foreach (i; 0..MAX_N)
	{
		foreach (c; d)
		{
			if (c > i)
			{
				break;
			}
			if (f[i] > f[i - c] + 1)
			{
				f[i] = f[i - c] + 1;
				p[i] = c;
			}
		}
	}

	int n;
	while (readf (" %s", &n) > 0)
	{
		int [] ans;
		while (n)
		{
			ans ~= p[n];
			n -= p[n];
		}
		writeln (ans.length);
		writefln ("%(%s %)", ans);
	}
}

import std.math;
import std.stdio;

void main() {
	uint n;
	readf(`%u`, &n);
	uint[] res;

	while(n) {
		int t, k = cast(int)log10(n).floor.lrint;

		while(true) {
			auto c = t + 10 ^^ k--;
			if(c > n) break;
			else t = c;
			if(k < 0) break;
		}

		n -= t;
		res ~= t;
	}

	writef("%u\n%(%u %)", res.length, res);
}

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

int N;
int[] Q;
Tuple!(int, int)[int] mem;

int dp(int n) {
    if (n < 10) return n;
    if (n in mem) return mem[n][0];

    mem[n] = tuple(1 << 30, -1);
    foreach (q; Q) {
        if (n >= q) {
            auto ret = dp(n-q) + 1;
            if (ret < mem[n][0]) {
                mem[n] = tuple(ret, q);
            }
        }
    }
    return mem[n][0];
}

void main() {
    N = readln.chomp.to!int;

    int q = 2;
    while (format("%b", q).to!int <= 10^^6) {
        Q ~= format("%b", q).to!int;
        q++;
    }

    reverse(Q);
    auto ans = dp(N);

    int[] ans2;
    while (N >= 10) {
        auto a = mem[N][1];
        ans2 ~= a;
        N -= a;
    }
    while (N--) {
        ans2 ~= 1;
    }
    ans2.map!(c => c.to!string).join(" ").writeln;
}

import std.stdio;
import std.range;
import std.string;
import std.algorithm;

void main() {
  auto s = readln.chomp;
  writeln(s);
  (s.minPos!"a > b"[0] - 48).iota
    .map!(i => s.map!(c => c > i + 48 ? "1" : "0").join.find!"a!=48").join(" ").writeln;
}

import std.stdio;
import std.range;
import std.string;
import std.algorithm;

void main() {
  auto s = readln.chomp;;
  (s.minPos!"a > b"[0] - 48).iota
    .map!(i => s.map!(c => c > i + 48 ? "1" : "0").join.find!"a!=48")
      .join(" ").writeln;
}


/+ dub.sdl:
    name "A"
    dependency "dunkelheit" version="1.0.1"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;

int main() {
    Scanner sc = new Scanner(stdin);
    scope(exit) assert(!sc.hasNext);

    int n;
    long[] a;
    sc.read(n, a);

    long sm = a.sum;
    int[] our = iota(n).filter!(i => i == 0 || 2 * a[i] <= a[0]).array;
    long my = our.map!(i => a[i]).sum;

    debug writeln(sm, " ", my, " ", our);

    if (sm >= my * 2) {
        writeln("0");
    } else {
        writeln(our.length);
        writeln(our.map!"a + 1".map!(to!string).join(" "));
    }
    return 0;
}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/foundation.d */

// module dkh.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/container/stackpayload.d */
// module dkh.container.stackpayload;

struct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {
    import core.exception : RangeError;

    private T* _data;
    private uint len, cap;

    @property bool empty() const { return len == 0; }
    @property size_t length() const { return len; }
    alias opDollar = length;

    inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }

    ref inout(T) opIndex(size_t i) inout {
        version(assert) if (len <= i) throw new RangeError();
        return _data[i];
    }
    ref inout(T) front() inout { return this[0]; }
    ref inout(T) back() inout { return this[$-1]; }

    void reserve(size_t newCap) {
        import core.memory : GC;
        import core.stdc.string : memcpy;
        import std.conv : to;
        if (newCap <= cap) return;
        void* newData = GC.malloc(newCap * T.sizeof);
        cap = newCap.to!uint;
        if (len) memcpy(newData, _data, len * T.sizeof);
        _data = cast(T*)(newData);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void clear() {
        len = 0;
    }

    void insertBack(T item) {
        import std.algorithm : max;
        if (len == cap) reserve(max(cap * 2, MINCAP));
        _data[len++] = item;
    }
    alias opOpAssign(string op : "~") = insertBack;
    void removeBack() {
        assert(!empty, "StackPayload.removeBack: Stack is empty");
        len--;
    }
}

/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/scanner.d */
// module dkh.scanner;

// import dkh.container.stackpayload;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    private File f;

    this(File f) {
        this.f = f;
    }
    private char[512] lineBuf;
    private char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    assert(succW());
                    x[i] = line.parse!E;
                }
            } else {
                StackPayload!E buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }

    int unsafeRead(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }

    void read(Args...)(auto ref Args args) {
        import std.exception : enforce;
        static if (args.length != 0) {
            enforce(readSingle(args[0]));
            read(args[1..$]);
        }
    }

    bool hasNext() {
        return succ();
    }
}

/*
This source code generated by dunkelheit and include dunkelheit's source code.
dunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)
dunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)
*/

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

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

int N;
int[] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }

      int[] ans;
      ans ~= 0;
      foreach (i; 1 .. N) {
        if (A[0] >= 2 * A[i]) {
          ans ~= i;
        }
      }
      int sum;
      foreach (i; ans) {
        sum += A[i];
      }
      if (2 * sum > A.sum) {
        writeln(ans.length);
        foreach (index, i; ans) {
          if (index > 0) {
            write(" ");
          }
          write(i + 1);
        }
        writeln();
      } else {
        writeln(0);
      }
    }
  } catch (EOFException e) {
  }
}


import core.bitop;
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

bool isPrime (int v)
{
	if (v < 2)
	{
		return false;
	}
	for (int d = 2; d * d <= v; d++)
	{
		if (v % d == 0)
		{
			return false;
		}
	}
	return true;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		for (int m = 1; ; m++)
		{
			if (!isPrime (n * m + 1))
			{
				writeln (m);
				break;
			}
		}
	}
}

import std.stdio;
import std.algorithm;
import std.range;
import std.string;

bool prime(int n)
{
    int i=2;
    for(;i<n/2+1;i++)
    {
        if(n%i==0)
            return true;
    }
    return false;
}
void main(string[] args)
{
    int n = 0;
    int k = 1;
    scanf("%d", &n);
    while(!prime(n*k+1))
    {
        k++;
    }
    writeln(k);
}

import std.stdio;
import std.algorithm;
import std.range;
import std.string;

bool prime(int n)
{
    int i=2;
    for(;i<n/2+1;i++)
    {
        if(n%i==0)
            return true;
    }
    return false;
}
void main(string[] args)
{
    int n = 0;
    int k = 1;
    scanf("%d", &n);
    while(prime(n*k+1))
    {
        k++;
    }
    writeln(k);
}


//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.container;
pragma(inline,true);

void main(){
    int k,n;
    readf!"%d %d"(n,k);
    readln;
    auto a=readln.splitter
                 .map!(to!int)
                 .array;
    k--;
    a.count!((x)=>x>0 && x>=a[k]).writeln;
}

import std.stdio;
import core.stdc.stdio;
import std.conv;
import std.container;

int main(string[] argv)
{
	int n, k;
	scanf("%d %d", &n, &k);
	int[] contestants = new int[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &contestants[i]);
	}
	int score = contestants[k-1];
	int result = 0;
	for (int i = 0; i < n; i++)
	{
		result += (contestants[i] > 0 && contestants[i] >= score) ? 1 : 0;
	}
	writeln(result);
	return 0;
}

import std.stdio;
void main() {
	int n, k;
	readf(" %s",&n);
	readf(" %s",&k);
	k--;
	int[] a = new int[n];
	for (int i = 0; i < n; i++) {
		readf(" %s",&a[i]);
	}
	a = a.sort.reverse;
	//writeln(a);
	int answer = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > 0 && a[i] >= a[k]) {
			answer++;
		}
	}
	writeln(answer);
}

// https://codeforces.com/problemset/problem/158/A
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

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

    string input = readln;
    int[] a = input.split.map!(x => x.to!int).array;

    a.filter!(x => (x >= a[k-1]) && (x > 0)).count.writeln;
}

// https://codeforces.com/problemset/problem/158/A
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

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

    string input = readln;
    int[] a = input.split.map!(x => x.to!int).array;

    a.count!(x => (x >= a[k-1]) && (x > 0)).writeln;
}

import std.stdio;
void main()
{
    int [100000+10]arr;
    int n,k;
    readf("%d %d ",&n,&k);
    for(int i=1;i<=n;i++)readf("%d ",&arr[i]);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(arr[i]>=arr[k] && arr[i]>0)ans++;
    }
    writeln(ans);
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k;
	scanf("%d %d", &n, &k);
	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] >= arr[k-1] && arr[i] >0)
			q++;
	printf("%d", q);
	return 0;
}

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
	int n, k; readf("%d %d\n", &n, &k);
	auto buf = readln.split.map!(to!int).array;
	(buf[0] == 0) ? writeln(0) : buf.count!(a => a>=buf[k-1] && a>0 ).writeln;
}

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
	int n, k; readf("%d %d\n", &n, &k);
	auto buf = readln.split.map!(to!int).array;
	buf.count!(a => (a >= buf[k-1]) && (a > 0) ).writeln;
}

import std.stdio;

int main(string[] argv)
{
	int n, pos;
    readf(" %d %d", &n, &pos);
	int[] a = new int[n];
	for (int i = 0; i < n; ++i)
		readf(" %d", &a[i]);
	int j = pos - 1;

	if (a[j] == 0)
		while (j >= 0 && a[j] == 0)
			--j;
	else
		while (j+1 <= n-1 && a[j] == a[j+1])
			++j;

	writeln(j+1);
	readln;
    return 0;
}

import std.stdio;
import std.conv;
import std.string;
import std.array;

void main() {
  string[] l1 = readln().chomp().split();
  auto n = to!int(l1[0]);
  auto k = to!int(l1[1]);
  string[] l2 = readln().chomp().split();
  auto tot = 0;
  for (auto i=0; i<k; i++) {
    if (to!int(l2[i]) > 0) {
      tot += 1;
    }
  }
  auto kv = to!int(l2[k-1]);
  if (kv > 0) {
    while (tot < n && to!int(l2[tot]) == kv) {
      tot += 1;
    }
  }
  writeln(tot);
}

import std.stdio, std.string, std.conv;

void main() {

	byte n, k;

	readf("%s %s\n", &n, &k);

	short max, ki;
	foreach (idx, score; readln.split) {
		if (idx == k - 1)
			ki = score.to!byte;
		if (idx > k - 1 && score.to!byte < ki || score.to!byte == 0)
			break;
		++max;
	}

	writeln(max);
}

import std.stdio : readf, readln, writeln;
import std.math : ceil;
import std.conv : to;
import std.array : split;

void main()
{
    uint[] nums;
    uint n, k;
    uint counter;
    uint pass;

    readf("%s %s\n", &n, &k);

    foreach(uint i, string num; split(readln))
    {
        uint unum = to!uint(num);
        if ((i+1)==k) pass = unum;
        nums ~= unum;
    }
    foreach(num; nums)
    {
        if (num > 0 && num >= pass) ++counter;
    }

    writeln(counter);
}

import std.stdio;

void main() {
    int n, k;
    readf("%d %d\n", &n, &k);

    int[] scores = new int[n];

    for (int i = 0; i < n-1; ++i) {
        readf("%d ", &scores[i]);
    }
    readf("%d\n", &scores[n-1]);

    int kScore = scores[k-1];
    int nextRound = 0;

    for (int i = 0; i < n; ++i) {
        if (scores[i] > 0 && scores[i] >= kScore) {
            nextRound++;
        }
    }

    writefln("%d", nextRound);
}

import std.stdio;
import std.algorithm;

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

    int[] a = new int[n];

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

    int f = a[k - 1];

    a.sort();

    int ans = 0;

    for (int i = 0; i < n; ++i) {

        if (a[i] > 0 && a[i] >= f)
            ans++;
    }

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

}

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
	int n, k; readf("%d %d\n", &n, &k);
	auto buf = readln.split.map!(to!int).array;
	(buf[0] == 0) ? writeln(0) : buf.count!(a => a>=buf[k-1]).writeln;
}

import std.stdio;
import std.conv;
import std.string;
import std.array;

void main() {
  string[] l1 = readln().chomp().split();
  auto n = to!int(l1[0]);
  auto k = to!int(l1[1]);
  string[] l2 = readln().chomp().split();
  auto tot = k;
  auto kv = to!int(l2[k-1]);
  if (kv > 0) {
    while (tot < n && to!int(l2[tot]) == kv) {
      tot += 1;
    }
    writeln(tot);
  } else {
    writeln(0);
  }
}

import std.stdio : readf, readln, writeln;
import std.math : ceil;
import std.conv : to;
import std.array : split;

void main()
{
	uint[] nums;
	uint n, k;
	uint counter;
	uint pass;

	readf("%s %s\n", &n, &k);

	foreach(uint i, string num; split(readln))
	{
		uint unum = to!uint(num);
		if (i==k) pass = unum;
		nums ~= unum;
	}
	foreach(num; nums)
	{
		if (num > 0 && num >= pass) ++counter;
	}

	writeln(counter);
}

import std.stdio;
import std.algorithm;

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

    int[] a = new int[n];

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

    a.sort();

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        if (a[i] > 0 && a[i] >= a[k - 1])
            ans++;
    }

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

}

import std.stdio;
import core.stdc.stdio;
import std.conv;
import std.container;

int main(string[] argv)
{
	int n, k;
	scanf("%d %d", &n, &k);
	int[] contestants = new int[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &contestants[i]);
	}
	int score = contestants[k];
	int result = 0;
	for (int i = 0; i < n; i++)
	{
		result += (contestants[i] > 0 && contestants[i] >= score) ? 1 : 0;
	}
	writeln(result);
	return 0;
}

import std.stdio;
void main() {
	int n, k;
	readf(" %s",&n);
	readf(" %s",&k);
	k--;
	int[] a = new int[n];
	for (int i = 0; i < n; i++) {
		readf(" %s",&a[i]);
	}
	a = a.reverse;
	int answer = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > 0 && a[i] >= a[k]) {
			answer++;
		}
	}
	writeln(answer);
}

// https://codeforces.com/problemset/problem/158/A
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

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

    string input = readln;
    int[] a = input.split.map!(x => x.to!int).array;

    a.filter!(x => (x >= a[k-1]) && (x > 0));
    a.length.writeln;
}


import std.stdio, std.string;
import std.algorithm;

double saiki(int n, int t, double p, double[][] dp)
{
    if (dp[n][t] != -1)
    {
        return dp[n][t];
    }
    if (n == 0)
    {
        dp[n][t] = 0.0;
        return 0.0;
    }
    if (t == 0)
    {
        dp[n][t] = cast(double)n;
        return cast(double)n;
    }
    auto ret0 = saiki(n - 1, t - 1, p, dp);
    auto ret1 = saiki(n, t - 1, p, dp);
    dp[n][t] = p * ret0 + (1.0 - p) * ret1;
    return dp[n][t];
}

void solve(int n, double p, int t)
{
    auto dp = new double[][](n + 1, t + 1);
    foreach (i; 0 .. n + 1)
    {
        fill(dp[i], -1);
    }
    auto res = saiki(n, t, p, dp);
    writefln("%.10f", cast(double)n - res);
}

int main(string[] args)
{
    int n, t;
    double p;
    while (readf("%d %f %d\n", &n, &p, &t) == 3)
    {
        solve(n, p, t);
    }
    return 0;
}

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

void main ()
{
	int n, t;
	real p;
	while (readf (" %s %s %s", &n, &p, &t) > 0)
	{
		real q = 1.0 - p;
		auto f = new real [] [] (t + 1, n + 1);
		foreach (ref g; f)
		{
			g[] = 0.0;
		}
		f[0][0] = 1.0;

		foreach (i; 0..t)
		{
			foreach (j; 0..n)
			{
				f[i + 1][j + 1] += f[i][j] * p;
				f[i + 1][j + 0] += f[i][j] * q;
			}
			f[i + 1][n] += f[i][n];
		}

		real res = 0.0;
		foreach (j; 0..n + 1)
		{
			res += f[t][j] * j;
		}
		writefln ("%.10f", res);
	}
}


import std.stdio, std.bigint, std.string;

void main() {
    auto a_ = readln.strip;
    auto n = a_.length;
    auto a = BigInt(a_);
    // auto b = BigInt(readln.strip);
    long b;
    scanf("%ld", &b);
    auto ans = a % b;
    auto pow10n = 1; for (int i=0; i<n; i++) pow10n = (pow10n * 10) % b;
    long left=0L;
    auto apow10i = long((a*10L)%b);
    for (int i=1; i<n; i++) {
        left = (left * 10L + (a_[i-1]-'0')) % b;
        // if (i <= 5) write(left, ' ',apow10i % b, ' ');
        auto _a = (b + (apow10i + left - left * pow10n) % b) % b;
        // writeln(_a % b);
        apow10i = (apow10i * 10L) % b;
        // if (i <= 5) writeln(left, ' ', _a, ' ', _a % b);
        if (a_[i] != '0') {
            // writeln(left, ' ', _a, ' ', _a % b);
            // writeln(i, ' ', _a % b);
            if (_a % b < ans)
                ans = _a % b;
        }
    }
    writeln(ans);
}

import std.stdio, std.bigint, std.string;

void main() {
    auto a_ = readln.strip;
    auto n = a_.length;
    auto a = BigInt(a_);
    // auto b = BigInt(readln.strip);
    long b;
    scanf("%ld", &b);

    auto ans = a % b;
    auto pow10n = 1; for (int i=0; i<n; i++) pow10n = (pow10n * 10) % b;
    long left=0L;
    auto apow10i = long((a*10L)%b);

    for (int i=1; i<n; i++) {
        left = (left * 10L + (a_[i-1]-'0')) % b;
        auto _a = (b + (apow10i + left - left * pow10n) % b) % b;
        apow10i = (apow10i * 10L) % b;
        if (a_[i] != '0') {
            if (_a % b < ans)
                ans = _a % b;
        }
    }
    writeln(ans);
}

import std.stdio;

const int N = cast(int)(2e5 + 5);

int n, mod;
int[N] s;
int[N] a, b, p10;

int min(int a, int b) { return a < b ? a : b; }

int main(string[] args)
{
	int ch;
	while ((ch = getchar()) != '\n') s[++n] = ch - '0';
	scanf("%d", &mod);
	for (int i = 1; i <= n; ++i)
		a[i] = (a[i-1] * 10 + s[i]) % mod;
	p10[0] = 1;
	for (int i = 1; i <= n; ++i) p10[i] = p10[i-1] * 10 % mod;
	for (int i = n; i; --i)
		b[i] = (b[i+1] + s[i] * p10[n - i]) % mod;
	int ans = cast(int)(2e9);
	for (int i = 1; i <= n; ++i)
	{
		if (s[i] == 0) continue;
		long t = cast(long)(b[i]) * p10[i - 1] + a[i - 1];
		ans = min(ans, cast(int)(t % mod));
	}
	writeln(ans);
	return 0;
}

import std.stdio, std.bigint, std.string;

void main() {
    auto a_ = readln.strip;
    auto n = a_.length;
    auto a = BigInt(a_);
    // auto b = BigInt(readln.strip);
    int b;
    scanf("%d", &b);
    if (n > 100) {
        writeln(b);
        writeln(a);
    }
    auto ans = a % b;
    auto pow10n = 1; for (int i=0; i<n; i++) pow10n = (pow10n * 10) % b;
    auto left=0;
    auto apow10i = int((a*10)%b);
    for (int i=1; i<n; i++) {
        left = (left * 10 + (a_[i-1]-'0')) % b;
        auto _a = (b + (apow10i + left - left * pow10n) % b) % b;
        apow10i = (apow10i * 10) % b;

        if (a_[i] != '0') {
            // writeln(left, ' ', _a, ' ', _a % b);
            if (_a % b < ans)
                ans = _a % b;
        }
    }
    writeln(ans);
}

import std.stdio, std.bigint, std.string;

void main() {
    auto a_ = readln.strip;
    auto n = a_.length;
    auto a = BigInt(a_);
    // auto b = BigInt(readln.strip);
    int b;
    scanf("%d", &b);
    if (n > 100) {
        writeln(a);
        writeln(b);
    }
    auto ans = a % b;
    // auto pow10n = (BigInt(10) ^^ n);
    auto pow10n = 1;
    for (int i=0; i<n; i++) pow10n = (pow10n * 10) % b;
    // writeln(pow10n);
    auto left=0; // BigInt(0);
    auto apow10i = int((a*10)%b);
    for (int i=1; i<n; i++) {
        left = (left * 10 + (a_[i-1]-'0')) % b;
        auto _a = (b + (apow10i + left - left * pow10n) % b) % b;
        apow10i = (apow10i * 10) % b;
        if (a_[i] != '0') {
            // writeln(left, ' ', _a, ' ', _a % b);
            if (_a % b < ans)
                ans = _a % b;
        }
    }
    writeln(ans);
}

import std.stdio, std.bigint, std.string;

void main() {
    auto a_ = readln.strip;
    auto n = a_.length;
    auto a = BigInt(a_);
    // auto b = BigInt(readln.strip);
    int b;
    scanf("%d", &b);
    auto ans = a % b;
    // auto pow10n = (BigInt(10) ^^ n);
    auto pow10n = 1;
    for (int i=0; i<n; i++) pow10n = (pow10n * 10) % b;
    // writeln(pow10n);
    auto left=0; // BigInt(0);
    auto apow10i = int((a*10)%b);
    for (int i=1; i<n; i++) {
        left = (left * 10 + (a_[i-1]-'0')) % b;
        auto _a = (b + (apow10i + left - left * pow10n) % b) % b;
        apow10i = (apow10i * 10) % b;
        if (a_[i] != '0') {
            // writeln(left, ' ', _a, ' ', _a % b);
            if (_a % b < ans)
                ans = _a % b;
        }
    }
    writeln(ans);
}

import std.stdio;

const int N = cast(int)(2e5 + 5);

int n, mod;
int[N] s, a, b, p10;

int min(int a, int b) { return a < b ? a : b; }

int main(string[] args)
{
	int ch;
	while ((ch = getchar()) != '\n') s[++n] = ch - '0';
	scanf("%d", &mod);
	for (int i = 1; i <= n; ++i)
		a[i] = (a[i-1] * 10 + s[i]) % mod;
	p10[0] = 1;
	for (int i = 1; i <= n; ++i) p10[i] = p10[i-1] * 10 % mod;
	for (int i = n; i; --i)
		b[i] = (b[i+1] + s[i] * p10[n - i]) % mod;
	int ans = cast(int)(2e9);
	for (int i = 1; i <= n; ++i)
	{
		if (s[i] == '0') continue;
		ans = min(ans, (b[i] * p10[i - 1] + a[i - 1]) % mod);
	}
	writeln(ans);
	return 0;
}

import std.stdio;

const int N = cast(int)(2e5 + 5);

int n, mod;
string s;
int[N] a, b, p10;

int min(int a, int b) { return a < b ? a : b; }

int main(string[] args)
{
	s = readln();
	n = cast(int)(s.length);
	s = " " ~ s;
	scanf("%d", &mod);
	for (int i = 1; i <= n; ++i)
		a[i] = (a[i-1] * 10 + s[i] - '0') % mod;
	p10[0] = 1;
	for (int i = 1; i <= n; ++i) p10[i] = p10[i-1] * 10 % mod;
	for (int i = n; i; --i)
		b[i] = (b[i+1] + (s[i] - '0') * p10[n - i]) % mod;
	int ans = cast(int)(2e9);
	for (int i = 1; i <= n; ++i)
	{
		if (s[i] == '0') continue;
		ans = min(ans, (b[i] * p10[i - 1] + a[i - 1]) % mod);
	}
	writeln(ans);
	return 0;
}


module main;
__gshared:
import core.bitop, std.algorithm, std.bigint, std.bitmanip, std.complex,
	std.container, std.conv, std.datetime, std.functional, std.math, std.meta,
	std.numeric, std.parallelism, std.random, std.range, std.regex, std.stdio,
	std.string, std.traits, std.typecons, std.uni, std.variant;

alias pair(X, Y) = Tuple!(X, "fi", Y, "se");
alias mp = make_pair;
alias pii = pair!(int, int);
alias pll = pair!(long, long);
alias gcd = std.numeric.gcd;
alias lint = long;
alias rbt = RedBlackTree;
///modulo
enum mod = 10 ^^ 9 + 7, mod2 = mod + 2;
public
{
	pure nothrow
	{
		///lcm
		T lcm(T)(auto ref T a, auto ref T b)
		{
			return a / gcd(a, b) * b;
		}
		///make_pair
		pair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)
		{
			return tuple!(X, "fi", Y, "se")(x_, y_);
		}
		///BigInt greatest common divizor
		BigInt gcd(BigInt a, BigInt b)
		{
			while (b)
			{
				a %= b;
				swap(a, b);
			}
			return a;
		}
		///square
		@property X sqr(X)(in X a_)
		{
			return a_ * a_;
		}
		///cube
		@property X cub(X)(in X a_)
		{
			return a_ * a_ * a_;
		}
		///integer size
		int sz(T)(T a) if (hasLength!T)
		{
			return cast(int) a.length;
		}
		///posicion lower bound
		size_t lowb(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			size_t l = 0, r = a.length;
			while (r - l > 1)
			{
				auto m = (l + r) >> 1;
				if (!(a[m] < g))
					r = m;
				else
					l = m;
			}
			return (!(a[l] < g)) ? l : r;
		}
		///posicion upper bound
		size_t upb(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			size_t l = 0, r = a.length;
			while (r - l > 1)
			{
				auto m = (l + r) >> 1;
				if (g < a[m])
					r = m;
				else
					l = m;
			}
			return (g < a[l]) ? l : r;
		}
		///posicion binary search
		size_t binf(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			auto pos = lowb(a, g);
			return (g == a[pos]) ? pos : a.length;
		}
		///binary search
		bool binary_search(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			return binf(a, g) != a.length;
		}
	}
	///write an array
	void putarr(X)(in X a, in char ch = ' ') if (isInputRange!X)
	{
		writefln("%(%s" ~ ch ~ "%)", a);
	}
	///write a matrix
	void putarr(X)(in X a)
			if (isInputRange!X && isInputRange!(ElementType!X) && !isSomeString!(ElementType!X))
	{
		writefln("%(%(%s %)\n%)", a);
	}
	///get an array
	bool getarr(X)(X a, in size_t n)
	{
		bool b = 1;
		foreach (ref i; a[0 .. n])
			b = input(&i);
		return b;
	}
	///read without format
	bool input(T...)(ref T ptrs) if (ptrs.length > 0)
	{
		size_t s = 0;
		foreach (ref e; ptrs)
		{
			if (isSomeChar!(Unqual!(typeof(e))))
				s += readf(" %c", &e);
			else
				s += readf(" %s", &e);
		}
		return s == ptrs.length;
	}
	///readln without format
	bool read(T...)(ref T ptrs) if (ptrs.length > 0)
	{
		size_t s = 0;
		foreach (ref e; ptrs)
		{
			if (isSomeChar!(Unqual!(typeof(e))))
				s += readf(" %c", &e);
			else
				s += readf(" %s", &e);
		}
		readln;
		return s == ptrs.length;
	}
	///opening file
	nothrow auto inf(in char* name)
	{
		return freopen(name, "r", core.stdc.stdio.stdin);
	}
	///closing file
	nothrow auto ouf(in char* name)
	{
		return freopen(name, "w", core.stdc.stdio.stdout);
	}
	///parsing array from line
	@property auto arread(T)()
	{
		return readln.splitter.map!(to!(T)).array;
	}
	///outbuffer
	void enter(T...)(T args)
	{
		writeln(args);
		stdout.flush;
	}
}
//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin
//cumulativeFold return static heapify join filter foreach
//------------------------------------------program beginning--------------------------

void main()
{
	version (home)
	{
		freopen("input.txt", "r", core.stdc.stdio.stdin);
		//freopen("output.txt", "w", core.stdc.stdio.stdout);
		/*StopWatch sw;
		sw.start;
		scope (exit)
		{
			sw.stop;
			stderr.writefln("\nTime: %d ms", sw.peek.msecs);
		}*/
	}
	int k;
	loop: while (read(k))
	{
		foreach (ch; 'a' .. 'z' + 1)
		{
			int i;
			while (i * (i + 1) / 2 <= k)
				i++;
			k -= i * (i - 1) / 2;
			foreach (_; 0 .. i)
			{
				write(cast(char) ch);
			}
		}
		writeln;
	}
}

/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.6.0"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;

int main() {
    auto sc = new Scanner(stdin);
    int k;
    sc.read(k); k *= 2;
    if (k == 0) {
        writeln("miku");
        return 0;
    }
    string s;
    char nw = 'a';
    while (k) {
        foreach (i; 1..1000) {
            if (k < (i+1)*(i)) {
                k -= i*(i-1);
                s ~= nw.repeat.take(i).array;
                nw++;
                break;
            }
        }
    }
    writeln(s);
    return 0;
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/foundation.d */
// module dcomp.foundation;

static if (__VERSION__ <= 2070) {
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
version (X86) static if (__VERSION__ < 2071) {
    import core.bitop : bsf, bsr, popcnt;
    int bsf(ulong v) {
        foreach (i; 0..64) {
            if (v & (1UL << i)) return i;
        }
        return -1;
    }
    int bsr(ulong v) {
        foreach_reverse (i; 0..64) {
            if (v & (1UL << i)) return i;
        }
        return -1;
    }
    int popcnt(ulong v) {
        int c = 0;
        foreach (i; 0..64) {
            if (v & (1UL << i)) c++;
        }
        return c;
    }
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            if (f.eof) return false;
            line = lineBuf[];
            f.readln(line);
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else {
                auto buf = line.split.map!(to!E).array;
                static if (isStaticArray!T) {

                    assert(buf.length == T.length);
                }
                x = buf;
                line.length = 0;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }
    int read(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
}

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

immutable int limit = 1003;

void main ()
{
	auto f = new int [limit];
	f[0] = 0;
	f[1] = 0;
	foreach (j; 2..limit)
	{
		f[j] = int.max;
		foreach (k; 1..j)
		{
			f[j] = min (f[j], f[k] + f[j - k] + k * (j - k));
		}
	}
	debug
	{
		foreach (j; 0..limit)
		{
			writefln ("%6s: %6s", j, f[j]);
		}
	}

	int n;
	while (readf (" %s", &n) > 0)
	{
		string res;
		foreach (c; 'a'..'p')
		{
			int len = 0;
			while (f[len + 1] <= n)
			{
				len += 1;
			}
			n -= f[len];
			foreach (i; 0..len)
			{
				res ~= c;
			}
		}
		writeln (res);
	}
}

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

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum LIM = 10^^5 + 5;

void main() {
  auto prev = new int[LIM];
  prev[] = -1;
  prev[0] = 0;
  foreach (i; 0 .. 3) {
    foreach_reverse (x; 0 .. LIM) {
      if (prev[x] != -1) {
        for (int a = 2; x + a * (a - 1) / 2 < LIM; ++a) {
          const xx = x + a * (a - 1) / 2;
          if (prev[xx] == -1) {
            prev[xx] = a;
          }
        }
      }
    }
  }
  foreach (x; 0 .. LIM) {
    assert(prev[x] != -1);
  }

  try {
    for (; ; ) {
      const K = readInt();

      int[] as;
      as ~= 1;
      for (int x = K; x > 0; ) {
        const a = prev[x];
        as ~= a;
        x -= a * (a - 1) / 2;
      }

      string ans;
      foreach (i, a; as) {
        ans ~= (cast(char)('a' + i)).repeat(a).array;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

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

void main() {
    auto N = readln.chomp.to!int;

    if (N == 0) {
        "a".writeln;
        return;
    }

    string ans = "";
    char c = 'a';

    while (N > 0) {
        ans ~= c;
        int tmp = 1;
        while (N - tmp >= 0) {
            N -= tmp;
            ans ~= c;
            tmp += 1;
        }
        c += 1;
    }

    ans.writeln;
}

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

void main() {
    auto N = readln.chomp.to!int;

    string ans = "";
    char c = 'a';

    while (N > 0) {
        ans ~= c;
        int tmp = 1;
        while (N - tmp >= 0) {
            N -= tmp;
            ans ~= c;
            tmp += 1;
        }
        c += 1;
    }

    ans.writeln;
}

module main;
__gshared:
import core.bitop, std.algorithm, std.bigint, std.bitmanip, std.complex,
	std.container, std.conv, std.datetime, std.functional, std.math, std.meta,
	std.numeric, std.parallelism, std.random, std.range, std.regex, std.stdio,
	std.string, std.traits, std.typecons, std.uni, std.variant;

alias pair(X, Y) = Tuple!(X, "fi", Y, "se");
alias mp = make_pair;
alias pii = pair!(int, int);
alias pll = pair!(long, long);
alias gcd = std.numeric.gcd;
alias lint = long;
alias rbt = RedBlackTree;
///modulo
enum mod = 10 ^^ 9 + 7, mod2 = mod + 2;
public
{
	pure nothrow
	{
		///lcm
		T lcm(T)(auto ref T a, auto ref T b)
		{
			return a / gcd(a, b) * b;
		}
		///make_pair
		pair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)
		{
			return tuple!(X, "fi", Y, "se")(x_, y_);
		}
		///BigInt greatest common divizor
		BigInt gcd(BigInt a, BigInt b)
		{
			while (b)
			{
				a %= b;
				swap(a, b);
			}
			return a;
		}
		///square
		@property X sqr(X)(in X a_)
		{
			return a_ * a_;
		}
		///cube
		@property X cub(X)(in X a_)
		{
			return a_ * a_ * a_;
		}
		///integer size
		int sz(T)(T a) if (hasLength!T)
		{
			return cast(int) a.length;
		}
		///posicion lower bound
		size_t lowb(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			size_t l = 0, r = a.length;
			while (r - l > 1)
			{
				auto m = (l + r) >> 1;
				if (!(a[m] < g))
					r = m;
				else
					l = m;
			}
			return (!(a[l] < g)) ? l : r;
		}
		///posicion upper bound
		size_t upb(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			size_t l = 0, r = a.length;
			while (r - l > 1)
			{
				auto m = (l + r) >> 1;
				if (g < a[m])
					r = m;
				else
					l = m;
			}
			return (g < a[l]) ? l : r;
		}
		///posicion binary search
		size_t binf(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			auto pos = lowb(a, g);
			return (g == a[pos]) ? pos : a.length;
		}
		///binary search
		bool binary_search(T, X)(T a, auto ref X g)
				if (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))
		{
			return binf(a, g) != a.length;
		}
	}
	///write an array
	void putarr(X)(in X a, in char ch = ' ') if (isInputRange!X)
	{
		writefln("%(%s" ~ ch ~ "%)", a);
	}
	///write a matrix
	void putarr(X)(in X a)
			if (isInputRange!X && isInputRange!(ElementType!X) && !isSomeString!(ElementType!X))
	{
		writefln("%(%(%s %)\n%)", a);
	}
	///get an array
	bool getarr(X)(X a, in size_t n)
	{
		bool b = 1;
		foreach (ref i; a[0 .. n])
			b = input(&i);
		return b;
	}
	///read without format
	bool input(T...)(ref T ptrs) if (ptrs.length > 0)
	{
		size_t s = 0;
		foreach (ref e; ptrs)
		{
			if (isSomeChar!(Unqual!(typeof(e))))
				s += readf(" %c", &e);
			else
				s += readf(" %s", &e);
		}
		return s == ptrs.length;
	}
	///readln without format
	bool read(T...)(ref T ptrs) if (ptrs.length > 0)
	{
		size_t s = 0;
		foreach (ref e; ptrs)
		{
			if (isSomeChar!(Unqual!(typeof(e))))
				s += readf(" %c", &e);
			else
				s += readf(" %s", &e);
		}
		readln;
		return s == ptrs.length;
	}
	///opening file
	nothrow auto inf(in char* name)
	{
		return freopen(name, "r", core.stdc.stdio.stdin);
	}
	///closing file
	nothrow auto ouf(in char* name)
	{
		return freopen(name, "w", core.stdc.stdio.stdout);
	}
	///parsing array from line
	@property auto arread(T)()
	{
		return readln.splitter.map!(to!(T)).array;
	}
	///outbuffer
	void enter(T...)(T args)
	{
		writeln(args);
		stdout.flush;
	}
}
//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin
//cumulativeFold return static heapify join filter foreach
//------------------------------------------program beginning--------------------------

void main()
{
	version (home)
	{
		freopen("input.txt", "r", core.stdc.stdio.stdin);
		//freopen("output.txt", "w", core.stdc.stdio.stdout);
		/*StopWatch sw;
		sw.start;
		scope (exit)
		{
			sw.stop;
			stderr.writefln("\nTime: %d ms", sw.peek.msecs);
		}*/
	}
	int k;
	loop: while (read(k))
	{
		foreach (ch; 'a' .. 'z' + 1)
		{
			int i = 1;
			while (i * (i - 1) / 2 <= k)
				i++;
			k -= i * (i - 1) / 2;
			foreach (_; 0 .. i - 1)
			{
				write(cast(char) ch);
			}
		}
		writeln;
	}
}

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

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum LIM = 10^^5 + 5;

void main() {
  auto prev = new int[LIM];
  prev[] = -1;
  prev[0] = 0;
  foreach (i; 0 .. 3) {
    foreach_reverse (x; 0 .. LIM) {
      if (prev[x] != -1) {
        for (int a = 2; x + a * (a - 1) / 2 < LIM; ++a) {
          const xx = x + a * (a - 1) / 2;
          if (prev[xx] == -1) {
            prev[xx] = a;
          }
        }
      }
    }
  }
  foreach (x; 0 .. LIM) {
    assert(prev[x] != -1);
  }

  try {
    for (; ; ) {
      const K = readInt();

      int[] as;
      for (int x = K; x > 0; ) {
        const a = prev[x];
        as ~= a;
        x -= a * (a - 1) / 2;
      }

      string ans;
      foreach (i, a; as) {
        ans ~= (cast(char)('a' + i)).repeat(a).array;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


import std.stdio;

int main() {
    debug stdin = File("in.txt", "r");

    //writeln("%s",
    int n;
    readf(" %s", &n);
    foreach (k; 1..5) {
        int[4] gs;
        readf(" %s %s %s %s", &gs[0], &gs[1], &gs[2], &gs[3]);
        foreach (i; 0..2) {
            foreach (j; 2..4) {
                if (gs[i] + gs[j] <= n) {
                    writefln("%s %s %s", k, gs[i], n - gs[i]);
                    return 0;
                }
            }
        }
    }
    writeln("-1");

    return 0;
}

import std.stdio;

void main() {
    debug stdin = File("input.txt", "r");

    int n;
    readf(" %s", &n);
    foreach (i; 0 .. 4) {
        int[] a = new int[2];
        int[] b = new int[2];
        readf(" %s %s %s %s", &a[0], &a[1], &b[0], &b[1]);
        foreach (j; 0 .. 2) {
            foreach (k; 0 .. 2) {
                if (a[j] + b[k] <= n) {
                    writeln(i + 1, " ", n - b[k], " ", b[k]);
                    return;
                }
            }
        }
    }

    writeln(-1);
}


import std.stdio, std.algorithm, std.array, std.math, std.typecons, std.bigint, std.conv;

void main()
{
    int k;
    scanf("%d", &k);
    long res1 = 2UL^^k - 2;
    BigInt n = 4;
    BigInt res2 = powmod(n, to!BigInt(res1), to!BigInt(10^^9 + 7));

    writeln((res2 * to!BigInt(6)) % (10^^9 + 7));
}

// Cheese-Cracker: cheese-cracker.github.io

const ll MOD = to!long(1e9) + 7L;
ll modexp(ll base, ll exp){
    ll x = base % MOD;
    ll y = exp;
    ll res = 1;
    while(y > 0){
        if(y & 1){
            res *= x; res %= MOD;
        }
        x *= x; x %= MOD;
        y >>= 1;
    }
    return res;
}

void solve(){
    ll k = scan;
    ll ex = 1;
    for(int i = 0; i < k; ++i) ex *= 2;
    ll res = 6;
    res *= modexp(4, ex-2);
    res %= MOD;
    writeln(res);
}

void main(){
    solve;
}

/**************    *****    That's All Folks!    *****    **************/
import std.stdio, std.range, std.conv, std.typecons, std.algorithm, std.container, std.math;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");


module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string read_string() {
                while (tokens.empty) {
                tokens = readln.split;
        }
        auto token = tokens.front;
                tokens.popFront;
                return token;
        }

        int read_int() {
                return read_string.to!int;
        }

        double read_double() {
                return read_string.to!double;
        }
        string[] tokens;
}

void main() {
        IO cin;
        int t = 1;
        // int t = cin.read_int;
        while (t--) {
                double d = cin.read_double;
                double L = cin.read_double;
                double v1 = cin.read_double;
                double v2 = cin.read_double;

                double rel_vel = v1 + v2;
                double dist = L - d;
                writefln("%.*f", 18, (dist) / (rel_vel));
        }
}

module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string read_string() {
                while (tokens.empty) {
                tokens = readln.split;
        }
        auto token = tokens.front;
                tokens.popFront;
                return token;
        }

        int read_int() {
                return read_string.to!int;
        }

        double read_double() {
                return read_string.to!double;
        }
        string[] tokens;
}

void main() {
        IO cin;
        int t = 1;
        // int t = cin.read_int;
        while (t--) {
                double d = cin.read_double;
                double L = cin.read_double;
                double v1 = cin.read_double;
                double v2 = cin.read_double;

                double rel_vel = v1 + v2 + 0.0;
                double dist = L - d - 0.0;
                writefln("%.*f", 18, (dist) / (rel_vel));
        }
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
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.ascii, std.typecons;

void main()
{
    immutable int MD = 10 ^^ 9 + 7;
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    int[] dp;
    dp ~= 0;
    dp ~= 2;
    dp ~= 4;
    foreach (i; 3 .. max(n, m) + 1) {
        dp ~= (dp[i-1] + dp[i-2]) % MD;
    }

    debug { dp.writeln; }

    int ans = (((dp[n] + dp[m] - 2) % MD) + MD) % MD;

    ans.writeln;
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

immutable int mod = 10 ^^ 9 + 7;
immutable int limit = 100_005;

void main ()
{
	auto f = new int [limit];
	f[0] = 1;
	f[1] = 1;
	foreach (i; 2..limit)
	{
		f[i] = (f[i - 1] + f[i - 2]) % mod;
	}

	int m, n;
	while (readf !(" %s %s") (&m, &n) > 0)
	{
		int res = 0;
		res = (res + f[m]) % mod;
		res = (res + f[n]) % mod;
		res = (res + mod - 1) % mod;
		res = (res * 2) % mod;
		writeln (res);
	}
}


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

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

    int [int] cnt;
    readln.chomp.split.map!(to!int).array.each!(x => ++cnt[x]);

    debug { cnt.writeln; }

    auto okDays = (int days) => cnt.values.map!(x => x / days).sum >= n;
    auto ans = okDays(1) ? (101).iota.dropOne.until!(days => !okDays(days)).array.back : 0;

    ans.writeln;
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	int n, m;
	while (readf (" %s %s", &n, &m) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		auto b = new int [101];
		foreach (c; a)
		{
			b[c] += 1;
		}
		int res = 1;
		while (b.map !(x => x / res).sum >= n)
		{
			res += 1;
		}
		writeln (res - 1);
	}
}

import std.algorithm, std.conv, std.range, std.stdio;
void main () {
	int r = 1, n = readln.split[0].to!int;
	int [101] b;
	foreach (c; readln.split) b[c.to!int]++;
	while (b[].map !(x => x / r).sum >= n) r++;
	writeln (r - 1);
}