#!/usr/bin/perl
($w,$l)=($ARGV[0]||0,$ARGV[1]||50);
substr($w x= 3,-($n+=3**($_-1))-1,1)=~tr/01/10/ for 0..log($l)/log(3);
print substr($w,0,$l),"\n"