uses math;

var i,l,n,pz,pk:longint;
    s:string;

  procedure make_step(var x,l:longint);
   begin
    x:=x+l;
    if x=0 then begin x:=2; l:=-l; end else
    if x>n then begin x:=n-1; l:=-l; end;
   end;

  procedure go_out(x,y,t:longint);
   begin
    if x=y then
     begin
      writeln('Controller ',t);
      halt;
     end;
   end;

 begin
  readln(n,pz,pk);
  readln(s);
  if s='to tail' then l:=1 else l:=-1;
  readln(s);
  for i:=1 to length(s) do
   begin
    if s[i]='1' then
     begin
      make_step(pk,l);
      if l=1 then
       begin
        if pk=1 then pz:=n else pz:=1;
       end else
        begin
         if pk=n then pz:=1 else pz:=n;
        end;
      go_out(pk,pz,i);
     end else
      begin
       if l=1 then
        begin
         if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);
        end else
         begin
          if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);
         end;
       go_out(pk,pz,i);
       make_step(pk,l);
       go_out(pk,pz,i);
      end;
   end;
  writeln('Stowaway');
 end.

var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=m then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if f then begin
    if s[i]='1' then begin
      m:=1;
    end else begin
      if m-k>=0 then begin
        if (m-k>1) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end;
    end;
  end else begin
    if s[i]='1' then begin
      m:=n;
    end else begin
      if k-m>=0 then begin
        if (k-m>1) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end;
    end;
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

const  fin='';
       fout='';

var  f:text;
     n,x,y,dir,m,res:longint;
     s:string;
     kt:boolean;

procedure nhap;
begin
     assign(f,fin);
     reset(f);
     readln(f,n,y,x);
     readln(f,s);
     if s='to head' then dir:=-1 else dir:=1;
     readln(f,s);
     close(f);
end;

procedure run1;
begin
     x:=x+dir;
     if x=0 then
     begin
          x:=2;
          dir:=1;
     end
     else if x>n then
          begin
               x:=n-1;
               dir:=-1;
          end;
end;

procedure run2(dir:longint);
begin
     if (y+dir>=1) and (y+dir<=n) then y:=y+dir;
end;

procedure xuly;
var  i:longint;
begin
     m:=length(s);
     kt:=false;
     for i:=1 to m do
     if s[i]='0' then
     begin
          if (y-x)*dir < 0 then run2(-dir) else run2(dir);
          run1;
          if x=y then
          begin
               kt:=true;
               res:=i;
               exit;
          end;
     end
     else
     begin
          run1;
          if dir=-1 then y:=n
          else y:=1;
     end;
end;

procedure xuat;
begin
     assign(f,fout);
     rewrite(f);
     if kt=false then writeln(f,'Stowaway')
     else writeln(f,'Controller ',res);
     close(f);
end;

begin
     nhap;
     xuly;
     xuat;
end.

var n,m,j,i,k,l,z,temp:longint;s,s1:string;
procedure xx(f:longint);
 begin
  if (temp=-1) and (k>z) and (z>1) then z:=z+temp else
  if (temp=-1) and (k<z) and (z<n) then z:=z+1 else
  if (temp=1)  and (k<z) and (z<n) then z:=z+temp else
  if (temp=1)  and (k>z) and (z>1) then z:=z-1;

  k:=k+temp;
  if (k=1)or(k=n) then temp:=temp*-1;
  if k=z then begin writeln('Controller ',f);halt;end;
 end;
procedure zz(f:longint);
 begin
  if f=length(s) then begin writeln('Stowaway');halt;end;
  k:=k+temp;
  if (k=1)or(k=n) then temp:=temp*-1;
  if k=1 then z:=n else
  if k=n then z:=1 else
  if temp>0 then z:=1 else
  if temp<0 then z:=n;
 end;
begin
{assign(input,'input.txt');reset(input);
assign(output,'output.txt');rewrite(output);  }
readln(n,z,k);
readln(s1);
if s1='to head' then temp:=-1 else temp:=1;
readln(s);
for i:=1 to length(s) do
  if s[i]='0' then xx(i) else zz(i);
end.

var
 n,m,k,y,i:longint;
 s:string;
 c:char;
begin
readln(n,m,k);
readln(s);
if s='to head' then y:=-1 else y:=1;
i:=0;
while not eoln do
 begin
  read(c);
  inc(i);
  if c='0' then
   begin
    if (m<>1)and(m<>n) then
     if k>m then m:=m-1 else m:=m+1;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if k=m then
     begin
      writeln('Controller ',i);
      halt;
     end;
   end else
  if c='1' then
   begin
    m:=0;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if (y=-1)or(k=1) then m:=n else m:=1;
   end;
 end;
writeln('Stowaway');
end.var
 n,m,k,y,i:longint;
 s:string;
 c:char;
begin
readln(n,m,k);
readln(s);
if s='to head' then y:=-1 else y:=1;
i:=0;
while not eoln do
 begin
  read(c);
  inc(i);
  if c='0' then
   begin
    if (m<>1)and(m<>n) then
     if k>m then m:=m-1 else m:=m+1;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if k=m then
     begin
      writeln('Controller ',i);
      halt;
     end;
   end else
  if c='1' then
   begin
    m:=0;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if n-k>k-1 then m:=n else m:=1;
   end;
 end;
writeln('Stowaway');
end.

var n,x,y,g,max,t,i,j:longint;
    s:string;

procedure tt(x:longint);
var k:longint;
 begin
  k:=0;
  if g>0 then begin
               if x>=y then k:=x-y
                       else k:=2*n-x-y;
              end
         else begin
               if x<=y then k:=y-x
                       else k:=y-1+x-1;
              end;
  if k>max then begin
                 max:=k;
                 t:=x;
                end;
 end;

 begin
  readln(n,x,y);
  readln(s);
  if s[length(s)]='d' then g:=-1
                      else g:=1;
  readln(s);
  for i:=1 to length(s)-1 do
   begin
    if (y=1) then g:=1;
    if (y=n) then g:=-1;
    max:=-1;
    t:=x;
    if s[i]='0' then begin
                      y:=y+g;

                      if (x-1>=1) and (x-1<>y-g) and (x-1<>y) then tt(x-1);
                      if (x+1<=n) and (x+1<>y-g) and (x+1<>y) then tt(x+1);
                      tt(x);

                      x:=t;

                      if x=y-g then begin
                                     writeln('Controller ',i);
                                     halt;
                                    end;
                     end
                else begin
                      y:=y+g;

                      for j:=1 to n do
                       if (j<>y) then tt(j);

                      x:=t;
                     end;
    if x=y then begin
                 writeln('Controller ',i);
                 halt;
                end;
   end;
  writeln('Stowaway');
 end.

var
b:array[1..10000] of char;
n,m,i,k,l,j,p:longint;
s:string;
begin
readln(n,m,k);
readln(s);
if s='to tail' then p:=1 else p:=0;
i:=0;
while not eoln do
 begin
  inc(i);
  read(b[i]);
 end;
if m>k then  l:=n
else l:=1;
for j:=1 to i do
 begin
  if b[j]='0' then
   if p=0 then
     dec(k) else inc(k) else
  begin
   if p=0 then
     dec(k)
     else inc(k);
    if p=0 then l:=n else l:=1;
  end;
  if k=l then begin write('Controller ',j); exit;end;
  if k=n then p:=0;
  if k=1 then p:=1;
 end;
write('Stowaway');
end.

var n,m,k,d,i:integer;
    s:string[202];
begin
  readln(n,k,m);
  readln(s);
  if s='to head'then d:=-1
  else d:=1;
  read(s);
  for i:=1to length(s)do
    begin
      if m=1then d:=1;
      if m=n then d:=-1;
      m:=m+d;
      if'0'=s[i]then
        begin
          if(k+d<=n)and(d+k>=1)then k:=k+d;
        end
      else
        begin
          if d=1then k:=1
          else k:=n;
        end;
      if m=k then
        begin
          writeln('Controller ',i);
          halt;
        end;
    end;
  write('Stowaway')
end.

var x,xenemy,incx:LongInt;
s:ansistring;
n:LongInt;
i:LongInt;
procedure fail;
begin
  writeln('Controller ',i);
  halt;
end;

begin
 // assign(input,'C:/input.txt');reset(input);
  readln(n,x,xenemy);
  readln(s);
  if s='to head' then incx:=-1
  else incx:=1;
  readln(s);
  for i:=1 to length(s) do
    if s[i]='0' then
    begin
      if x<xenemy then dec(x)
      else
      if x>xenemy then inc(x);

      if x=0 then x:=1;
      if x=n+1 then x:=n;

      if x=xenemy then fail;

      inc(xenemy,incx);
      if xenemy=0 then
      begin
        xenemy:=2;
        incx:=1;
      end
      else
      if xenemy=n+1 then
      begin
        xenemy:=n-1;
        incx:=-1;
      end;

      if x=xenemy then fail;
    end
   else
   begin
     inc(xenemy,incx);
     if xenemy=0 then
     begin
       xenemy:=2;
       incx:=1;
     end
     else
     if xenemy=n+1 then
     begin
       xenemy:=n-1;
       incx:=-1;
     end;

     if (incx=1)and(xenemy<>1) then x:=1
     else
     if (incx=1) then x:=n;

     if (incx=-1)and(xenemy<>n) then x:=n
     else
     if (incx=-1) then x:=1;
   end;
   writeln('Stowaway');
end.

uses math;
var
        n,m,k,l,tt:longint;
        s,t:string;
procedure nhap;
begin
        readln(n,m,k);
        readln(t);
        readln(s);
        l:=length(s);
        if t='to head' then tt:=-1 else tt:=1;
end;
procedure xuly;
var
        i:longint;
begin
        for i:=1 to l do
        begin
                if s[i]='0' then
                begin
                        if tt=-1 then
                        begin
                                if m<k then m:=math.max(1,m-1)
                                else m:=math.min(n,m+1);
                        end
                        else
                        begin
                                if m>k then m:=math.min(n,m+1)
                                else m:=math.max(1,m-1);
                        end;
                        k:=k+tt;
                        if k=m then
                        begin
                                writeln('Controller ',i);
                                exit;
                        end;
                end
                else
                begin
                        k:=k+tt;
                        if tt=-1 then
                        begin
                                if k<n then m:=n else m:=1;
                        end
                        else
                        begin
                                if k>1 then m:=1 else m:=n;
                        end;
                end;
                if (k=1) and (tt=-1) then tt:=1;
                        if (k=n) and (tt=1) then tt:=-1;
        end;
        writeln('Stowaway');
end;
begin
        nhap;
        xuly;
end.

var n,m,k,min,i,t:integer;
    s,time:string;
    controller: boolean;
begin
Read(n);
Read(m);
Readln(k);
Readln(s);
readln(time);
If (s='to head') then t:=-1 else t:=1;
For i:=1 to length(time)-1 do begin
If time[i]='0' then begin
    if ((t=-1) and (k>m)) or ((t=1) and (k<m)) then begin
                    If (m<>1) and (m<>n) then m:=m+t;
                    k:=k+t;
                    If (k=1) or (k=n) then t:=t*(-1)
                    end
    else if ((t=-1) and (k<m)) or ((t=1) and (k>m)) then begin
        If (m<>1) and (m<>n) then m:=m-t;
                    k:=k+t;
                    If (k=1) or (k=n) then t:=t*(-1)
                    end
end
else begin
    k:=k+t;
    If (k=1) or (k=n) then t:=t*(-1);
    if ((t=-1) and (k<>n)) or ((t=1) and (k=1)) then m:=n
    else if ((t=1) and (k<>1)) or ((t=-1) and (k=n)) then m:=1
    end;
If m=k then begin controller:=true; min:=i;break end
end;
    If controller then write('Controller ',min) else writeln('Stowaway')
end.

var
    n,thie,wei,ty,sum   :longint;
    ch  :char;
function getmin(aaa,bbb:longint):longint;
begin
        if aaa<Bbb then exit(aaa)
        else exit(bbb);
end;
function getmax(aaa,bbb:longint):longint;
begin
        if aaa>bbb then exit(aaa)
                   else exit(bbb);
end;
begin
    readln(n,thie,wei);
    readln(ch,ch,ch,ch);
    if ch='h' then ty:=-1
          else ty:=1;
    while not eoln do
    begin
        inc(sum);
        read(ch);
        if ch='0' then
        begin
            if (thie-wei)*ty>0 then thie:=thie+ty;
            if thie>n then thie:=n
            else if thie=0 then thie:=1;
            if n<>1 then begin
                wei:=wei+ty;
                if wei>n then begin wei:=n-1;ty:=-1;end
                else if wei=0 then begin wei:=2;ty:=1;end;
            end;
        end else
        begin
            if n<>1 then begin
                wei:=wei+ty;
                if wei>n then begin wei:=n-1;ty:=-1;end
                else if wei=0 then begin wei:=2;ty:=1;end;
            end;
            if ty=1 then
            begin
                if wei=1 then thie:=n
                     else thie:=1;
            end else begin
                if wei=n then thie:=1
                     else thie:=n;
            end;
        end;
        if wei=thie then
        begin
            writeln('Controller ',sum);
            halt;
        end;
    end;
    writeln('Stowaway');
end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  f:=false;
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if (k<m)and(m<n)and(m+1<>k)and(h=1) then inc(m) else if ((m>1)and(m-1<>k))and(h=-1) then dec(m);
  if s[i]='1' then
  begin
   f:=true;
   m:=0;
  end;
  inc(k,h);
  if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
end.

const   INPUT = '';
        OUTPUT = '';
        MAX_N = 60;

var fi,fo:text;
    n,m,a,b,d:longint;
    s:string;

function    modn(x:longint):longint;
begin
    while x < 0 do x:=x+n;
    exit(x mod n);
end;

procedure   enter;
begin
    readln(fi,n,b,a);
    dec(a); dec(b);
    readln(fi,s);
    if s[4] = 'h' then d:=-1
    else d:=1;
    readln(fi,s);   m:=length(s);
end;

procedure   solve;
var i:longint;
begin
    for i:=1 to m do begin
        if (a+d < 0) or (a+d > n-1) then d:=-d;
        a:=modn(a+d);
        if s[i] = '0' then begin
            if (b+d > -1) and (b+d < n) then b:=modn(b+d);
        end
        else
            if d = -1 then b:=n-1
            else b:=0;
        if a = b then begin
            writeln(fo,'Controller ',i);
            exit;
        end;
    end;
    writeln(fo,'Stowaway');
end;

begin
    assign(fi,INPUT);   reset(fi);
    assign(fo,OUTPUT);  rewrite(fo);
    enter;
    solve;
    close(fo);
    close(fi);
end.

{$R+}
var n,m,k,j,i:longint;
s:string;
procedure step(var m,k:longint);
begin
  if j=0
     then dec(k)
  else inc(k);
  if j=0
     then if k<n
             then m:=n
          else m:=1
  else if k>1
          then m:=1
       else m:=n;
end;
begin
  readln(n,m,k);
  readln(s);
  if s[4]='t'
     then j:=1{� ������}
  else j:=0; {� 墮���}
  readln(s);
  for i:=1 to length(s) do
    begin
      if ((j=0)and(k=1))or((j=1)and(k=n))
         then j:=(j+1)mod 2;
      if ((m=1)and(s[i]='0')and(k=2)and(j=0))or
         ((m=n)and(s[i]='0')and(k=n-1)and(j=1))
         then break;
      if s[i]='1'
         then step(m,k)
      else if j=0
              then begin
                     if (m>k)and(m<n)
                        then inc(m);
                     if (m<k)and(m>1)
                        then dec(m);
                     dec(k);
                   end
      else begin
             if (m<k)and(m>1)
                then dec(m);
             if (m>k)and(m<n)
                then inc(m);
             inc(k);
           end;
    end;
  if i=length(s)
     then writeln('Stowaway')
  else writeln('Controller ',i);
end.

Const
        fi    = '';
        fo    = '';

Var
        f,g   : Text;
        n,m,k : Integer;
        d     : Integer;
        t     : String;
{-------------------}
Procedure ReadFile;
Var
        i : LongInt;
        st : String;
Begin
        Assign(f,fi);
        Assign(g,fo);
        Rewrite(g);
        Reset(f);
        Readln(f,n,m,k);
        Readln(f,st);
        Readln(f,t);
        If st = 'to head' then d:=-1 else d:=1;
        Close(f);
End;

Function Max(a,b:Integer):Integer;
Begin
         If a < b then Max:=b else Max:=a;
End;

Function Min(a,b:Integer):Integer;
Begin
         If a < b then Min:=a else Min:=b;
End;

Procedure Process;
Var
        i,j,time : Integer;
Begin
        i:=1;
        While i < Length(t) do
         Begin
                If t[i] = '0' then
                 Begin
                        If m > k then m:=Min(m+1,n);
                        If m < k then m:=Max(m-1,1);
                        k:=k + d;
                        If (k = 1) or (k=n) then d:=-d;
                 End
                Else
                 Begin
                        For j:=i to Length(t)-1 do
                         Begin
                          k:=k+d;
                          If (k = 1) or (k=n) then d:=-d;

                          If t[j+1] = '0' then
                           Begin
                            i:=j;
                            Break;
                           End;

                         End;

                         If (k = 1) then m:=n;
                         If (k = n) then m:=1;
                         If (k <> 1) and (k <> n) then
                          If d = 1 then
                           m:=1
                          Else
                           m:=n;
                 End;
                If m = k then Begin Writeln(g,'Controller ',i); Close(g); Exit; End;
                i:=i+1;
         End;
         Writeln(g,'Stowaway');
        Close(g);
End;

Begin
        ReadFile;
        Process;
End.

Var i,f,d,n,m,k:longint;
    c:char;
    s:string;
Begin
      {  assign(input,'input.txt');
        reset(input);
        assign(output,'output.txt');
        rewrite(output); }
        readln(n,m,k);
        readln(s);
        if s[length(s)]='d'
        then f:=-1
        else f:=1;
        for i:=1 to 200 do
        begin
                Read(c);
                if(c<>'1')and(c<>'0')
                then break;
                if c='1'
                then begin
                        inc(k,f);
                        if k=0
                        then begin
                                k:=2;
                                f:=1;
                        end;
                        if k=n+1
                        then begin
                                k:=n-1;
                                f:=-1;
                        end;
                        if f=-1
                        then m:=k+1
                        else m:=k-1;
                        if(k=1)or(k=n)
                        then begin
                                if m=k+1
                                then m:=k-1
                                else m:=k+1;
                        end;
                        if m=0
                        then m:=n;
                        if m=n+1
                        then m:=1;
                end
                else begin
                        d:=1;
                        if (k>m)
                        then d:=1
                        else d:=2;
                        if(d=1)and(m<>1)
                        then dec(m);
                        if(d=2)and(m<>n)
                        then inc(m);
                        inc(k,f);
                        if k=0
                        then begin
                                k:=2;
                                f:=1;
                        end;
                        if k=n+1
                        then begin
                                k:=n-1;
                                f:=-1;
                        end;
                        if m=k
                        then begin
                                writeln('Controller ',i);
                                halt;
                        end;
                end;
        end;
        writeln('Stowaway');
End.

var
    n,m,k,i: longint;
    s: shortstring;
    c: char;

Begin

  readln(n,m,k);
   readln(s);
    i:=0;
     while not eoln do
      begin

        inc(i);
         read(c);
          if c = '0'
           then
            begin

              if s = 'to head'
               then
                begin
                 if (m>k) and (m<>n) then inc(m);
                  if (m<k) and (m<>1) then dec(m);
                   dec(k);
                end
               else
                begin
                 if (m>k) and (m<>n) then inc(m);
                  if (m<k) and (m<>1) then dec(m);
                   inc(k);
                end;

            end
           else
            begin

              if s = 'to head'
               then
                begin
                 dec(k);
                  m:=n;
                end
               else
                begin
                 inc(k);
                  m:=1;
                end;

            end;

      if k = 1 then s:='to tail';
       if k = n then s:='to head';

        if m=k
         then
          begin
           writeln('Controller ',i);
            halt;
           end;

    end;

  writeln('Stowaway');

End.

Program z74b;
var n,m,k,i:longint;
	p:shortint;
    c:char;
begin
	readln(n,m,k);
    for i:=1 to 4 do
    	read(c);
    if c='h' then p:=-1
    else p:=1;
    readln;i:=0;
    while not(Eoln(input)) do
    begin
    	read(c);inc(i);
        if c='0' then
        begin
        	if p=-1 then
            begin
            	if (m<k)and(m>1) then dec(m);
                if (m>k)and(m<n) then inc(m);
                if k=1 then p:=1;
                k:=k+p;
            end
            else
            begin
            	if (m>k)and(m<n) then inc(m);
                if (m<k)and(m>1) then dec(m);
                if k=n then p:=-1;
                k:=k+p;
            end;
        end
        else if c='1' then
        begin
        	if p=-1 then
            begin
            	if k=1 then p:=1;
                k:=k+p;
                if p=1 then m:=k-1;
                if p=-1 then m:=k+1;
            end
            else if p=1 then
            begin
            	if k=n then p:=-1;
                k:=k+p;
                if p=1 then m:=k-1;
                if p=-1 then m:=k+1;
            end;
        end;
        if k=m then begin write('Controller ',i);halt;end;
    end;
    write('Stowaway');
end.

const maxn=1000000;

var n,m,k,t,move,i:longint;
    s:string;
    ch:char;
    p:array [0..maxn+1] of longint;

Function min(a,b:longint):longint;
begin
  if a<b then exit(a);
  exit(b);
end;

Function max(a,b:longint):longint;
begin
  if a>b then exit(a);
  exit(b);
end;

BEGIN
//  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);
  readln(n,k,m);
  readln(s);
  if s[4]='h' then move:=-1
  else move:=1;
  i:=0;
  while not eoln do begin
    read(ch);
    inc(i);
    if ch='0' then p[i]:=0
    else p[i]:=1;
  end;
  t:=i;
  if (m=n) and (move=1) then move:=-1;
      if (m=1) and (move=-1) then move:=1;
  for i:=1 to t do begin
    if ((m=2) and (k=1) and (move=-1) and (p[i]=0)) or ((p[i]=0)and (m=n-1) and (k=n) and (move=1)) then begin
      writeln('Controller ',i);
      halt;
    end;
    if p[i]=0 then begin
      if (k=n) or (k=1) then begin
      end
      else
       if m<k then
         inc(k)
       else dec(k);
      m:=m+move;
      if (m=n) and (move=1) then move:=-1;
      if (m=1) and (move=-1) then move:=1;
    end
    else begin
      m:=m+move;
      if (m=n) and (move=1) then move:=-1;
      if (m=1) and (move=-1) then move:=1;
      if m=1 then k:=n
      else if m=n then k:=1
      else if move=-1 then k:=n
      else if move=1 then k:=1;
    end;
  end;
  writeln('Stowaway');
  close(input);
  close(output)
END.

var
  n,m,k,i,j:longint;
  s,st:string;
begin
  readln(n, m, k);
  readln(s);
  readln(st);
  if k = n then s:='to head' else
  if k = 1 then s:='to tail';
  for i:=1 to length(st) do
  begin
    if st[i] = '0' then
    begin
      {zayac}
      if (m = 1)or(m = n) then m:=m+0 else
      if s = 'to head' then dec(m) else inc(m);
      {//zayac}
      {kontroller}
      if s = 'to head' then dec(k) else inc(k);
      if k = n then s:='to head' else
      if k = 1 then s:='to tail';
      {//kontroller}
    end else
    begin
      if s = 'to head' then dec(k) else inc(k);
      if k = n then s:='to head' else
      if k = 1 then s:='to tail';
      if s = 'to head' then
      begin
        if k = n then m:=1 else m:=n;
      end else
      begin
        if k = 1 then m:=n else m:=1;
      end;
    end;
    if m = k then
    begin
      writeln('Controller ', i);
      halt;
    end;
  end;
  writeln('Stowaway');
end.

const
          fi='';
          fo='';
type mang=array[1..50] of longint;
var
          a:mang;
          f:text;
          n,m,k,h:longint;
          s:string;
procedure nhap;
var
          i,j:longint;
          st:string;
begin
          assign(f,fi);
          reset(f);
          readln(f,n,m,k);
          readln(f,st);
          if st='to head' then h:=1
          else h:=2;
          readln(f,s);
          close(f);
end;
procedure xuli;
var
          i,j:longint;
begin
          if m>k then m:=n
          else m:=1;
          for i:=1 to length(s) do
          begin
                    if s[i]='1' then
                    begin
                              if (h=1) then m:=n
                              else m:=1;
                    end;
                    if h=1 then dec(k)
                    else inc(k);
                    if k=n then h:=1;
                    if k=1 then h:=2;
                    if k=m then
                    begin
                              writeln('Controller ',i);
                              halt;
                    end;
          end;
          writeln('Stowaway');
end;
begin
          nhap;
          xuli;
end.

var
 n,m,k,i,pp,posk,poss:longint;
 f:boolean;
 s,s1:ansistring;

begin
 readln(n,m,k);
 readln(s);
 if s='to head' then f:=true;
 posk:=k;
 poss:=m;
 readln(s1);
 pp:=length(s1);

 for i:=1 to pp do if s1[i]='0' then
 begin
  if f then
  begin
   if (poss>1) then dec(poss);
   if (posk>1) then dec(posk);
   if posk=1 then f:=false;
  end else
  begin
   if (poss<n) then inc(poss);
   if (posk<n) then inc(posk);
   if posk=n then f:=true;
  end;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end else
 begin
  if not f then
  begin
   if (posk<n) then inc(posk);
   if posk=n then f:=true;
  end else
  begin
   if (posk>1) then dec(posk);
   if posk=1 then  f:=false;
  end;
  if f then if posk<n then poss:=n else poss:=n-1;
  if not f then if posk>1 then poss:=1 else poss:=2;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

uses math;
var i,n,m,k:longint;
    s:ansistring;
    v:boolean;
 begin
   readln(n,m,k);
   readln(s);
   if s[4]='h' then v:=true
               else v:=false;
   readln(s);
   for i:=1 to length(s)-1 do
    begin
      if s[i]='1' then
           begin
             if (k=1) then v:=false
             else if k=n then v:=true;
             if v then k:=k-1
                  else k:=k+1;
             if (k=1) then v:=false
             else if k=n then v:=true;

             if (k=1) then m:=n
             else if (k=n) then m:=1
             else if v then m:=n
             else m:=1;

           end
      else begin
             if v and (m<k) then m:=max(m-1,1)
             else if v then m:=min(m+1,n)
             else if m>k then m:=min(m+1,n)
             else m:=max(m-1,1);

             if (k=1) then v:=false
             else if k=n then v:=true;
             if v then k:=k-1
                  else k:=k+1;
             if (k=1) then v:=false
             else if k=n then v:=true;

             if m=k then begin writeln('Controller ',i); halt(0); end;
           end;
    end;
   writeln('Stowaway');
 end.

  {$R+,S+,Q+,I+,O-}
   {R-,S-,Q-,I-,O+}
   var
     dir,n,m,k,i,j,ans,p: longint;
     t,s: ansistring;
     ok: boolean;
     wh: array [0..333] of longint;
     f: array [0..333,0..333] of boolean;
   begin
   //  assign(input,'in'); reset(input);
   //  assign(output,'out'); rewrite(output);
     readln(n,m,k);
     readln(t);
     readln(s);
     p:=length(s);
     if t = 'to head' then dir:=-1
     else dir:=1;
     wh[0]:=k;
     for i:=1 to p do
     begin
       wh[i]:=wh[i-1]+dir;
       if (wh[i] < 1) or (wh[i] > n) then
       begin
         dir:=-dir;
         wh[i]:=wh[i-1]+dir;
       end;
     end;
     fillchar(f,sizeof(f),False);
     f[0,m]:=True;
     ans:=p;
     for i:=1 to p do
     begin
       if s[i] = '1' then
       begin
         for j:=1 to n do
           if j <> wh[i] then f[i,j]:=True;
       end else
         for j:=1 to n do
           if (j <> wh[i]) and (j <> wh[i-1]) then
             if f[i-1,j] or f[i-1,j-1] or f[i-1,j+1] then
               f[i,j]:=True;
       ok:=False;
       for j:=1 to n do ok:=ok or f[i,j];
       if not ok then
       begin
         ans:=i;
         break;
       end;
     end;
     if ans = p then writeln('Stowaway')
     else writeln('Controller ',ans);
     close(input);
     close(output);
   end.

var a:array [1..1000] of longint;
    b,n,i,j,k,d,m,max:longint;
    s,p:string;

     begin
 readln(n,k,m);
 readln(s);
 readln(p);
 for i:=1 to length(p) do
  begin
   if p[i]='1' then
    begin
     if s[4]='h' then begin
      dec(m);
           if m=0 then
      begin
       m:=2;
       s[4]:='t';
      end;
      end else
     if s[4]='t' then begin
      inc(m);
      if m=n+1 then
       begin
          m:=n-1;
          s[4]:='h';
       end;
      end;

    if (s[4]='h') then k:=m+1
     else k:=m-1;
    if (m=1) or (m=n) then
     begin
      if k=m+1 then k:=m-1
       else k:=m+1;
     end;
    if k=0 then k:=n;
    if k=n+1 then k:=1;
    end else
     begin

     d:=1;
     if (m>k) then d:=1
      else d:=2;

     if (d=1) and (k<>1) then dec(k);
     if (d=2) and (k<>n) then inc(k);

       if s[4]='h' then begin
      dec(m);
           if m=0 then
      begin
       m:=2;
       s[4]:='t';
      end;
      end else
     if s[4]='t' then begin
      inc(m);
      if m=n+1 then
       begin
          m:=n-1;
          s[4]:='h';
       end;
      end;

     if k=m then begin
       writeln('Controller ',i);
       halt;
     end;

     end;
  end;
 writeln('Stowaway');
end.

var n,m,k,d,i,l:integer;
   s:string[202];
 {  a:array[1..55]of integer; }
begin
readln(n,k,m);
readln(s);
if s='to head' then d:=-1 else d:=1;
readln(s);
  l:=length(s);
  for i:=1 to l do
  begin
  if m=1 then d:=1;
  if m=n then d:=-1;
   m:=m+d;
  if s[i]='0' then
   begin
  if (k+d<=n)and(d+k>=1) then k:=k+d;
  end
else
  begin
  if d=1 then k:=1 else k:=n;
  end;

  if m=k then begin writeln('Controller ',i); exit; end;
  end;
 writeln('Stowaway');
end.

var n,m,k,i,c,l,z:integer;
a:array[1..200] of char;
s:string;

procedure step1;
begin
if m<k then
  if m>1 then dec(m);
if m>k then
  if m<n then inc(m);
k:=k+c;
end;

procedure step2;
begin
k:=k+c;
if c=1 then
  if k<>1 then m:=1 else m:=n;
if c=-1 then
  if k<>n then m:=n else m:=1;
end;

begin
readln(n,m,k);
readln(s);
while not eoln do
  begin
  inc(l);
  read(a[l]);
  end;
if s='to head' then c:=-1 else c:=1;
for i:=1 to l do
  begin
  if a[i]='0' then step1 else step2;
  if (k=1) or (k=n) then c:=-c;
  if m=k then
    begin
    writeln('Controller ',i);
    halt;
    end;
  end;
writeln('Stowaway');
end.

{uses crt;
}const nn=300;
var m,t,n,i,j,k,p,max,kolvag:longint;
cc:char;
s,nap:string;   flag:boolean;
napcon,contr,zayaz:array[0..nn] of longint;
begin {clrscr;
 assign(input,'input.txt');reset(input);
} readln (kolvag,m,k);
 readln(nap);
 readln(s);
 n:=length(s);
 if nap='to head' then napcon[1]:=-1 else napcon[1]:=1;
 contr[1]:=k;
 for i:=2 to n do
   begin contr[i]:=contr[i-1]+napcon[i-1];
      if (contr[i]=kolvag)or(contr[i]=1) then napcon[i]:=-1*napcon[i-1] else napcon[i]:=napcon[i-1];

   end;

if s[1]='0' then  zayaz[1]:=m;
if s[1]='1' then  zayaz[1]:=contr[1]-napcon[2];
for i:=2 to n do
 begin
    if s[i-1]='0' then if (zayaz[i-1]=1)or(zayaz[i-1]=kolvag)
      then zayaz[i]:=zayaz[i-1] else zayaz[i]:=zayaz[i-1]+napcon[i-1];
    if s[i-1]='1' then zayaz[i]:=contr[i-1];

 end;

{for i:=1 to n do writeln(i,' ',contr[i],' ',zayaz[i],' ',napcon[i]); }
for i:=1 to n do if (contr[i]=zayaz[i])and(s[i-1]='0') then begin flag:=true;break;end;
  if flag then writeln('Controller',' ',i-1) else writeln('Stowaway');

end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var cm,n,i,k,m,r:integer;
s,t:string;
c:char;

begin
readln(n,m,k);
readln(s);
readln(t);
c:=s[4];

if (c='h') and (m>k) then m:=n
else
if (c='h') and (m<k) then m:=1
else
if (c='t') and (m<k) then m:=1
else
m:=n;

for I := 1 to length(t) do
begin
if k=n then c:='h';
if k=1 then c:='t';
    if c='h' then begin k:=k-1; end
    else
    begin k:=k+1;  end;
  if t[i]='1' then
  begin
    if c='h' then m:=n
    else
    m:=1;
  end;
if k=m then begin write('Controller ',i); halt; end;
end;
write('Stowaway');
end.

Var n,i,j,k,l,m,t,r:longint;
s:string;
Begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);}
Readln(N,M,k);
Readln(s);
if s='to head' then
  r:=1
else
  r:=0;
s:='';
Readln(s);
For i:=1 to length(s) do begin
  if s[i]='0' then begin
    if M>k then begin
      if M<N then
        inc(M);
    end
    else begin
      if M>1 then
        dec(M);
    end;
  end;
  if r=1 then
    dec(k)
  else
    inc(k);
  if k=1 then
    r:=0;
  if k=N then
    r:=1;
  if s[i]='1' then begin
    if r=1 then begin
      if k=N then
        M:=1
      else
        M:=N;
    end
    else begin
      if k=1 then
        M:=N
      else
        M:=1;
    end;
  end;
  if k=M then begin
    writeln('Controller ',i);
    halt(0);
  end;
end;
writeln('Stowaway');
end.

{$apptype console}
{$R+,S+,I+,Q+}
const
     inf = 'input.txt';
     outf = 'output.txt';
var
 n,m,k,i:longint;
 s,t:string;

 procedure go;
  begin
   if (k = 2) and (s[4] = 'h') then
    begin
     k:=1;
     s[4]:='t';
    end else
   if (k = n-1) and (s[4] = 't') then
    begin
     k:=n;
     s[4]:='h';
    end else
   if s[4] = 'h' then dec(k) else inc(k);
  end;

begin
 //reset(input,inf);
 //rewrite(output,outf);
 readln(n,m,k);
 readln(s);
 readln(t);
 for i:=1 to length(t) do
  begin
   if t[i] = '0' then
    begin
     if m < k then m:=1 else m:=n;
     go;
    end else
    begin
     go;
     if k = 1 then m:=n else
     if k = n then m:=1 else
     if s[4] = 'h' then m:=n else m:=1;
    end;
   if k = m then
    begin
     writeln('Controller ',i);
     exit;
    end;
  end;
 writeln('Stowaway');
end.

var n,c,h,k:longint;
dir,time:string;
catched:boolean;
procedure move(var x:longint;moveTo:string);begin
  if (moveTo='to head') then
    if (x<=1)
    then exit
    else dec(x)
  else if (moveTo='to tail') then
    if (x>=n) then exit
    else inc(x);
end;
procedure movec(moveTo:string); begin
  if (moveTo='to head') then
    if (c=1) then begin dir:='to tail';movec(dir);end else dec(c)
  else if (moveTo='to tail') then
    if (c=n) then begin dir:='to head';movec(dir);end else inc(c);
end;
procedure checkNewPositions; begin
  if (h=c) then begin
    writeln('Controller ',k);
    halt;
  end;
end;
procedure getOut; begin
   if (length(time)=1) then begin writeln('Stowaway');halt;end;
   if (dir='to head') then h:=0;
   if (dir='to tail') then h:=n+1;
end;
procedure getOn; begin
  if (dir='to head') then
    if (c<n) then h:=n else h:=1
  else if (dir='to tail') then
    if (c>1) then h:=1 else h:=n;
end;
procedure countNewMove; begin
  if (dir='to head') then begin
    if (h<c) then begin
      move(h,'to head');
      movec(dir);
      exit;
    end;
    if (h>c) then begin
      move(h,'to tail');
      movec(dir);
      exit;
    end
  end
  else if (dir='to tail') then begin
    if (h>c) then begin
      move(h,'to tail');
      movec(dir);
      exit;
    end;
    if (h<c) then begin
      move(h,'to head');
      movec(dir);
      exit;
    end;
  end;
end;
begin
{  assign(input,'input.txt');
  reset(input);
  assign(output,'output.txt');
  rewrite(output);}
  readln(n,h,c);
  readln(dir);
  readln(time);
  k:=1;
  while (length(time)<>0) do begin
    if (time[1]='0') then begin
      //train moves - checking cotroller direction
      countNewMove;
      checkNewPositions;
    end
    else begin
      getOut;
      countNewMove;
      getOn;
      checkNewPositions;
    end;
    delete(time,1,1);
    inc(k);
  end;
end.

{ fp }
Var
 n,x,y,i,j,m:longint;
 s : string;
 ok : boolean;

 Procedure next;
  begin
    if ok then y := y-1
          else y := y+1;
    If (y=1) or (y=n) then ok := not ok;
  End;

 begin
  REadLn(n,x,y);
  REadLn(s);
  ok:= (s[4]='h');
  ReadLn(s);
  m := length(s);
  For i := 1 to m do
   Begin

    If s[i]='0' then
     Begin
       if ok and (x<y) and (x<>1) then x := x-1 else
       If ok and (x>y) and (x<>n) then x := x+1 else
       If (ok=false) and (x>y) and (x<>n) then x := x+1 else
       If (ok=false) and (x<y) and (x<>1) then x := x-1;
      next;
      If x=y then
        Begin
         WriteLn('Controller ',i);
         halt(0);
        End;
     end else
     Begin
      next;
      If ok  then
       Begin
        x := n;
        If x=y then x := 1;
       End else
        Begin
         x := 1;
         If x=y then x := n;
        End;
     End;
//      WriteLn(i,' ',x,' ',y);
    End;
  WriteLn('Stowaway');
 end.

Var e,n,m,k,i:LongInt;
s:string;
begin
 // Assign(input,'input.txt');
 // Assign(output,'output.txt');
  Readln(n,m,k);
  readln(s);
  if s[4]='h'
  then e:=-1
  else e:=1;
  Readln(s);
  for i:=1 to Length(s) do
  begin
    if s[i]='1'
    then begin
          if ((k=1)and(e=-1))or((k=n)and(e=1))
          then e:=e*(-1);
          k:=k+e;
          if e=1
          then m:=1
          else m:=n;
         end
    else begin
          if (m<>1)and(m<>n)
          then begin
                  if e=1
                  then begin
                         if m>k
                         then m:=n
                         else m:=1;
                       end
                  else begin
                         if m<k
                         then m:=1
                         else m:=n;
                       end;
                 end;
                  if ((k=1)and(e=-1))or((k=n)and(e=1))
                  then e:=e*(-1);
                  k:=k+e;
                  if k=m
                  then begin writeln('Controller ',i); halt(0); end;

         end;
  end;
  Writeln('Stowaway');
end.

var n,m,k,i,napr:longint;
    s:String;
    a:array[0..51] of longint;

procedure fun1;
begin
if m=k then begin writeln('Controller ',i-1); halt; end;
 if (Napr=1) and (m+1=k) then begin
                               if m=1 then begin writeln('Controller ',i); halt; end;
                               dec(m);
                               dec(k);
                              end else
 if (napr=1) then begin
                   dec(k);
                   if k=0 then begin
                                k:=2; napr:=3-napr;
                   if m=k then begin writeln('Controller ',i); halt; end; end;
                  end else
 if (napr=2) and (m=k+1) then begin
                               if m=n then begin writeln('Controller ',i); halt; end;
                               inc(m);
                               inc(k);
                              end else
  if (napr=2) then begin
                   inc(k);
                   if k=n+1 then begin
                                k:=n-1; napr:=3-napr;
                               end;
                    if m=k then begin writeln('Controller ',i); halt; end;
                  end;
end;

procedure fun2;
begin
  if napr=1 then begin
                 k:=k-1;
                 if k=0 then begin
                              napr:=2;
                              k:=2;
                             end;
                end else
 if (napr=2) then begin
                   inc(k);
                   if k=n+1 then begin
                                k:=n-1; napr:=3-napr;
                               end;
                  end;
 if napr=1 then begin
                 if k=n then m:=1 else m:=n;
                end else
 if napr=2 then begin
                 if k=1 then m:=n else m:=1;
                end;

 if k=m then begin writeln('Controller ',i); halt; end;

end;

begin
readln(n,m,k);
readln(s);
if s='to head' then napr:=1 else napr:=2;
readln(S);
for i:= 1 to length(s) do
 begin
  if s[i]='0' then fun1 else fun2;
 end;
 writeln('Stowaway');
end.

{$APPTYPE CONSOLE}
var
  i,z,co,n:integer;
  s:string;
  c:char;

  Procedure move(var t:char);
  begin
   If t='t' then inc(co)
   else dec(co);
   If co=1 then t:='t' else If co=n then t:='h';
  end;

  Procedure think;
  begin
   If co=1 then z:=n else
    If co=n then z:=1 else If c='t' then z:=1
    else z:=n;
  end;

  Procedure movez;
  begin
   If (c='t') and (z>co) and (z+1<=n) then inc(z)
   else If (c='t') and (z<co) and (z-1>0) then dec(z)
   else If (c='h') and (z<co) and (z-1>0) then dec(z)
   else If (c='h') and (z>co) and (z+1<=n) then inc(z);
  end;

begin
{reset(input,'Input.txt');
rewrite(output,'Output.txt');}
readln(n,z,co);
readln(s);
c:=s[4];
If (c='t') and (co=n) then c:='h';
If (c='h') and (co=1) then c:='t';
readln(s);

For i:=1 to length(s)-1 do
begin
  If s[i]='1' then
  begin
   move(c);
   think;
  end
  else
  begin
   movez;
   If z=co then
   begin
    writeln('Controller',' ',i);
    exit;
   end;
   move(c);
   //writeln(z,' ',co);
   If z=co then
   begin
    writeln('Controller',' ',i);
    exit;
   end;
  end;
end;
writeln('Stowaway');
end.

var n,z,k,i,h:byte;
        s:char;
head,flag:boolean;
a:array [0..200] of 0..1;

begin
readln(n,z,k);
read(s);
read(s);
read(s);
readln(s);
if s='h' then head:=true;
i:=0;
read(s);
repeat
        inc(i);
        A[i]:=ord(s)-ord('0');
        read(s);
until not(s in ['0'..'1']);
h:=i;
flag:=false;
for i:=1 to h-1 do
begin
        if k=z then
        begin
                flag:=true;
                break;
        end;
        if A[i]=0 then
        begin
                if (z>k) and (z<n) then inc(z);
                if (z<k) and (z>1) then dec(z);
                if  head then dec(k)
                else inc(k);
        end
        else
        begin
                if  head then dec(k)
                else inc(k);
                if head then
                        if k=n  then z:=1
                                else z:=n
                else
                        if k=1 then z:=n
                                else z:=1;
        end;

        if k=1 then head:=false;
        if k=n then head:=true;
        if k=z then
        begin
                flag:=true;
                break;
        end;
end;
if flag then writeln('Controller ',i)
else writeln('Stowaway');
end.

var
ok:boolean;
i,j,n,m,k,q,pk:longint;
s,nap:ansistring;
u,e:array[0..1000]of boolean;
 begin
  readln(n,m,k);
  readln(nap);
  readln(s);
  if nap[length(nap)]='d' then q:=-1
                          else q:=1;

  fillchar(u,sizeof(u),false);
  u[m]:=true;

  for i:=1 to length(s) do
    begin
     fillchar(e,sizeof(e),false);
     if k+q=0 then
       begin
        q:=1;
       end
        else if k+q>n then
          begin
           q:=-1;
          end;

     pk:=k;
     k:=k+q;

     if s[i]='0' then
       begin
        for j:=1 to n do
          if u[j] then
            begin
             if (j>1)and(pk<>j-1)and(k<>j-1) then e[j-1]:=true;
             if (j<n)and(pk<>j+1)and(k<>j+1) then e[j+1]:=true;
             if j<>k then e[j]:=true;
            end;
       end
        else
       begin
        for j:=1 to n do
          if (j<>k) then e[j]:=true;
       end;

     ok:=false;
     for j:=1 to n do
       if e[j] then ok:=true;

     if not ok then
       begin
        writeln('Controller ',i);
        halt(0);
       end;

     u:=e;
    end;
  writeln('Stowaway');
 end.

var
 n,m,k,i,p,f:longint;
 s:string;
 c:char;
 begin
    {assign(input,'input.txt');
    assign(output,'output.txt');
    reset(input);
    rewrite(output); }
    readln(n,k,m);
    readln(s);
    if s='to head' then
        p:=-1
        else
        p:=1;
    i:=0;
     while eoln<>true do
        begin

         read(c);
          inc(i);
          if c='0' then
                begin
                 if p=-1 then
                        if (k-1>m)and(m<>1) then
                                dec(k)
                                else
                                if (m=1)and(2>k-1)and(k-1>0) then
                                        dec(k)
                                else
                                if (m=1)and(k=2)and(k+1<n) then
                                        inc(k)
                                else
                                if (m=1) then
                                f:=1
                                else
                        if (k+1<=n)and(m=k-1) then
                                inc(k)
                        else
                        if (k-1>0)and(m=k+1) then
                                dec(k);
                 if p=1 then
                        if (k+1<m)and(m<>n) then
                                inc(k)
                                else
                                if (m=n)and(m-1>k+1)and(k+1<n) then
                                        inc(k)
                                        else
                                if (m=n)and(k=m-1)and(k-1>0) then
                                        dec(k)
                                        else
                                if m=n then
                                        f:=1
                                        else
                        if (k-1>0)and(m=k+1) then
                                dec(k)
                        else
                         if (k+1<=n)and(m=k-1) then
                                inc(k);
                        if m=k then
                        begin
                         writeln('Controller',' ',i);
                         halt;
                        end;
                 inc(m,p);
                 if m>n then
                        begin
                         m:=n-1;
                         p:=-1;
                        end;
                 if m<1 then
                        begin
                         m:=2;
                         p:=1;
                        end;
                 if m=k then
                        begin
                         writeln('Controller',' ',i);
                         halt;
                        end;
                end;
          if c='1' then
                begin
                 k:=0;
                  inc(m,p);
                 if m>n then
                        begin
                         m:=n-1;
                         p:=-1;
                        end;
                 if m<1 then
                        begin
                         m:=2;
                         p:=1;
                        end;
                 if p=1 then

                 if m-2>0 then
                        k:=m-2
                        else
                        k:=m-1;
                 if p=-1 then
                 if m+2<=n then
                        k:=m+2
                        else
                        k:=m+1;

                end;

        end;
    writeln('Stowaway');
    end.

var
a,s1:string;
i,j,k,l,n,m:longint;
begin
readln(n,m,k);
readln(s1);
read(a);
for i:=1 to length(a) do
 begin
  if k=1 then s1:='to tail';
  if k=n then s1:='to head';
  if (a[i]='1') and (i=length(a)) then
   begin
    write('Stowaway');
    exit;
   end;
  if ((m=1) and (k=2) and (a[i]='0') and (s1='to head')) or ((m=n) and (k=n-1) and (a[i]='0') and (s1='to tail')) then
   begin
    write('Controller ',i);
    exit;
   end;
  if m<k then m:=1;
  if m>k then m:=n;
  if (a[i]='1') and (s1='to head') then m:=n;
  if (a[i]='1') and (s1='to tail') then m:=1;
  if s1='to tail' then inc(k)
   else dec(k);
 end;
end.

Program			BB;
var
k,p,s,c,m,time,i,n : longint;
len,rp : string;
flag : Boolean;
begin
{Assign(input,'B.in');Assign(output,'B.out');
reset(input);rewrite(output);}
	readln(n,m,k);
	s:=m;c:=k;
	readln(Rp);
	if Rp[4]='h' then p:=-1 else p:=1;
	readln(len);
	time :=0;flag := false;
	for i :=1 to length(len) do
	begin
		if len[i]='1' then
		begin
			if p=-1 then begin
                                if c<>1 then
                                s := n else
                                s := 1;
                        end else
                        begin
                                if c<>n then s :=1 else
                                s := n;
                        end;
		end else
                begin
                        if s>c then begin
                                s:=s+1;
                                if s=n+1 then s := n;
                                end
                        else
                        if s<c then
                        begin
                                s:=s-1;
                                if s=0 then s:=1;
                        end;
                end;
			c:=c+p;
			if c=0 then
			begin c:=2;p:=-p; end else
			if c=n+1 then
			begin c :=n-1;p:=-p;end;

		time := time+1;
		if s=c then begin flag := true;break;end;
	end;
	if flag=false then writeln('Stowaway') else
	writeln('Controller ',time);
{Close(input); Close(output);}

end.

program xj;

 var
  i,j,k,n,m,x,y,dir,xx,yy,zz:longint;
  st:string;

 begin
  //assign(input,'x.in');reset(input);
  readln(n,y,x);
  readln(st);
  if st[4]='h'
   then dir:=-1
   else dir:=1;
  readln(st);
  m:=length(st);
  for i:=1 to m do
   begin
    if st[i]='0'
     then
      begin
       xx:=y-1;yy:=y+1;zz:=y;
       if xx=0 then xx:=1;if yy>n then yy:=n;
       if abs(xx-x)<abs(yy-x) then xx:=yy;
       if abs(xx-x)<abs(zz-x) then xx:=zz;
       y:=xx;
       x:=x+dir;
       if x=0 then begin dir:=-dir;x:=2; end;
       if x=n+1 then begin dir:=-dir;x:=n-1; end;
       if x=y
        then begin writeln('Controller ',i);halt; end;
      end
     else
      begin
       x:=x+dir;
       if x=0 then begin dir:=-dir;x:=2; end;
       if x=n+1 then begin dir:=-dir;x:=n-1; end;
       if dir=-1
        then if x<>n then y:=n
                     else y:=1
        else if x<>1 then y:=1
                     else y:=n;
      end;
   end;
  writeln('Stowaway');
 end.

var
  px,o,n,x,y,i,m:longint;
  s:ansistring;

begin
  readln(n,x,y);
  readln(s);
  if (s[4]='h')then o:=1 else o:=2;
  readln(s);
  m:=length(s);
  for i:=1 to m-1 do begin
    if (s[i]='0')then begin
      px:=x;
      if (x=1)then inc(x)else
      if (x=n)then dec(x)else
      if (abs(x-1-y)>abs(x+1-y))then dec(x)else
      inc(x);
      if (x=y)then x:=px;
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (x=y)and(x=px)then begin writeln('Controller ',i);exit;end else
      if (x=y)then x:=px;
    end else begin
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (y=n)then x:=1 else
      if (y=1)then x:=n else
      if (o=1)then x:=n else
      x:=1;
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end;
  end;
  writeln('Stowaway');
end.

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=m then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if f then begin
    if s[i]='1' then begin
      m:=1;
    end else begin
      if m-k>=0 then begin
        if (m-k>1) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end;
    end;
  end else begin
    if s[i]='1' then begin
      m:=n;
    end else begin
      if k-m>=0 then begin
        if (k-m>1) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end;
    end;
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

program problemB;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  orient,n,m,k,i,j,p:integer;
  s,q:string;
begin
  readln(n,m,k);
  readln(s);
  readln(q);
  if s='to head' then orient:=-1 else orient:=1;
  p:=-1;
  for i:=1 to length(q) do begin
    case q[i] of
      '0':begin
        if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        if k=m then begin
          p:=k;
          break;
        end;
      end;
      '1':begin
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        m:=k-orient;
        if (m>n) then m:=1;
        if (m<1) then m:=n;
        if m=k then begin
          p:=k;
          break;
        end;
      end;
    end;
//    writeln(m,' ',k);
  end;
  if p=-1 then writeln('Stowaway') else writeln('Controller ',i);
  readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.

{$R+,Q+,I+}
{$apptype console}
Uses SysUtils;
Var
   a:Array[0..3000] of Integer;
   used:Array[0..3000,0..3000] of Boolean;
   s,w:String;
   n,m,k,n1,i,j,f,ans:Integer;
Procedure Dfs(i,j:Integer);
Var
   r:Integer;
Begin
   used[i,j]:=true;
   If a[i]=j Then Exit;
   If i>ans Then ans:=i;
   If i=n1 Then Exit;
   If w[i]='0' Then Begin
      If not(used[i+1,j]) Then Dfs(i+1,j);
      If (j>1) and (not(used[i+1,j-1])) and (a[i]<>j-1) Then Dfs(i+1,j-1);
      If (j<n) and (not(used[i+1,j+1])) and (a[i]<>j+1) Then Dfs(i+1,j+1);
   End
   Else Begin
      For r:=1 To n Do
         If not(used[i+1,r]) Then Dfs(i+1,r);
   End;
End;
Begin
   ReadLn(n,m,k);
   ReadLn(s);
   Read(w);
   If s[4]='h' Then f:=0
               Else f:=1;
   j:=k;
   n1:=length(w);
   For i:=1 To n1 Do Begin
      a[i]:=j;
      If f=1 Then j:=j+1
             Else j:=j-1;
      If j=0 Then Begin
         f:=1;
         j:=2;
      End;
      If j>n Then Begin
         f:=0;
         j:=n-1;
      End;
   End;
   ans:=0;
   Dfs(1,m);
   If ans=n1 Then Write('Stowaway')
             Else Write('Controller ',ans);
End.

Var n,z,k,dx,l,i:Integer;
    s,v:String;

Procedure KGO;
Begin
     Inc (k,dx);
     If k=0 then Begin dx:=-dx; k:=2; Exit End;
     If k=n+1 then Begin dx:=-dx; k:=n-1 End;
End;

Procedure ZGO;
Begin
     If v[i]='0'
     then Begin
               If z>k
               then Begin If z<>n then Inc (z) End
               else Begin If z<>1 then Dec (z) End;
          End
     else Begin
               If dx=1
               then If k=1 then z:=n else z:=1
               else If k=n then z:=1 else z:=n;
          End;
End;

Begin
     //Assign (input,'input.txt'); ReSet (input);
     //Assign (output,'output.txt'); ReWrite (output);
     Readln (n,z,k);
     Readln (s);
     If s[4]='h'
     then dx:=-1
     else dx:=1;
     Readln (v);
     l:=Length (v);
     For I:=1 to l do
     Begin
          If v[i]='0' then Begin ZGO; KGO; End
          else Begin KGO; ZGO; End;
          If k=z then Begin Writeln ('Controller ',i); Exit End;
     End;
     Writeln ('Stowaway')
End.

    var

     kk,max,f,n,m,i,j,k,off,tr: longint;
    tt : longint;
    s : String;
    q : char;
    a : Array[0..1000]of longint;
    b : Array[0..70,0..70,-5..5,0..201]of longint;

    function maxx(x,y : Longint):longint;
    begin
    if x > y then y := x;
    maxx := y;
    end;
    function rec(x,y,shag,z : longint) : longint;
    var i,tr,h,ht,shah: Longint;
    begin

     if x = y then
      begin
       b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);
       if b[x,y,shag,z] > max then max := b[x,y,shag,z];
       exit(b[x,y,shag,z]);
      end;

     if z = f then
      begin
       b[x,y,shag,z] := maxlongint;
       max := maxlongint;
       exit(maxlongint);

      end;

     if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

     if a[z] = 1 then
      begin

        shah := shag;
        h := y + shag;
          if (h = 0)or(h = n + 1) then
           begin
            shag := -shag;
            h := y + shag;
           end;

       For i := 1 to n do
         begin
          if i = h then tr := z
          else
          tr := Rec(i,h,shag,z+1);
          if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
         end;
        rec := b[x,y,shah,z];
      end
     else
      begin
        shah := shag;
        h := x + 1;
        if h <= n then
         begin
          ht := y + shag;
          if (ht = 0)or(ht = n + 1) then
           begin
            shag := -shag;
            ht := y + shag;
           end;
          if h = y then tr := z
          else
          tr := Rec(h,ht,shag,z+1);
          if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
         end;

       h := x - 1;
       shag := shah;
       if h > 0 then
        begin
          ht := y + shag;
          if (ht = 0)or(ht = n + 1) then
           begin
            shag := -shag;
            ht := y + shag;
           end;
          if  h = y then tr := z
          else
          tr := Rec(h,ht,shag,z+1);
          if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

        end;

       shag := shah;
       ht := y + shag;
       if (ht = 0)or(ht = n+1)
        then
         begin
          shag := -shag;
          ht := y + shag;
         end;
       tr := Rec(x,ht,shag,z+1);
       if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

       Rec := b[x,y,shah,z];
      end;

     if b[x,y,shah,z] > max then max := b[x,y,shah,z];
    end;

     begin
      readln(n,m,kk);
      readln(s);

      i := 0;
      while not seekeof do
        begin
         read(q);
         i := i + 1;
         if q = '1' then a[i] := 1
         else a[i] := 0;
        end;
       f := i;
       if s = 'to tail' then off := 1
       else off := -1;

       for i := 1 to n do
        for j := 1 to n do
         for k := -1 to 1 do
          for tr := 0 to f do
           b[i,j,k,tr] := -1;

       max := -maxlongint;
       Rec(m,kk,off,1);

       if max >= f then writeln('Stowaway')
       else writeln('Controller ',max);
     end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var i,n,m,k,z,c : Integer;
    s : string;
    nap : Boolean;
begin
  Readln(n,m,k);
  Readln(s);
  if s[4]='t' then nap:=True;
  if s[4]='h' then nap:=false;
  Readln(s);
  if (m>k) then z:=n
  else z:=1;
  c:=k;
  for i:=1 to length(s) do
   begin
     if nap then c:=c+1
     else c:=c-1;
     if c=0 then
       begin
         c:=2;
         nap:=True;
       end;
     if c=n+1 then
      begin
        c:=n-1;
        nap:=False;
      end;
     if s[i]='1' then
       begin
         if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1
         else z:=n;
       end;
     if z=c then
       begin
         Writeln('Controller ', i);
         Readln;
         Exit;
       end;
   end;
   Writeln('Stowaway');
   Readln;
end.

{$APPTYPE CONSOLE}
{$R-,Q-,O+,S+}
var
 n,m,k,i,l : longint;
 s :string;
begin
// reset(input,'input.txt');
// rewrite(output,'output.txt');
 readlN(n,m,k);
 readln(s);
 if s[4]='h' then
  l:=-1
 else
  l:=1;
 readln(s);
 for i:=1 to length(s) do
  begin
   if s[i]='1' then
    begin
     if l=-1 then
      m:=n
     else
      m:=1;
    end
   else
    begin
     if m<k then
      m:=m-1
     else
      m:=m+1;
     if m<1 then
      m:=1;
     if m>n then
      m:=n;
    end;
   k:=k+l;
   if m=k then
    begin
     writeln('Controller ',i);
     halt;
    end;
   if k=1 then
    l:=1;
   if k=n then
    l:=-1;
  end;
 writeln('Stowaway');
end.

const
    fi='';
    fo='';
var
    VtC,mv,n,luu:longint;
    State:string;
    xet,cungchieu:boolean;
    f:text;
procedure nhap;
var m,k:longint;St:string;
begin
    assign(f,fi);
    reset(F);
    readln(f,n,m,k);
    readln(f,St);
    readln(f,State);
    if St='to head' then mv:=-1
    else mv:=1;
    if mv*(m-k)>0 then cungchieu:=true
    else cungchieu:=false;
    VtC:=k;
    close(f);
end;
procedure xuat;
begin
    assign(f,fo);
    rewrite(f);
    if xet then writeln(f,'Stowaway')
    else
     begin
        write(f,'Controller ');
        writeln(f,luu);
     end;
    close(f);
end;
procedure process;
var cuoi,i,reach1,p,j,S1:longint;
begin
    i:=1;
    reach1:=0;
    while i<=length(State) do
     begin
        if State[i]='1' then cungchieu:=false;
                for j:=i+1 to length(State) do
                    if State[j]='1' then
                     begin
                        reach1:=j-i+1;
                        break;
                     end;
        if mv=1 then cuoi:=n
        else cuoi:=1;
        if not cungchieu then S1:=n+abs(cuoi-vtC)-1
        else S1:=abs(cuoi-vtC);
        if State[i]='0' then
            if S1<reach1 then
             begin
                i:=i+S1-1;
                break;
             end;
        inc(i);
        if (VtC=n) and (mv=1) then mv:=mv*(-1)
        else
                if (VtC=1) and (mv=-1) then mv:=mv*(-1);
        VtC:=VtC+mv;
     end;
    if i>=length(State)+1 then xet:=true
    else
     begin
        xet:=false;
        luu:=i;
     end;
end;
begin
    nhap;
    process;
    xuat;
end.

var
   i,j,n,m,k,p:longint;
   napr,t:string;
BEGIN
readln(n,m,k);
readln(napr);
readln(t);
if (napr='to head') then p:=-1 else p:=1;
for i:=1 to length(t) do
    begin
    {Zayac}
    if (t[i]='0') then
        begin
        if (p=-1)and(m>k)and(m+1<=n) then inc(m);
        if (p=-1)and(m<k)and(m>=2) then dec(m);
        if (p=1)and(m>k)and(m+1<=n) then inc(m);
        if (p=1)and(m<k)and(m>=2) then dec(m);
        {Controller}
        if (k+p>=1)and(k+p<=n) then k:=k+p
        else
            begin
            p:=-p;
            k:=k+p;
            end;
        end
    else
        begin
        {Controller}
        if (k+p>=1)and(k+p<=n) then k:=k+p
        else
            begin
            p:=-p;
            k:=k+p;
            end;
        if (p=-1)and(k<>n) then m:=n;
        if (p=-1)and(k=n) then m:=1;
        if (p=1)and(k<>1) then m:=1;
        if (p=1)and(k=1) then m:=n;
        end;
    {End game?}
    if (m=k) then
        begin
        writeln('Controller ',i);
        halt;
        end;
    end;
writeln('Stowaway');
END.

uses math;

Var n:longint;
    z,k:longint;
    i,j:longint;
    s:string;
    na:longint;

Procedure jump(ii:longint);

Begin

if s[i]='0' then begin if na=1 then z:=min(z+1,n);
                       if na=-1 then z:=max(1,z-1);

                       k:=k+na; if k=n then na:=-1;
                                if k=1 then na:=1;

                       if k=z then begin Writeln('Controller ',ii);
                                         halt;end;end;
if s[i]='1' then begin if na=1 then z:=1;
                       if na=-1 then z:=n;

                       k:=k+na; if k=n then na:=-1;
                                if k=1 then na:=1;

                       if k=z then begin Writeln('Controller ',ii);
                                         halt;end;end;

end;

Begin

Readln(n,z,k);
Readln(s);

if s[4]='t' then na:=1 else na:=-1;

Readln(s);

for i:=1 to length(s)-1 do jump(i);

Writeln('Stowaway');

End.

Const
        fi = '';
        fo = '';

Var     s, dir : String;
        n, m, k, i : Longint;

Function Min(a, b : Longint) : Longint;
 Begin
        If a < b Then Exit(a);
        Exit(b);
 End;

Function Max(a, b : Longint) : Longint;
 Begin
        If a > b Then Exit(a);
        Exit(b);
 End;

Begin
        Readln(n,m,k);
        Readln(dir);
        Readln(s);
        For i := 1 to length(s) do
                If s[i] = '0' Then
                Begin
                        If dir[7] = 'd' Then
                        Begin
                                If m < k Then
                                Begin
                                        m := Max(m-1,1);
                                        k := k-1;
                                        If k = 1 Then
                                                dir := 'to tail';
                                        If m = k Then
                                        Begin
                                                Writeln('Controller ',i);
                                                Exit;
                                        End;
                                End
                                Else
                                Begin
                                        m := Min(m+1,n);
                                        k := k-1;
                                        If k = 1 Then
                                                dir := 'to tail';
                                End;
                        End
                        Else
                        Begin
                                If m < k Then
                                Begin
                                        m := Max(m-1,1);
                                        k := k+1;
                                        If k = n Then
                                                dir := 'to head';
                                End
                                Else
                                Begin
                                        m := Min(m+1,n);
                                        k := k+1;
                                        If k = n Then
                                                dir := 'to head';
                                        If m = k Then
                                        Begin
                                                Writeln('Controller ',i);
                                                Exit;
                                        End;
                                End;
                        End;
                End
                Else
                Begin
                        If dir[7] = 'd' Then
                        Begin
                                m := n;
                                k := k-1;
                                If k = 1 Then
                                        dir := 'to tail';
                        End
                        Else
                        Begin
                                m := 1;
                                k := k+1;
                                If k = n Then
                                        dir := 'to head';
                        End;
                End;
        Writeln('Stowaway');
End.

var
  i,n,m,k:integer;
  s:string;
  d:boolean;
Begin
 readln(n,m,k);
 readln(s);
 if s='to head' then d:=true else d:=false;
 if (k=1)and(d=true)then d:=false;
 if (k=n)and(d=false)then d:=true;
 readln(s);
 for i:=1 to length(s) do
  begin
   if s[i]='0' then
    begin
     if (d=true)and((m<k)and(m<>1))then  dec(m) else
      if (d=true)and((m>k)and(m<>n))then  inc(m);
     if (d=false)and((m<k)and(m<>1))then  dec(m)  else
      if (d=false)and((m>k)and(m<>n))then  inc(m);
     if d=true then dec(k) else inc(k);
    end else
         begin
         if d=true then dec(k) else inc(k);
          if (d=true)and(k<>n)then m:=n else
           if (d=false)and(k<>1) then m:=1 else
            if (d=true)and(k=n) then  m:=1 else
             if (d=false)and(k=1) then  m:=1;
         end;
   if k=m then Begin write('Controller ',i); exit; end;
   if k=n then d:=true;
   if k=1 then d:=false;
  end;
   write('Stowaway');
 end.

var
max,f,n,m,i,j,k,off,tr: longint;
tt : longint;
s : String;
q : char;
a : Array[0..1000]of longint;
b : Array[0..70,0..70,-5..5,0..201]of longint;
function rec(x,y,shag,z : longint) : longint;
var i,tr,h,ht,shah: Longint;
begin
 if z > max then max := z;
 if z = f then
  begin
   b[x,y,shag,z] := maxlongint;
   exit(maxlongint);

  end;

 if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

 if x = y then
  begin
   b[x,y,shag,z] := z - 1;
   exit(b[x,y,shag,z]);
  end;

 if a[z] = 1 then
  begin

   shah := shag;
    h := y + shag;
      if (h = 0)or(h = n + 1) then
       begin
        shag := -shag;
        h := y;
       end;

   For i := 1 to n do
     begin
      if i = h then tr := z
      else
      tr := Rec(i,h,shag,z+1);
      if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
     end;
    rec := b[x,y,shah,z];
  end
 else
  begin
    shah := shag;
    h := x + 1;
    if h <= n then
     begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y;
       end;
      if h = y then tr := z
      else if ht = h then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
     end;

   h := x - 1;
   shag := shah;
   if h > 0 then
    begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y;
       end;
      if h = y then tr := z
      else if h = ht then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

    end;

   shag := shah;
   ht := y + shag;
   if (ht = 0)or(ht = n+1)
    then
     begin
      shag := -shag;
      ht := y;
     end;
   if ht = x then tr := z
   else
   tr := Rec(x,ht,shag,z+1);
   if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

   Rec := b[x,y,shah,z];
  end;
end;

 begin
  readln(n,m,k);
  readln(s);
  i := 0;
  while not seekeof do
    begin
     read(q);
     i := i + 1;
     if q = '1' then a[i] := 1
     else a[i] := 0;
    end;
   f := i;
   if s = 'to tail' then off := 1
   else off := -1;
   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 0 to f do
       b[i,j,k,tr] := -1;

   max := -maxlongint;
   Rec(m,k,off,1);

   if max = f then writeln('Stowaway')
   else writeln('Controller ',max);
 end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var i,n,m,k,z,c : Integer;
    s : string;
    nap : Boolean;
begin
  Readln(n,m,k);
  Readln(s);
  if s[4]='t' then nap:=True;
  if s[4]='h' then nap:=false;
  Readln(s);
  if m>k then z:=n
  else z:=1;
  c:=k;
  for i:=1 to length(s) do
   begin
     if s[i]='1' then
       begin
         if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1
         else z:=n;
       end;
     if nap then c:=c+1
     else c:=c-1;
     if z=c then
       begin
         Writeln('Controller ', i);
         Readln;
         Exit;
       end;
     if c=0 then
       begin
         c:=1;
         nap:=True;
       end;
     if c=n+1 then
      begin
        c:=n;
        nap:=False;
      end;
   end;
   Writeln('Stowaway');
   Readln;
end.

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=n then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if s[i]='1' then begin
      if k>n div 2-1 then m:=1 else m:=n;
    end else begin
      if m-k>0 then begin
        if (m-k>1) and (m>1) then dec(m) else inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else dec(m);
      end;
    end;
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if s[i]='1' then begin
      if k>n div 2+1 then m:=n else m:=1;
    end else begin
      if k-m>0 then begin
        if (k-m>1) and (m<n) then inc(m) else dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else inc(m);
      end;
    end;
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if (k=m) or (m<1) or (m>n) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

uses math;
var i,n,m,k:longint;
    s:string;
    v:boolean;
 begin
   readln(n,m,k);
   readln(s);
   if s[4]='h' then v:=true
               else v:=false;
   readln(s);
   for i:=1 to length(s)-1 do
    begin
      if s[i]='1' then
           begin
             if (k=1) then m:=n
             else if (k=n) then m:=1
             else if v then m:=n
             else m:=1;
             if v then k:=k-1
                  else k:=k+1;
             if (k=1)or(k=m) then v:=v xor true;

           end
      else begin
             if v and (m<k) then m:=max(m-1,1)
             else if v then m:=min(m+1,n)
             else if m>k then m:=min(m+1,n)
             else m:=max(m-1,1);

             if v then k:=k-1
                  else k:=k+1;
             if (k=1)or(k=m) then v:=v xor true;

             if m=k then begin writeln('Controller ',i); halt(0); end;
           end;
    end;
   writeln('Stowaway');
 end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var i,n,m,k,z,c : Integer;
    s : string;
    nap : Boolean;
begin
  Readln(n,m,k);
  Readln(s);
  if s[4]='t' then nap:=True;
  if s[4]='h' then nap:=false;
  Readln(s);
  if m>k then z:=n
  else z:=1;
  c:=k;
  for i:=1 to length(s) do
   begin
     if s[i]='1' then
       begin
         if (nap and (c<>1)) or (not nap and (c<>n)) then z:=1
         else z:=n;
       end;
     if nap then c:=c+1
     else c:=c-1;
     if z=c then
       begin
         Writeln('Controller ', i);
         Readln;
         Exit;
       end;
     if c=0 then
       begin
         c:=1;
         nap:=True;
       end;
     if c=n+1 then
      begin
        c:=n;
        nap:=False;
      end;
   end;
   Writeln('Stowaway');
   Readln;
end.

var
b:array[1..10000] of char;
n,m,i,k,l,j,p:longint;
s:string;
begin
readln(n,m,k);
readln(s);
if s='to tail' then p:=1 else p:=0;
i:=0;
while not eoln do
 begin
  inc(i);
  read(b[i]);
 end;
if p=0 then l:=1
else l:=n;
for j:=1 to i do
 begin
  if b[j]='0' then
   if p=0 then
     dec(k) else inc(k) else
  if p=0 then l:=n else l:=1;
  if k=l then begin write('Controller ',j); exit;end;
  if k=n then p:=0;
  if k=1 then p:=1;
 end;
write('Stowaway');
end.

var
 n,m,k,i,p,f:longint;
 s:string;
 c:char;
 begin
   { assign(input,'input.txt');
    assign(output,'output.txt');
    reset(input);
    rewrite(output);}
    readln(n,k,m);
    readln(s);
    if s='to head' then
        p:=-1
        else
        p:=1;
    i:=0;
     while eoln<>true do
        begin

         read(c);
          inc(i);
          if c='0' then
                begin
                 if p=-1 then
                        if (k-1>m)and(m<>1) then
                                dec(k)
                                else
                                if (m=1)and(2>k-1)and(k-1>0) then
                                        dec(k)
                                else
                                if (m=1)and(k=2)and(k+1<n) then
                                        inc(k)
                                else
                                if (m=1) then
                                f:=1
                                else
                        if (k+1<=n)and(m=k-1) then
                                inc(k)
                        else
                        if (k-1>0)and(m=k+1) then
                                dec(k);
                 if p=1 then
                        if (k+1<m)and(m<>n) then
                                inc(k)
                                else
                                if (m=n)and(m-1>k+1)and(k+1<n) then
                                        inc(k)
                                        else
                                if (m=n)and(k=m-1)and(k-1>0) then
                                        dec(k)
                                        else
                                if m=n then
                                        f:=1
                                        else
                        if (k-1>0)and(m=k+1) then
                                dec(k)
                        else
                         if (k+1<=n)and(m=k-1) then
                                inc(k);
                 inc(m,p);
                 if m>n then
                        begin
                         m:=n-1;
                         p:=-1;
                        end;
                 if m<1 then
                        begin
                         m:=2;
                         p:=1;
                        end;
                 if m=k then
                        begin
                         writeln('Controller',' ',i);
                         halt;
                        end;
                end;
          if c='1' then
                begin
                 k:=0;
                  inc(m,p);
                 if m>n then
                        begin
                         m:=n-1;
                         p:=-1;
                        end;
                 if m<1 then
                        begin
                         m:=2;
                         p:=1;
                        end;
                 if p=1 then

                 if m-2>0 then
                        k:=m-2
                        else
                        k:=m-1;
                 if p=-1 then
                 if m+2<=n then
                        k:=m+2
                        else
                        k:=m+1;

                end;

        end;
    writeln('Stowaway');
    end.

Program			BB;
var
k,p,s,c,m,time,i,n : longint;
len,rp : string;
flag : Boolean;
begin
{Assign(input,'B.in');Assign(output,'B.out');
reset(input);rewrite(output);}
	readln(n,m,k);
	s:=m;c:=k;
	readln(Rp);
	if Rp[4]='h' then p:=-1 else p:=1;
	readln(len);
	time :=0;flag := false;
	for i :=1 to length(len) do
	begin
		if len[i]='1' then
		begin
			if p=-1 then s := n else s :=1;
		end;
                if i<>1 then
		begin
			c:=c+p;
			if c=0 then
			begin c:=2;p:=-p; end else
			if c=n+1 then
			begin c :=n-1;p:=-p;end;
		end;
		time := time+1;
		if s=c then begin flag := true;break;end;
	end;
	if flag=false then writeln('Stowaway') else
	writeln('Controller ',time);
{Close(input); Close(output);}

end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : ansistring;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  f:=false;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if (k-m<m-k)and(m<n) then inc(m) else if m>1 then dec(m);
  if s[i]='1' then f:=true;
  if (not f)and(k=m) then
  begin
   writeln('Controller ',i);
   halt;
  end;
  inc(k,h);
  if (not f)and(k=m) then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  f:=false;
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if (k<m)and(m<n)and(m+1<>k) then inc(m) else if (m>1)and(m-1<>k) then dec(m);
  if s[i]='1' then
  begin
   f:=true;
   m:=0;
  end;
  inc(k,h);
  if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

Const
        fi = '';
        fo = '';

Var     s, dir : String;
        n, m, k, i : Longint;

Function Min(a, b : Longint) : Longint;
 Begin
        If a < b Then Exit(a);
        Exit(b);
 End;

Function Max(a, b : Longint) : Longint;
 Begin
        If a > b Then Exit(a);
        Exit(b);
 End;

Begin
        Readln(n,m,k);
        Readln(dir);
        Readln(s);
        For i := 1 to length(s) do
                If s[i] = '0' Then
                Begin
                        If dir[7] = 'd' Then
                        Begin
                                If m < k Then
                                Begin
                                        m := Max(m-1,1);
                                        k := k-1;
                                        If m = k Then
                                        Begin
                                                Writeln('Controller ',i);
                                                Exit;
                                        End;
                                End
                                Else
                                Begin
                                        m := Min(m+1,n);
                                        k := k-1;
                                        If k < 1 Then
                                        Begin
                                                k := 2;
                                                dir := 'to tail';
                                        End;
                                End;
                        End
                        Else
                        Begin
                                If m < k Then
                                Begin
                                        m := Max(m-1,1);
                                        k := k+1;
                                        If k > n Then
                                        Begin
                                                k := n-1;
                                                dir := 'to head';
                                        End;
                                End
                                Else
                                Begin
                                        m := Min(m+1,n);
                                        k := k+1;
                                        If m = k Then
                                        Begin
                                                Writeln('Controller ',i);
                                                Exit;
                                        End;
                                End;
                        End;
                End
                Else
                Begin
                        If dir[7] = 'd' Then
                        Begin
                                m := n;
                                k := k-1;
                        End
                        Else
                        Begin
                                m := 1;
                                k := k+1;
                        End;
                End;
        Writeln('Stowaway');
End.

    var

     kk,max,f,n,m,i,j,k,off,tr: longint;
    tt : longint;
    s : String;
    q : char;
    a : Array[0..1000]of longint;
    b : Array[0..70,0..70,-5..5,0..201]of longint;

    function maxx(x,y : Longint):longint;
    begin
    if x > y then y := x;
    maxx := y;
    end;
    function rec(x,y,shag,z : longint) : longint;
    var i,tr,h,ht,shah: Longint;
    begin

     if x = y then
      begin
       b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);
       if b[x,y,shag,z] > max then max := b[x,y,shag,z];
       exit(b[x,y,shag,z]);
      end;

     if z = f then
      begin
       b[x,y,shag,z] := maxlongint;
       exit(maxlongint);

      end;

     if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

     if a[z] = 1 then
      begin

        shah := shag;
        h := y + shag;
          if (h = 0)or(h = n + 1) then
           begin
            shag := -shag;
            h := y + shag;
           end;

       For i := 1 to n do
         begin
          if i = h then tr := z
          else
          tr := Rec(i,h,shag,z+1);
          if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
         end;
        rec := b[x,y,shah,z];
      end
     else
      begin
        shah := shag;
        h := x + 1;
        if h <= n then
         begin
          ht := y + shag;
          if (ht = 0)or(ht = n + 1) then
           begin
            shag := -shag;
            ht := y + shag;
           end;
          if h = y then tr := z
          else
          tr := Rec(h,ht,shag,z+1);
          if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
         end;

       h := x - 1;
       shag := shah;
       if h > 0 then
        begin
          ht := y + shag;
          if (ht = 0)or(ht = n + 1) then
           begin
            shag := -shag;
            ht := y + shag;
           end;
          if  h = y then tr := z
          else
          tr := Rec(h,ht,shag,z+1);
          if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

        end;

       shag := shah;
       ht := y + shag;
       if (ht = 0)or(ht = n+1)
        then
         begin
          shag := -shag;
          ht := y + shag;
         end;
       tr := Rec(x,ht,shag,z+1);
       if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

       Rec := b[x,y,shah,z];
      end;

     if b[x,y,shah,z] > max then max := b[x,y,shah,z];
    end;

     begin
      readln(n,m,kk);
      readln(s);

      i := 0;
      while not seekeof do
        begin
         read(q);
         i := i + 1;
         if q = '1' then a[i] := 1
         else a[i] := 0;
        end;
       f := i;
       if s = 'to tail' then off := 1
       else off := -1;
       for i := 1 to n do
        for j := 1 to n do
         for k := -1 to 1 do
          for tr := 0 to f do
           b[i,j,k,tr] := -1;

       max := -maxlongint;
       Rec(m,kk,off,1);

       if max >= f then writeln('Stowaway')
       else writeln('Controller ',max);
     end.

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=n then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if s[i]='1' then begin
      if k>n div 2-1 then m:=1 else m:=n;
    end else begin
      if m-k>0 then begin
        if (m-k>1) and (m>1) then dec(m) else inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else dec(m);
      end;
    end;
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if s[i]='1' then begin
      if k>n div 2+1 then m:=n else m:=1;
    end else begin
      if k-m>0 then begin
        if (k-m>1) and (m<n) then inc(m) else dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else inc(m);
      end;
    end;
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=m then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
    if k=n then f:=false;
  end else begin
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
    if k=1 then f:=true;
  end;
  if f then begin
    if s[i]='1' then begin
      if (k>=n div 2) and (k>2) then m:=1 else m:=n;
    end else begin
      if m-k>=0 then begin
        if (m-k>1) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end;
    end;
  end else begin
    if s[i]='1' then begin
      if (k>=n div 2) and (k<n-1) then m:=n else m:=1;
    end else begin
      if k-m>=0 then begin
        if (k-m>1) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end;
    end;
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=n then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if s[i]='1' then begin
      if k>n div 2+1 then m:=1 else m:=n;
    end else begin
      if m-k>0 then begin
        if (m-k>1) and (m>1) then dec(m) else inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else dec(m);
      end;
    end;
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if s[i]='1' then begin
      if k>n div 2-1 then m:=n else m:=1;
    end else begin
      if k-m>0 then begin
        if (k-m>1) and (m<n) then inc(m) else dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else inc(m);
      end;
    end;
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

var
 n,m,k,i,pp,posk,poss:longint;
 f:boolean;
 s,s1:ansistring;

begin
 readln(n,m,k);
 readln(s);
 if s='to head' then f:=true;
 posk:=k;
 poss:=m;
 readln(s1);
 pp:=length(s1);

 for i:=1 to pp do if s1[i]='0' then
 begin
  if f then
  begin
   if (poss<1) then dec(poss);
   if (posk>1) then dec(posk);
   if posk=1 then f:=false;
  end else
  begin
   if (poss<n) then inc(poss);
   if (posk<n) then inc(posk);
   if posk=n then f:=true;
  end;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end else
 begin
  if f then
  begin
   if (posk<n) then inc(posk);
   if posk=n then f:=false;
  end else
  begin
   poss:=m;
   if (posk>1) then dec(posk);
   if posk=1 then  f:=true;
  end;
  if f then if posk<n then poss:=n else posk:=n-1;
  if not f then if posk>1 then posk:=1 else posk:=2;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  f:=false;
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if ((k-m<=m-k)and(m<n))and(m+1<>k) then inc(m) else if (m>1)and(m-1<>k) then dec(m);
  if s[i]='1' then
  begin
   f:=true;
   m:=0;
  end;
  inc(k,h);
  if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

uses math;

var i,l,n,pz,pk:longint;
    s:string;

  procedure make_step(var x,l:longint);
   begin
    x:=x+l;
    if x=0 then begin x:=1; l:=-l; end else
    if x>n then begin x:=n; l:=-l; end;
   end;

  procedure go_out(x,y,t:longint);
   begin
    if x=y then
     begin
      writeln('Controller ',t);
      halt;
     end;
   end;

 begin
  readln(n,pz,pk);
  readln(s);
  if s='to tail' then l:=1 else l:=-1;
  readln(s);
  for i:=1 to n do
   begin
    if s[i]='1' then
     begin
      if l=1 then
       begin
        if pk=1 then pz:=n else pz:=1;
       end else
        begin
         if pk=n then pz:=1 else pz:=n;
        end;
      go_out(pk,pz,i);
      make_step(pk,l);
      go_out(pk,pz,i);
     end else
      begin
       if l=1 then
        begin
         if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);
        end else
         begin
          if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);
         end;
       go_out(pk,pz,i);
       make_step(pk,l);
       go_out(pk,pz,i);
      end;
   end;
  writeln('Stowaway');
 end.

var a:array [1..1000] of longint;
    b,n,i,j,k,d,m,max:longint;
    s,p:string;

     begin
 readln(n,k,m);
 readln(s);
 readln(p);
 for i:=1 to length(p) do
  begin
   if p[i]='1' then
    begin
     if s[4]='h' then begin
      dec(m);
           if m=0 then
      begin
       m:=2;
       s[4]:='t';
      end;
      end;
     if s[4]='t' then begin
      inc(m);
      if m=n+1 then
       begin
          m:=n-1;
          s[4]:='h';
       end;
      end;

    if (s[4]='h') then k:=m+1
     else k:=m-1;
    if (m=1) or (m=n) then
     begin
      if k=m+1 then k:=m-1
       else k:=m+1;
     end;
    if k=0 then k:=n;
    if k=n+1 then k:=1;
    end else
     begin

     d:=1;
     if (m>k) then d:=1
      else d:=2;

     if (d=1) and (k<>1) then dec(k);
     if (d=2) and (k<>n) then inc(k);

       if s[4]='h' then begin
      dec(m);
           if m=0 then
      begin
       m:=2;
       s[4]:='t';
      end;
      end;
     if s[4]='t' then begin
      inc(m);
      if m=n+1 then
       begin
          m:=n-1;
          s[4]:='h';
       end;
      end;

     if k=m then begin
       writeln('Controller ',i);
       halt;
     end;

     end;
  end;
 writeln('Stowaway');
end.

var

 kk,max,f,n,m,i,j,k,off,tr: longint;
tt : longint;
s : String;
q : char;
a : Array[0..1000]of longint;
b : Array[0..70,0..70,-5..5,0..201]of longint;
function rec(x,y,shag,z : longint) : longint;
var i,tr,h,ht,shah: Longint;
begin

 if x = y then
  begin
   b[x,y,shag,z] := z;
   exit(b[x,y,shag,z]);
  end;

  if z > max then max := z;

 if z = f then
  begin
   b[x,y,shag,z] := maxlongint;
   exit(maxlongint);

  end;

 if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

 if a[z] = 1 then
  begin

    shah := shag;
    h := y + shag;
      if (h = 0)or(h = n + 1) then
       begin
        shag := -shag;
        h := y;
       end;

   For i := 1 to n do
     begin
      if i = h then tr := z
      else
      tr := Rec(i,h,shag,z+1);
      if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
     end;
    rec := b[x,y,shah,z];
  end
 else
  begin
    shah := shag;
    h := x + 1;
    if h <= n then
     begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if h = y then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
     end;

   h := x - 1;
   shag := shah;
   if h > 0 then
    begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if  h = y then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

    end;

   shag := shah;
   ht := y + shag;
   if (ht = 0)or(ht = n+1)
    then
     begin
      shag := -shag;
      ht := y + shag;
     end;
   tr := Rec(x,ht,shag,z+1);
   if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

   Rec := b[x,y,shah,z];
  end;
end;

 begin
  readln(n,m,kk);
  readln(s);

  i := 0;
  while not seekeof do
    begin
     read(q);
     i := i + 1;
     if q = '1' then a[i] := 1
     else a[i] := 0;
    end;
   f := i;
   if s = 'to tail' then off := 1
   else off := -1;
   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 0 to f do
       b[i,j,k,tr] := -1;

   max := -maxlongint;
   Rec(m,kk,off,1);

   if max = f then writeln('Stowaway')
   else writeln('Controller ',max);
 end.

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=0;
for i:=1 to ls do begin
  if f then begin
    if s[i]='1' then begin
      if k>n div 2-1 then m:=1 else m:=n;
    end else begin
      if m-k>0 then begin
        if (m-k>1) and (m>1) then dec(m) else inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else dec(m);
      end;
    end;
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if s[i]='1' then begin
      if k>n div 2+1 then m:=n else m:=1;
    end else begin
      if k-m>0 then begin
        if (k-m>1) and (m<n) then inc(m) else dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else inc(m);
      end;
    end;
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if (k=m) or (m<1) or (m>n) then begin
    r:=i;
    break;
  end;
end;
if r=0 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

program problemB;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  orient,n,m,k,i,j,p:integer;
  s,q:string;
begin
  readln(n,m,k);
  readln(s);
  readln(q);
  if s='to head' then orient:=-1 else orient:=1;
  p:=-1;
  for i:=1 to length(q) do begin
    case q[i] of
      '0':begin
        if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        if k=m then begin
          p:=k;
          break;
        end;
      end;
      '1':begin
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        m:=k-orient;
        if (m>n) then m:=1;
        if (m<1) then m:=n;
        if m=k then begin
          p:=k;
          break;
        end;
      end;
    end;
    writeln(m,' ',k);
  end;
  if p=-1 then writeln('Stowaway') else writeln('Controller ',p);
  readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.

Const
        fi = '';
        fo = '';

Var     s, dir : String;
        n, m, k, i : Longint;

Function Min(a, b : Longint) : Longint;
 Begin
        If a < b Then Exit(a);
        Exit(b);
 End;

Function Max(a, b : Longint) : Longint;
 Begin
        If a > b Then Exit(a);
        Exit(b);
 End;

Begin
        Readln(n,m,k);
        Readln(dir);
        Readln(s);
        For i := 1 to n do
                If s[i] = '0' Then
                Begin
                        If dir[7] = 'd' Then
                        Begin
                                If m < k Then
                                Begin
                                        m := Max(m-1,1);
                                        k := k-1;
                                        If m = k Then
                                        Begin
                                                Writeln('Controller ',i);
                                                Exit;
                                        End;
                                End
                                Else
                                Begin
                                        m := Min(m+1,n);
                                        k := k-1;
                                        If k < 1 Then
                                        Begin
                                                k := 2;
                                                dir := 'to tail';
                                        End;
                                End;
                        End
                        Else
                        Begin
                                If m < k Then
                                Begin
                                        m := Max(m-1,1);
                                        k := k+1;
                                        If k > n Then
                                        Begin
                                                k := n-1;
                                                dir := 'to head';
                                        End;
                                End
                                Else
                                Begin
                                        m := Min(m+1,n);
                                        k := k+1;
                                        If m = k Then
                                        Begin
                                                Writeln('Controller ',i);
                                                Exit;
                                        End;
                                End;
                        End;
                End
                Else
                Begin
                        If dir[7] = 'd' Then
                        Begin
                                If k < n Then
                                Begin
                                        m := n;
                                        k := k-1;
                                End
                                Else
                                Begin
                                        m := 1;
                                        k := k-1;
                                End;
                        End
                        Else
                        Begin
                                If k > 1 Then
                                Begin
                                        m := 1;
                                        k := k+1;
                                End
                                Else
                                Begin
                                        m := n;
                                        k := k+1;
                                End;
                        End;
                End;
        Writeln('Stowaway');
End.

uses math;
var
        n,m,k,l,tt:longint;
        s,t:string;
procedure nhap;
begin
        readln(n,m,k);
        readln(t);
        readln(s);
        l:=length(s);
        if t='to head' then tt:=-1 else tt:=1;
end;
procedure xuly;
var
        i:longint;
begin
        for i:=1 to l do
        begin
                if s[i]='0' then
                begin
                        if tt=-1 then
                        begin
                                if m<k then m:=math.max(1,m-1)
                                else m:=math.min(n,m+1);
                        end
                        else
                        begin
                                if m>k then m:=math.min(n,m+1)
                                else m:=math.max(1,m-1);
                        end;
                        k:=k+tt;
                        if k=m then
                        begin
                                writeln('Controller ',i);
                                exit;
                        end;
                end
                else
                begin
                        if tt=-1 then m:=n
                        else m:=1;
                end;
                if k=1 then tt:=1;
                if k=n then tt:=-1;
        end;
        writeln('Stowaway');
end;
begin
        nhap;
        xuly;
end.

var
  o,n,x,y,i,m:longint;
  s:ansistring;

begin
  readln(n,x,y);
  readln(s);
  if (s[4]='h')then o:=1 else o:=2;
  readln(s);
  m:=length(s);
  for i:=1 to m-1 do begin
    if (s[i]='0')then begin
      if (x=1)then inc(x)else
      if (x=n)then dec(x)else
      if (abs(x-1-y)>abs(x+1-y))then dec(x)else
      inc(x);
      if (x=y)then begin writeln('Controller ',i);exit;end;
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end else begin
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (y=n)then x:=1 else
      if (y=1)then x:=n else
      if (o=1)then begin
        x:=n;
        if (y=n-1)then x:=1;
      end else begin
        x:=1;
        if (y=2)then x:=n;
      end;
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end;
  end;
  writeln('Stowaway');
end.

var n,x,y,g,max,t,i,j:longint;
    s:string;

procedure tt(x:longint);
var k:longint;
 begin
  k:=0;
  if g>0 then begin
               if x>=y then k:=x-y
                       else k:=2*n-x-y;
              end
         else begin
               if x<=y then k:=y-x
                       else k:=y-1+x-1;
              end;
  if k>max then begin
                 max:=k;
                 t:=x;
                end;
 end;

 begin
  readln(n,x,y);
  readln(s);
  if s[length(s)]='d' then g:=-1
                      else g:=1;
  readln(s);
  for i:=1 to length(s) do
   begin
    if (y=1) then g:=1;
    if (y=n) then g:=-1;
    max:=-1;
    t:=x;
    if s[i]='0' then begin
                      y:=y+g;

                      if (x-1>=1) and (x-1<>y-g) and (x-1<>y) then tt(x-1);
                      if (x+1<=n) and (x+1<>y-g) and (x+1<>y) then tt(x+1);
                      tt(x);

                      x:=t;

                      if x=y-g then begin
                                     writeln('Controller ',i);
                                     halt;
                                    end;
                     end
                else begin
                      y:=y+g;

                      for j:=1 to n do
                       if (j<>y-g) and
                          (j<>y) then tt(j);

                      x:=t;

                      if x=y-g then begin
                                     writeln('Controller ',i);
                                     halt;
                                    end;
                     end;
    if x=y then begin
                 writeln('Controller ',i);
                 halt;
                end;
   end;
  writeln('Stowaway');
 end.

Const
        fi = '';
        fo = '';

Var     n, m, k, kq : Longint;
        s, t : String;
        kt : boolean;

Procedure ReadFile;
 Begin
        Assign(Input, fi);
        Reset(Input);
        Readln(n,m,k);
        Readln(t);
        Readln(s);
        Close(Input);
 End;

Procedure WriteFile;
 Begin
        Assign(Output, fo);
        Rewrite(Output);
        If kt Then
                Writeln('Stowaway')
        Else    Writeln('Controller ',kq);
        Close(Output);
 End;

Procedure Solve;
 Var    dir : Boolean;
        i, time : Longint;
 Begin
        dir := t[length(t)] = 'd';
        Kt := True;
        For i := 1 to Length(S) do
        Begin
                If dir Then
                Begin
                        If k = 1 Then
                        Begin
                                dir := not dir;
                                k := k+1;
                        End
                        Else    k := k-1;
                        If m < k Then
                        Begin
                                m := m-1;
                                If m = 0 Then m := 1;
                        End
                        Else
                        Begin
                                m := m+1;
                                If m = n+1 Then m := n;
                        End;
                End
                Else
                Begin
                        If k = n Then
                        Begin
                                dir := not dir;
                                k := k-1;
                        End
                        Else    k := k+1;
                        If m < k Then
                        Begin
                                m := m-1;
                                If m = 0 Then m := 1;
                        End
                        Else
                        Begin
                                m := m+1;
                                If m = n+1 Then m := n;
                        End;
                End;
                If s[i] = '0' Then
                Begin
                        If m = k Then
                        Begin
                                Kt := False; Kq := i; Break;
                        End;
                End
                Else
                Begin
                        If dir Then m := n
                        Else    m := 1;
                End;
        End;
 End;

Begin
        ReadFile;
        Solve;
        WriteFile;
End.

{$apptype console}
{$R-,S+,I+,Q+}
const
     inf = 'input.txt';
     outf = 'output.txt';
var
 n,m,k,i,len:longint;
 s,t:string;
begin
 //reset(input,inf);
 //rewrite(output,outf);
 readln(n,m,k);
 readln(s);
 readln(t);
 len:=length(t);
 for i:=1 to len do
  begin
   if t[i] = '1' then
    begin
     if s[4] = 'h' then
      begin
       if k = 1 then
        begin
         s[4]:='t';
         inc(k);
        end else dec(k);
       m:=n;
      end else
      begin
       if k = n then
        begin
         s[4]:='h';
         dec(k);
        end else inc(k);
       m:=1;
      end;
     continue;
    end;
   if m > k then m:=n else m:=1;
   if s[4] = 'h' then
    begin
     if k = 1 then
      begin
       s[4]:='t';
       inc(k);
      end else dec(k);
    end else
    begin
     if k = n then
      begin
       s[4]:='h';
       dec(k);
      end else inc(k);
    end;
   if k = m then
    begin
     writeln('Controller ',i);
     exit;
    end;
  end;
 writeln('Stowaway');
end.

const
    fi='';
    fo='';
var
    VtC,mv,n,luu:longint;
    State:string;
    xet,cungchieu:boolean;
    f:text;
procedure nhap;
var m,k:longint;St:string;
begin
    assign(f,fi);
    reset(F);
    readln(f,n,m,k);
    readln(f,St);
    readln(f,State);
    if St='to head' then mv:=-1
    else mv:=1;
    if mv*(m-k)>0 then cungchieu:=true
    else cungchieu:=false;
    VtC:=k;
    close(f);
end;
procedure xuat;
begin
    assign(f,fo);
    rewrite(f);
    if xet then writeln(f,'Stowaway')
    else
     begin
        write(f,'Controller ');
        writeln(f,luu);
     end;
    close(f);
end;
procedure process;
var cuoi,i,reach1,p,j,S1:longint;
begin
    i:=1;
    reach1:=0;
    while i<=length(State) do
     begin
        if State[i]='1' then cungchieu:=false
        else
                for j:=i+1 to length(State) do
                    if State[j]='1' then
                     begin
                        reach1:=j-i+1;
                        break;
                     end;
        if mv=1 then cuoi:=n
        else cuoi:=1;
        if not cungchieu then S1:=n+abs(cuoi-vtC)-1
        else S1:=abs(cuoi-vtC);
        if State[i]='0' then
         begin
            if S1<reach1 then
             begin
                i:=i+S1-1;
                break;
             end
            else
             begin
                cungchieu:=false;
                p:=i;
                for i:=p+1 to p+reach1 do
                 begin
                    if (VtC=n) or (VtC=1) then mv:=mv*(-1);
                    VtC:=VtC+mv;
                end;
             end;
         end;
        inc(i);
        if (VtC=n) and (mv=1) then mv:=mv*(-1)
        else
                if (VtC=1) and (mv=-1) then mv:=mv*(-1);
        VtC:=VtC+mv;
     end;
    if i>=length(State)+1 then xet:=true
    else
     begin
        xet:=false;
        luu:=i;
     end;
end;
begin
    nhap;
    process;
    xuat;
end.

Program			BB;
var
k,p,s,c,m,time,i,n : longint;
len,rp : string;
flag : Boolean;
begin
{Assign(input,'B.in');Assign(output,'B.out');
reset(input);rewrite(output);}
	readln(n,m,k);
	s:=m;c:=k;
	readln(Rp);
	if Rp[4]='h' then p:=-1 else p:=1;
	readln(len);
	time :=0;flag := false;
	for i :=1 to length(len) do
	begin
		if len[i]='1' then
		begin
			if p=-1 then begin
                        if c<>1 then
                                s := n else
                                s := 1;
                        end else
                        begin
                                if c<>n then s :=1 else
                                s := n;
                        end;
		end;    if i<>1 then begin
			c:=c+p;
			if c=0 then
			begin c:=2;p:=-p; end else
			if c=n+1 then
			begin c :=n-1;p:=-p;end;
                        end;

		time := time+1;
		if s=c then begin flag := true;break;end;
	end;
	if flag=false then writeln('Stowaway') else
	writeln('Controller ',time);
{Close(input); Close(output);}

end.

{uses crt;
}const nn=300;
var m,t,n,i,j,k,p,max,kolvag:longint;
cc:char;
s,nap:string;   flag:boolean;
napcon,contr,zayaz:array[0..nn] of longint;
begin {clrscr;
 assign(input,'input.txt');reset(input);
} readln (kolvag,m,k);
 readln(nap);
 readln(s);
 n:=length(s);
 if nap='to head' then napcon[1]:=-1 else napcon[1]:=1;
 contr[1]:=k;
 for i:=2 to n do
   begin contr[i]:=contr[i-1]+napcon[i-1];
      if (contr[i]=kolvag)or(contr[i]=1) then napcon[i]:=-1*napcon[i-1] else napcon[i]:=napcon[i-1];

   end;

if s[1]='0' then  zayaz[1]:=m;
if s[1]='1' then  zayaz[1]:=contr[1]-napcon[2];
for i:=2 to n do
 begin
    if s[i-1]='0' then if (zayaz[i-1]=1)or(zayaz[i-1]=kolvag)
      then zayaz[i]:=zayaz[i-1] else zayaz[i]:=zayaz[i-1]+napcon[i-1];
    if s[i-1]='1' then zayaz[i]:=contr[i-1];

 end;

{for i:=1 to n do writeln(i,' ',contr[i],' ',zayaz[i],' ',napcon[i]); }
for i:=1 to n do if (contr[i]=zayaz[i])and(s[i]='0') then begin flag:=true;break;end;
  if flag then writeln('Controller',' ',i-1) else writeln('Stowaway');

end.

var
a,s1:string;
i,j,k,l,n,m:longint;
begin
readln(n,m,k);
readln(s1);
read(a);
for i:=1 to length(a) do
 begin
  if k=1 then s1:='to tail';
  if k=n then s1:='to head';
  if (a[i]='1') and (i=length(a)) then
   begin
    write('Stawaway');
    exit;
   end;
  if ((m=1) and (k=2) and (a[i]='0') and (s1='to head')) or ((m=n) and (k=n-1) and (a[i]='0') and (s1='to tail')) then
   begin
    write('Controller ',i);
    exit;
   end;
  if m<k then m:=1;
  if m>k then m:=n;
  if (a[i]='1') and (s1='to head') then m:=n;
  if (a[i]='1') and (s1='to tail') then m:=1;
  if s1='to tail' then inc(k)
   else dec(k);
 end;
end.

var a:array [1..1000] of longint;
    b,n,i,j,k,d,m,max:longint;
    s,p:string;

     begin
 readln(n,k,m);
 readln(s);
 readln(p);
 for i:=1 to length(p) do
  begin
   if p[i]='1' then
    begin
     if s[4]='h' then begin
      dec(m);
           if m=0 then
      begin
       m:=2;
       s[4]:='t';
      end;
      end;
     if s[4]='t' then begin
      inc(m);
      if m=n+1 then
       begin
          m:=n-1;
          s[4]:='h';
       end;
      end;

    if s[4]='h' then k:=m+1
     else k:=m-1;
    if k=0 then k:=n;
    if k=n+1 then k:=1;
    end else
     begin

     d:=1;
     if (m>k) then d:=1
      else d:=2;

     if (d=1) and (k<>1) then dec(k);
     if (d=2) and (k<>n) then inc(k);

       if s[4]='h' then begin
      dec(m);
           if m=0 then
      begin
       m:=2;
       s[4]:='t';
      end;
      end;
     if s[4]='t' then begin
      inc(m);
      if m=n+1 then
       begin
          m:=n-1;
          s[4]:='h';
       end;
      end;

     if k=m then begin
       writeln('Controller ',i);
       halt;
     end;

     end;
  end;
 writeln('Stowaway');
end.

Var n,i,j,k,l,m,t,r:longint;
s:string;
Begin
Readln(N,M,k);
Readln(s);
if s='to head' then
  r:=1
else
  r:=0;
s:='';
Readln(s);
For i:=1 to length(s) do begin
  if s[i]='0' then begin
    if M<k then begin
      if M>1 then
        dec(M);
    end
    else begin
      if M<N then
        inc(M);
    end;
  end;
  if r=1 then
    dec(k)
  else
    inc(k);
  if k=1 then
    r:=0;
  if k=N then
    r:=1;
  if s[i]='1' then begin
    if r=1 then begin
      if M=N then
        k:=1
      else
        k:=N;
    end
    else begin
      if M=1 then
        k:=N
      else
        k:=1;
    end;
  end;
  if k=M then begin
    writeln('Controller ',i);
    halt(0);
  end;
end;
writeln('Stowaway');
end.

Const
        fi = '';
        fo = '';

Var     n, m, k, kq, spt : Longint;
        a : Array[0..201] Of Longint;
        s, t : String;
        kt : boolean;

Procedure ReadFile;
 Begin
        Assign(Input, fi);
        Reset(Input);
        Readln(n,m,k);
        Readln(t);
        Readln(s);
        Close(Input);
 End;

Procedure WriteFile;
 Begin
        Assign(Output, fo);
        Rewrite(Output);
        If kt Then
                Writeln('Stowaway')
        Else    Writeln('Controller ',kq);
        Close(Output);
 End;

Procedure Init;
 Var    i : Longint;
 Begin
        For i := 1 to Length(s) do
                If s[i] = '1' Then
                Begin
                        Inc(spt);
                        a[spt] := i;
                End;
 End;

Procedure Solve;
 Var    dir : Boolean;
        i, time : Longint;
 Begin
        dir := t[length(t)] = 'd';
        kt := true;
        For i := 1 to spt do
        Begin
                If dir Then
                Begin
                        If m < k Then
                                time := k-1
                        Else    time := n+k-2;
                End
                Else
                Begin
                        If m > k Then
                                time := n-k
                        Else    time := n*2-k-1;
                End;
                If time < a[i]-a[i-1] Then
                Begin
                        kt := False;
                        kq := a[i-1]+time;
                        Break;
                End
                Else
                Begin
                        if dir Then
                        Begin
                                k := 1;
                                m := n;
                        End
                        Else
                        Begin
                                k := n;
                                m := 1;
                        End;
                        dir := not dir;
                End;
        End;
 End;

Begin
        ReadFile;
        Init;
        Solve;
        WriteFile;
End.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var i,n,m,k,z,c : Integer;
    s : string;
    nap : Boolean;
begin
  Readln(n,m,k);
  Readln(s);
  if s[4]='t' then nap:=True;
  if s[4]='h' then nap:=false;
  Readln(s);
  if m>k then z:=n
  else z:=1;
  c:=k;
  for i:=1 to length(s) do
   begin
     if s[i]='1' then
       begin
         if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1
         else z:=n;
       end;
     if nap then c:=c+1
     else c:=c-1;
     if z=c then
       begin
         Writeln('Controller ', i);
         Readln;
         Exit;
       end;
     if c=0 then
       begin
         c:=1;
         nap:=True;
       end;
     if c=n+1 then
      begin
        c:=n;
        nap:=False;
      end;
   end;
   Writeln('Stowaway');
   Readln;
end.

var
 n,m,k,i,pp,posk,poss:longint;
 f:boolean;
 s,s1:ansistring;

begin
 readln(n,m,k);
 readln(s);
 if s='to head' then f:=true;
 posk:=k;
 poss:=m;
 readln(s1);
 pp:=length(s1);

 for i:=1 to pp do if s1[i]='0' then
 begin
  if f then
  begin
   if (poss<1) then dec(poss);
   if (posk>1) then dec(posk);
   if posk=1 then f:=false;
  end else
  begin
   if (poss<n) then inc(poss);
   if (posk<n) then inc(posk);
   if posk=n then f:=true;
  end;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end else
 begin
  if f then
  begin
   if (posk<n) then inc(posk);
   if posk=n then f:=false;
  end else
  begin
   poss:=m;
   if (posk>1) then dec(posk);
   if posk=1 then  f:=true;
  end;
  if f then if posk<n then poss:=n else posk:=n-1;
  if not f then if posk>1 then posk:=1 else posk:=2;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

program problemB;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  orient,n,m,k,i,j,p:integer;
  s,q:string;
begin
  readln(n,m,k);
  readln(s);
  readln(q);
  if s='to head' then orient:=-1 else orient:=1;
  p:=-1;
  for i:=1 to length(q) do begin
    case q[i] of
      '0':begin
        if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        if k=m then begin
          p:=k;
          break;
        end;
      end;
      '1':begin
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        m:=k-orient;
        if (m>n) then m:=1;
        if (m<1) then m:=n;
        if m=k then begin
          p:=k;
          break;
        end;
      end;
    end;
    writeln(m,' ',k);
  end;
  if p=-1 then writeln('Stowaway') else writeln('Controller ',p);
  readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.

var
max,f,n,m,i,j,k,off,tr: longint;
tt : longint;
s : String;
q : char;
a : Array[0..1000]of longint;
b : Array[0..7,0..7,-5..5,0..21]of longint;
function rec(x,y,shag,z : longint) : longint;
var i,tr,h,ht,shah: Longint;
begin
 if z > max then max := z;
 if z = f then
  begin
   b[x,y,shag,z] := maxlongint;
   exit(maxlongint);

  end;
 if x = y then
  begin
   b[x,y,shag,z] := z;
   exit(b[x,y,shag,z]);
  end;
 if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

 b[x,y,shag,z] := z;
 if a[z] = 1 then
  begin
   shah := shag;
    h := y + shag;
      if (h = 0)or(h = n + 1) then
       begin
        shag := -shag;
        h := y + shag;
       end;

   For i := 1 to n do
     begin
      tr := Rec(i,h,shag,z+1);
      if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
     end;
    rec := b[x,y,shah,z];
  end
 else
  begin
    shah := shag;
    h := x + 1;
    if h <= n then
     begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if h = y then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
     end;

   h := x - 1;
   shag := shah;
   if h > 0 then
    begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if h = y then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

    end;

   shag := shah;
   ht := y + shag;
   if (ht = 0)or(ht = n+1)
    then
     begin
      shag := -shag;
      ht := y + shag;
     end;
   if ht = x then tr := z
   else
   tr := Rec(x,ht,shag,z+1);
   if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

   Rec := b[x,y,shah,z];
  end;
end;

 begin
  readln(n,m,k);
  readln(s);
  i := 0;
  while not seekeof do
    begin
     read(q);
     i := i + 1;
     if q = '1' then a[i] := 1
     else a[i] := 0;
    end;
   f := i;
   if s = 'to tail' then off := 1
   else off := -1;
   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 0 to f do
       b[i,j,k,tr] := -1;

   max := -maxlongint;
   Rec(m,k,off,1);

   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 1 to f do
       if b[i][j][k][tr] <>-1 then
        begin
         if tr > max then max := tr;
        end;

   if max = f then writeln('Stowaway')
   else writeln('Controller ',max
  );
 end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  f:=false;
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if (k<m)and(m<n)and(m+1<>k) then inc(m) else if (m>1)and(m-1<>k) then dec(m);
  if s[i]='1' then
  begin
   f:=true;
   m:=0;
  end;
  inc(k,h);
  if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

uses math;
var i,n,m,k:longint;
    s:ansistring;
    v:boolean;
 begin
   readln(n,m,k);
   readln(s);
   if s[4]='h' then v:=true
               else v:=false;
   readln(s);
   for i:=1 to length(s)-1 do
    begin
      if s[i]='1' then
           begin
             if v then k:=k-1
                  else k:=k+1;
             if (k=1)or(k=m) then v:=v xor true;

             if (k=1) then m:=n
             else if (k=n) then m:=1
             else if v then m:=n
             else m:=1;

           end
      else begin
             if v and (m<k) then m:=max(m-1,1)
             else if v then m:=min(m+1,n)
             else if m>k then m:=min(m+1,n)
             else m:=max(m-1,1);

             if v then k:=k-1
                  else k:=k+1;
             if (k=1)or(k=m) then v:=v xor true;

             if m=k then begin writeln('Controller ',i); halt(0); end;
           end;
    end;
   writeln('Stowaway');
 end.

var n,m,k,i,c,l,z:integer;
a:array[1..200] of char;
s:string;

procedure step1;
begin
if m<k then
  if m>1 then dec(m);
if m>k then
  if m<n then inc(m);
k:=k+c;
end;

procedure step2;
begin
k:=k+c;
if c=1 then
  if k<>1 then m:=1 else m:=n;
if c=-1 then
  if k<>n then m:=n else m:=1;
k:=k+c;
end;

begin
readln(n,m,k);
readln(s);
while not eoln do
  begin
  inc(l);
  read(a[l]);
  end;
if s='to head' then c:=-1 else c:=1;
for i:=1 to l do
  begin
  if a[i]='0' then step1 else step2;
  if (k=1) or (k=n) then c:=-c;
  if m=k then
    begin
    writeln('Controller ',i);
    halt;
    end;
  end;
writeln('Stowaway');
end.

program problemB;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  orient,n,m,k,i,j,p:integer;
  s,q:string;
begin
  readln(n,m,k);
  readln(s);
  readln(q);
  if s='to head' then orient:=-1 else orient:=1;
  p:=-1;
  for i:=1 to length(q) do begin
    case q[i] of
      '0':begin
        if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        if k=m then begin
          p:=k;
          break;
        end;
      end;
      '1':begin
        k:=k+orient;
        if (k=1) or (k=n) then orient:=-orient;
        m:=k-orient;
        if (m>n) then m:=1;
        if (m<1) then m:=n;
        if m=k then begin
          p:=k;
          break;
        end;
      end;
    end;
//    writeln(m,' ',k);
  end;
  if p=-1 then writeln('Stowaway') else writeln('Controller ',p);
  readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.

var n,m,k,i,napr:longint;
    s:String;
    a:array[0..51] of longint;

procedure fun1;
begin
 if (Napr=1) and (m+1=k) then begin
                               if m=1 then begin writeln('Controller ',i); halt; end;
                               dec(m);
                               dec(k);
                              end else
 if (napr=1) then begin
                   dec(k);
                   if k=0 then begin
                                k:=2; napr:=3-napr;
                               end;
                  end else
 if (napr=2) and (m=k+1) then begin
                               if m=n then begin writeln('Controller ',i); halt; end;
                               inc(m);
                               inc(k);
                              end else
  if (napr=2) then begin
                   inc(k);
                   if k=n+1 then begin
                                k:=n-1; napr:=3-napr;
                               end;
                  end;
end;

procedure fun2;
begin
 if napr=2 then begin
                 if k=1 then m:=n else
                 m:=1;
                end else
                begin
                 if k=n then m:=1 else
                 m:=n;
                end;
 if napr=1 then begin
                 k:=k-1;
                 if k=0 then begin
                              napr:=2;
                              k:=2;
                             end;
                end else
 if (napr=2) then begin
                   inc(k);
                   if k=n+1 then begin
                                k:=n-1; napr:=3-napr;
                               end;
                  end;
 if k=m then begin writeln('Controller ',i); halt; end;

end;

begin
readln(n,m,k);
readln(s);
if s='to head' then napr:=1 else napr:=2;
readln(S);
for i:= 1 to length(s) do
 begin
  if s[i]='0' then fun1 else fun2;
 end;
 writeln('Stowaway');
end.

var
 n,m,k,y,i:longint;
 s:string;
 c:char;
begin
readln(n,m,k);
readln(s);
if s='to head' then y:=-1 else y:=1;
i:=0;
while not eoln do
 begin
  read(c);
  inc(i);
  if c='0' then
   begin
    if (m<>1)and(m<>n) then
     if k>m then m:=m-1 else m:=m+1;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if k=m then
     begin
      writeln('Controller ',i);
      halt;
     end;
   end else
  if c='1' then
   begin
    m:=0;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if n-k>k-1 then m:=n else m:=1;
   end;
 end;
writeln('Stowaway');
end.

var n,m,j,i,k,l,z,temp:longint;s,s1:string;
procedure xx(f:longint);
 begin
  if (temp=-1) and (k>z) and (z>1) then z:=z+temp else
  if (temp=-1) and (k<z) and (z<n) then z:=z+1 else
  if (temp=1)  and (k<z) and (z<n) then z:=z+temp else
  if (temp=1)  and (k>z) and (z>1) then z:=z-1;

  k:=k+temp;
  if (k=1)or(k=n) then temp:=temp*-1;
  if k=z then begin writeln('Controller ',f);halt;end;
 end;
procedure zz(f:longint);
 begin
  if f=length(s) then begin writeln('Stowaway');halt;end;
  if (k<>n) or (k<>1)then k:=k+temp else temp:=temp*(-1);
  if k=1 then z:=n;

  if k=n then z:=1;
  if temp>0 then z:=1;
  if temp<0 then z:=n;
 end;
begin
{assign(input,'input.txt');reset(input);
assign(output,'output.txt');rewrite(output);}
readln(n,z,k);
readln(s1);
if s1='to head' then temp:=-1 else temp:=1;
readln(s);
for i:=1 to length(s) do
  if s[i]='0' then xx(i) else zz(i);
end.

Program			BB;
var
k,p,s,c,m,time,i,n : longint;
len,rp : string;
flag : Boolean;
begin
{Assign(input,'B.in');Assign(output,'B.out');
reset(input);rewrite(output);}
	readln(n,m,k);
	s:=m;c:=k;
	readln(Rp);
	if Rp[4]='h' then p:=-1 else p:=1;
	readln(len);
	time :=0;flag := false;
	for i :=1 to length(len) do
	begin
		if len[i]='1' then
		begin
			if p=-1 then s := n else s :=1;
		end else if i<>1 then
		begin
			c:=c+p;
			if c=0 then
			begin c:=2;p:=-p; end else
			if c=n+1 then
			begin c :=n-1;p:=-p;end;
		end;
		time := time+1;
		if s=c then begin flag := true;break;end;
	end;
	if flag=false then writeln('Stowaway') else
	writeln('Controller ',time);
{Close(input); Close(output);}

end.

    var

     kk,max,f,n,m,i,j,k,off,tr: longint;
    tt : longint;
    s : String;
    q : char;
    a : Array[0..1000]of longint;
    b : Array[0..70,0..70,-5..5,0..201]of longint;

    function maxx(x,y : Longint):longint;
    begin
    if x > y then y := x;
    maxx := y;
    end;
    function rec(x,y,shag,z : longint) : longint;
    var i,tr,h,ht,shah: Longint;
    begin

     if x = y then
      begin
       b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);
       if b[x,y,shag,z] > max then max := b[x,y,shag,z];
       exit(b[x,y,shag,z]);
      end;

     if z = f then
      begin
       b[x,y,shag,z] := maxlongint;
       exit(maxlongint);

      end;

     if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

     if a[z] = 1 then
      begin

        shah := shag;
        h := y + shag;
          if (h = 0)or(h = n + 1) then
           begin
            shag := -shag;
            h := y + shag;
           end;

       For i := 1 to n do
         begin
          if i = h then tr := z
          else
          tr := Rec(i,h,shag,z+1);
          if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
         end;
        rec := b[x,y,shah,z];
      end
     else
      begin
        shah := shag;
        h := x + 1;
        if h <= n then
         begin
          ht := y + shag;
          if (ht = 0)or(ht = n + 1) then
           begin
            shag := -shag;
            ht := y + shag;
           end;
          if h = y then tr := z
          else
          tr := Rec(h,ht,shag,z+1);
          if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
         end;

       h := x - 1;
       shag := shah;
       if h > 0 then
        begin
          ht := y + shag;
          if (ht = 0)or(ht = n + 1) then
           begin
            shag := -shag;
            ht := y + shag;
           end;
          if  h = y then tr := z
          else
          tr := Rec(h,ht,shag,z+1);
          if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

        end;

       shag := shah;
       ht := y + shag;
       if (ht = 0)or(ht = n+1)
        then
         begin
          shag := -shag;
          ht := y + shag;
         end;
       tr := Rec(x,ht,shag,z+1);
       if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

       Rec := b[x,y,shah,z];
      end;

     if b[x,y,shah,z] > max then max := b[x,y,shah,z];
    end;

     begin
      readln(n,m,kk);
      readln(s);

      i := 0;
      while not seekeof do
        begin
         read(q);
         i := i + 1;
         if q = '1' then a[i] := 1
         else a[i] := 0;
        end;
       f := i;
       if s = 'to tail' then off := 1
       else off := -1;
       for i := 1 to n do
        for j := 1 to n do
         for k := -1 to 1 do
          for tr := 0 to f do
           b[i,j,k,tr] := -1;

       max := -maxlongint;
       Rec(m,kk,off,1);

       if max = f then writeln('Stowaway')
       else writeln('Controller ',max);
     end.

var n,m,j,i,k,l,z,temp:longint;s,s1:string;
procedure xx(f:longint);
 begin
  if (temp=-1) and (k>z) and (z>1) then z:=z+temp else
  if (temp=-1) and (k<z) and (z<n) then z:=z+1 else
  if (temp=1)  and (k<z) and (z<n) then z:=z+temp else
  if (temp=1)  and (k>z) and (z>1) then z:=z-1;

  k:=k+temp;
  if (k=1)or(k=n) then temp:=temp*-1;
  if k=z then begin writeln('Controller ',f);halt;end;
 end;
procedure zz(f:longint);
 begin
  if f=length(s) then begin writeln('Stowaway');halt;end;
  k:=k+temp;
  if (k=1)or(k=n) then temp:=temp*-1;
  if k=1 then z:=n;
  if k=n then z:=1;
  if temp>0 then z:=1;
  if temp<0 then z:=n;
 end;
begin
{assign(input,'input.txt');reset(input);
assign(output,'output.txt');rewrite(output);   }
readln(n,z,k);
readln(s1);
if s1='to head' then temp:=-1 else temp:=1;
readln(s);
for i:=1 to length(s) do
  if s[i]='0' then xx(i) else zz(i);
end.

var
   i,j,n,m,k,p:longint;
   napr,t:string;
BEGIN
readln(n,m,k);writeln(n,m,k);
readln(napr);writeln(napr);
readln(t);writeln(t);
if (napr='to head') then p:=-1 else p:=1;
for i:=1 to length(t) do
    begin
    {Zayac}
    if (t[i]='0') then
        begin
        if (p=-1)and(m>k)and(m+1<=n) then inc(m);
        if (p=-1)and(m<k)and(m>=2) then dec(m);
        if (p=1)and(m>k)and(m+1<=n) then inc(m);
        if (p=1)and(m<k)and(m>=2) then dec(m);
        {Controller}
        if (k+p>=1)and(k+p<=n) then k:=k+p
        else
            begin
            p:=-p;
            k:=k+p;
            end;
        end
    else
        begin
        {Controller}
        if (k+p>=1)and(k+p<=n) then k:=k+p
        else
            begin
            p:=-p;
            k:=k+p;
            end;
        if (p=-1)and(k<>n) then m:=n;
        if (p=-1)and(k=n) then m:=1;
        if (p=1)and(k<>1) then m:=1;
        if (p=1)and(k=1) then m:=n;
        end;
    {End game?}
    if (m=k) then
        begin
        writeln('Controller ',i);
        halt;
        end;
        {writeln(t[i],' t=',i,' c=',k,' z=',m);}
    end;
writeln('Stowaway');
END.

var

 kk,max,f,n,m,i,j,k,off,tr: longint;
tt : longint;
s : String;
q : char;
a : Array[0..1000]of longint;
b : Array[0..70,0..70,-5..5,0..201]of longint;
function rec(x,y,shag,z : longint) : longint;
var i,tr,h,ht,shah: Longint;
begin

 if x = y then
  begin
   b[x,y,shag,z] := z - 1;
   exit(b[x,y,shag,z]);
  end;

  if z > max then max := z;

 if z = f then
  begin
   b[x,y,shag,z] := maxlongint;
   exit(maxlongint);

  end;

 if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

 if a[z] = 1 then
  begin

    shah := shag;
    h := y + shag;
      if (h = 0)or(h = n + 1) then
       begin
        shag := -shag;
        h := y;
       end;

   For i := 1 to n do
     begin
      if i = h then tr := z
      else
      tr := Rec(i,h,shag,z+1);
      if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
     end;
    rec := b[x,y,shah,z];
  end
 else
  begin
    shah := shag;
    h := x + 1;
    if h <= n then
     begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if h = y then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
     end;

   h := x - 1;
   shag := shah;
   if h > 0 then
    begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if  h = y then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

    end;

   shag := shah;
   ht := y + shag;
   if (ht = 0)or(ht = n+1)
    then
     begin
      shag := -shag;
      ht := y + shag;
     end;
   tr := Rec(x,ht,shag,z+1);
   if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

   Rec := b[x,y,shah,z];
  end;
end;

 begin
  readln(n,m,kk);
  readln(s);

  i := 0;
  while not seekeof do
    begin
     read(q);
     i := i + 1;
     if q = '1' then a[i] := 1
     else a[i] := 0;
    end;
   f := i;
   if s = 'to tail' then off := 1
   else off := -1;
   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 0 to f do
       b[i,j,k,tr] := -1;

   max := -maxlongint;
   Rec(m,kk,off,1);

   if max = f then writeln('Stowaway')
   else writeln('Controller ',max);
 end.

const
    fi='';
    fo='';
var
    VtC,mv,n,luu:longint;
    State:string;
    xet,cungchieu:boolean;
    f:text;
procedure nhap;
var m,k:longint;St:string;
begin
    assign(f,fi);
    reset(F);
    readln(f,n,m,k);
    readln(f,St);
    readln(f,State);
    if St='to head' then mv:=-1
    else mv:=1;
    if mv*(m-k)>0 then cungchieu:=true
    else cungchieu:=false;
    VtC:=k;
    close(f);
end;
procedure xuat;
begin
    assign(f,fo);
    rewrite(f);
    if xet then writeln(f,'Stowaway')
    else
     begin
        write(f,'Controller ');
        writeln(f,luu);
     end;
    close(f);
end;
procedure process;
var cuoi,i,reach1,p,j,S1:longint;
begin
    i:=1;
    reach1:=0;
    while i<=length(State) do
     begin
        if State[i]='1' then cungchieu:=false;
                for j:=i+1 to length(State) do
                    if State[j]='1' then
                     begin
                        reach1:=j-i;
                        break;
                     end;
        if mv=1 then cuoi:=n
        else cuoi:=1;
        if not cungchieu then S1:=n+abs(cuoi-vtC)-1
        else S1:=abs(cuoi-vtC);
        if State[i]='0' then
         begin
            if S1<reach1 then
             begin
                i:=i+S1-1;
                break;
             end
            else
             begin
                cungchieu:=false;
                p:=i;
                for i:=p+1 to p+reach1 do
                 begin
                    if (VtC=n) or (VtC=1) then mv:=mv*(-1);
                    VtC:=VtC+mv;
                 end;
             end;
         end;
        inc(i);
        if (VtC=n) or (VtC=1) then mv:=mv*(-1);
        VtC:=VtC+mv;
     end;
    if i=length(State)+1 then xet:=true
    else
     begin
        xet:=false;
        luu:=i;
     end;
end;
begin
    nhap;
    process;
    xuat;
end.

Var n,i,j,k,l,m,t,r:longint;
s:string;
Begin
Readln(N,M,k);
Readln(s);
if s='to head' then
  r:=1
else
  r:=0;
s:='';
Readln(s);
For i:=1 to length(s) do begin
  if s[i]='0' then begin
    if M<k then begin
      if M>1 then
        dec(M);
    end
    else begin
      if M<N then
        inc(M);
    end;
  end;
  if r=1 then
    dec(k)
  else
    inc(k);
  if k=1 then
    r:=0;
  if k=N then
    r:=1;
  if s[i]='1' then begin
    if r=1 then begin
      if M=N then
        k:=1
      else
        k:=N;
    end
    else begin
      if M=1 then
        k:=N
      else
        k:=1;
    end;
  end;
  if k=M then begin
    writeln('Controller ',i);
    halt(0);
  end;
end;
writeln('Stowaway');
end.

var n,m,k,i,napr:longint;
    s:String;
    a:array[0..51] of longint;

procedure fun1;
begin
 if (Napr=1) and (m+1=k) then begin
                               if m=1 then begin writeln('Controller ',i); halt; end;
                               dec(m);
                               dec(k);
                              end else
 if (napr=1) then begin
                   dec(k);
                   if k=0 then begin
                                k:=2; napr:=3-napr;
                               end;
                  end else
 if (napr=2) and (m=k+1) then begin
                               if m=n then begin writeln('Controller ',i); halt; end;
                               inc(m);
                               inc(k);
                              end else
  if (napr=2) then begin
                   inc(k);
                   if k=n+1 then begin
                                k:=n-1; napr:=3-napr;
                               end;
                  end;
end;

procedure fun2;
begin
 if napr=2 then m:=1 else m:=n;
 if napr=1 then begin
                 k:=k-1;
                 if k=0 then begin
                              napr:=2;
                              k:=2;
                             end;
                end else
 if (napr=2) then begin
                   inc(k);
                   if k=n+1 then begin
                                k:=n-1; napr:=3-napr;
                               end;
                  end;

end;

begin
readln(n,m,k);
readln(s);
if s='to head' then napr:=1 else napr:=2;
readln(S);
for i:= 1 to length(s) do
 begin
  if s[i]='0' then fun1 else fun2;
 end;
 writeln('Stowaway');
end.

Var e,n,m,k,i:LongInt;
s:string;
begin
//  Assign(input,'input.txt');
  //Assign(output,'output.txt');
  Readln(n,m,k);
  readln(s);
  if s[4]='h'
  then e:=-1
  else e:=1;
  Readln(s);
  for i:=1 to Length(s) do
  begin
    if s[i]='1'
    then begin
          if e=1
          then m:=1
          else m:=n;
          if ((k=1)and(e=-1))or((k=n)and(e=1))
          then e:=e*(-1);
          k:=k+e;
         end
    else begin
          if (m<>1)and(m<>n)
          then begin
                  if e=1
                  then begin
                         if m>k
                         then m:=n
                         else m:=1;
                       end
                  else begin
                         if m<k
                         then m:=1
                         else m:=n;
                       end;
                 end;
                  if ((k=1)and(e=-1))or((k=n)and(e=1))
                  then e:=e*(-1);
                  k:=k+e;
                  if k=m
                  then begin writeln('Controller ',i); halt(0); end;

         end;
  end;
  Writeln('Stowaway');
end.

var
a,s1:string;
i,j,k,l,n,m:longint;
begin
readln(n,m,k);
readln(s1);
read(a);
for i:=1 to length(a) do
 begin
  if (a[i]='1') and (i=length(a)) then
   begin
    write('Stawaway');
    exit;
   end;
  if ((m=1) and (k=2) and (a[i]='0')) or ((m=n) and (k=n-1) and (a[i]='0')) then
   begin
    write('Controller ',i);
    exit;
   end;
  if m<k then m:=1;
  if m>k then m:=n;
  if (a[i]='1') and ((k=1) or (s1='to head')) then m:=n;
  if (a[i]='1') and ((k=n) or (s1='to tail')) then m:=1;
  if (s1='to head') and (k=1) then s1:='to tail';
  if (s1='ta tail') and (k=n) then s1:='to head';
  if s1='to tail' then inc(k)
   else dec(k);
 end;
end.

var
  o,n,x,y,i,m:longint;
  s:ansistring;

begin
  readln(n,x,y);
  readln(s);
  if (s[4]='h')then o:=1 else o:=2;
  readln(s);
  m:=length(s);
  for i:=1 to m-1 do begin
    if (s[i]='0')then begin
      if (x=1)then inc(x)else
      if (x=n)then dec(x)else
      if (abs(x-1-y)>abs(x+1-y))then dec(x)else
      inc(x);
      if (x=y)then begin writeln('Controller ',i);exit;end;
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end else begin
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (y=n)then x:=1 else
      if (y=1)then x:=n else
      if (o=1)then x:=n else
      x:=1;
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end;
  end;
  writeln('Stowaway');
end.

var
  o,n,x,y,i,m:longint;
  s:ansistring;

begin
  readln(n,x,y);
  readln(s);
  if (s[4]='h')then o:=1 else o:=2;
  readln(s);
  m:=length(s);
  for i:=1 to m-1 do begin
    if (s[i]='0')then begin
      if (x=1)then inc(x)else
      if (x=n)then dec(x)else
      if (abs(x-1-y)>abs(x+1-y))then dec(x)else
      inc(x);
      if (x=y)then begin writeln('Controller ',i);exit;end;
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end else begin
      if (y=1)and(o=1)then o:=2;
      if (y=n)and(o=2)then o:=1;
      if (o=1)then dec(y)else inc(y);
      if (y=n)then x:=1 else
      if (y=1)then x:=n else
      if (o=1)then begin
        x:=n;
        if (s[i+1]='0')and(y=n-1)then x:=1;
      end else begin
        x:=1;
        if (s[i+1]='0')and(y=2)then x:=n;
      end;
      if (x=y)then begin writeln('Controller ',i);exit;end;
    end;
  end;
  writeln('Stowaway');
end.

var
b:array[1..10000] of char;
n,m,i,k,l,j,p:longint;
s:string;
begin
readln(n,m,k);
readln(s);
if s='to tail' then p:=1 else p:=0;
i:=0;
while not eoln do
 begin
  inc(i);
  read(b[i]);
 end;
if p=0 then l:=1
else l:=n;
for j:=1 to i do
 begin
  if b[j]='0' then
   if p=0 then
     dec(k) else inc(k) else
  if p=0 then l:=n else l:=1;
  if k=l then begin write('Controller',' ',j); exit;end;
 end;
write('Stowaway');
end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if ((k-m<m-k)and(m<n))and(m+1<>k) then inc(m) else if (m>1)and(m-1<>k) then dec(m);
  if s[i]='1' then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  inc(k,h);
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var cm,n,i,k,m,r:integer;
s,t:string;
c:char;

begin
readln(n,m,k);
readln(s);
readln(t);
c:=s[4];

if (c='h') and (m>k) then m:=n
else
if (c='h') and (m<k) then m:=1
else
if (c='t') and (m<k) then m:=1
else
m:=n;

for I := 1 to length(t) do
begin
    if c='h' then begin k:=k-1; if k=1 then c:='t' end
    else
    begin k:=k+1; if k=n then c:='h' end;
  if t[i]='1' then
  begin
    if (c='h') and (m<>n) then m:=n
    else
    m:=1;
  end;
if k=m then begin write('Controller ',i); halt; end;
end;
write('Stowaway');
end.

{$apptype console}
{$R-,S+,I+,Q+}
const
     inf = 'input.txt';
     outf = 'output.txt';
var
 n,m,k,i,len:longint;
 s,t:string;
begin
 //reset(input,inf);
 //rewrite(output,outf);
 readln(n,m,k);
 readln(s);
 readln(t);
 len:=length(t);
 for i:=1 to len do
  begin
   if t[i] = '1' then
    begin
     if s[4] = 'h' then
      begin
       if k = 1 then
        begin
         s[4]:='t';
         inc(k);
        end else dec(k);
       m:=n;
      end else
      begin
       if k = n then
        begin
         s[4]:='h';
         dec(k);
        end else inc(k);
       m:=1;
      end;
     continue;
    end;
   if m > k then m:=n else m:=1;
   if s[4] = 'h' then
    begin
     if k = 1 then
      begin
       s[4]:='t';
       inc(k);
      end else dec(k);
    end else
    begin
     if k = n then
      begin
       s[4]:='h';
       dec(k);
      end else inc(k);
    end;
   if k = m then
    begin
     writeln('Controller ',i);
     exit;
    end;
  end;
 writeln('Stowaway');
end.

var
 n,m,k,y,i:longint;
 s:string;
 c:char;
begin
readln(n,m,k);
readln(s);
if s='to head' then y:=-1 else y:=1;
i:=0;
while not eoln do
 begin
  read(c);
  inc(i);
  if c='0' then
   begin
    if (m<>1)and(m<>n) then
     if k>m then m:=m-1 else m:=m+1;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if k=m then
     begin
      writeln('Controller ',i);
      halt;
     end;
   end else
  if c='1' then
   begin
    m:=0;
    if k=1 then y:=1 else
    if k=n then y:=-1;
    k:=k+y;
    if n-k>k-1 then m:=n else m:=1;
   end;
 end;
writeln('Stowaway');
end.

var
a,s1:string;
i,j,k,l,n,m:longint;
begin
readln(n,m,k);
readln(s1);
read(a);
for i:=1 to length(a) do
 begin
  if k=1 then s1:='to tail';
  if k=n then s1:='to head';
  if (a[i]='1') and (i=length(a)) then
   begin
    write('Stawaway');
    exit;
   end;
  if ((m=1) and (k=2) and (a[i]='0') and (s1='to head')) or ((m=n) and (k=n-1) and (a[i]='0') and (s1='to tail')) then
   begin
    write('Controller ',i);
    exit;
   end;
  if m<k then m:=1;
  if m>k then m:=n;
  if (a[i]='1') and (s1='to head') then m:=n;
  if (a[i]='1') and (s1='to tail') then m:=1;
  if s1='to tail' then inc(k)
   else dec(k);
 end;
end.

var n,x,y,g,max,t,i,j:longint;
    s:string;

procedure tt(x:longint);
var k:longint;
 begin
  k:=0;
  if g>0 then begin
               if x>=y then k:=x-y
                       else k:=2*n-x-y;
              end
         else begin
               if x<=y then k:=y-x
                       else k:=y-1+x-1;
              end;
  if k>max then begin
                 max:=k;
                 t:=x;
                end;
 end;

 begin
  readln(n,x,y);
  readln(s);
  if s[length(s)]='d' then g:=-1
                      else g:=1;
  readln(s);
  for i:=1 to length(s) do
   begin
    if (y=1) then g:=1;
    if (y=n) then g:=-1;
    max:=-1;
    t:=x;
    if s[i]='0' then begin
                      y:=y+g;

                      if (x-1>=1) and (x-1<>y-g) then tt(x-1);
                      if (x+1<=n) and (x+1<>y-g) then tt(x+1);
                      tt(x);

                      x:=t;

                      if x=y-g then begin
                                     writeln('Controller ',i);
                                     halt;
                                    end;
                     end
                else begin
                      y:=y+g;

                      for j:=1 to n do
                       if j<>y-g then tt(j);

                      x:=t;

                      if x=y-g then begin
                                     writeln('Controller ',i);
                                     halt;
                                    end;
                     end;
    if x=y then begin
                 writeln('Controller ',i);
                 halt;
                end;
   end;
  writeln('Stowaway');
 end.

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=m then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if f then begin
    if s[i]='1' then begin
      if (k>=n div 2) and (k>2) then m:=1 else m:=n;
    end else begin
      if m-k>=0 then begin
        if (m-k>1) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end;
    end;
  end else begin
    if s[i]='1' then begin
      if (k>=n div 2) and (k<n-1) then m:=n else m:=1;
    end else begin
      if k-m>=0 then begin
        if (k-m>1) and (m<n) then inc(m) else
        if abs(m-k)<1 then dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else
        if abs(m-k)<1 then inc(m);
      end;
    end;
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

var
 n,m,k,i,pp,posk,poss:longint;
 f:boolean;
 s,s1:ansistring;

begin
 readln(n,m,k);
 readln(s);
 if s='to head' then f:=true;
 posk:=k;
 poss:=m;
 readln(s1);
 pp:=length(s1);

 for i:=1 to pp do if s1[i]='0' then
 begin
  if f then
  begin
   if (poss<1) then dec(poss);
   if (posk>1) then dec(posk);
   if posk=1 then f:=false;
  end else
  begin
   if (poss<n) then inc(poss);
   if (posk<n) then inc(posk);
   if posk=n then f:=true;
  end;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end else
 begin
  if f then
  begin
   if (posk<n) then inc(posk);
   if posk=n then f:=true;
  end else
  begin
   poss:=m;
   if (posk>1) then dec(posk);
   if posk=1 then  f:=false;
  end;
  if f then if posk<n then poss:=n else posk:=n-1;
  if not f then if posk>1 then posk:=1 else posk:=2;
  if poss=posk then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

{$APPTYPE CONSOLE}

{$R+,S+,Q+,I+,C+,M+,H+,O-}
{$M 67108864}
uses SysUtils,math;
var i,n,m,k,ls,r:longint; s:string; f:boolean;
begin
{$IFNDEF ONLINE_JUDGE}
reset(input,'input.txt');
rewrite(output,'output.txt');
{$ENDIF}
readln(n,m,k);
readln(s);
delete(s,1,pos(' ',s));
f:=false;
if s='tail' then f:=true;
readln(s);
ls:=length(s);
r:=-1;
if k=m then r:=0 else begin
for i:=1 to ls do begin
  if f then begin
    if k=n then begin
      dec(k);
      f:=false;
    end else inc(k);
  end else begin
    if k=1 then begin
      inc(k);
      f:=true;
    end else dec(k);
  end;
  if f then begin
    if s[i]='1' then begin
      if k>n div 2 then m:=1 else m:=n;
    end else begin
      if m-k>0 then begin
        if (m-k>1) and (m>1) then dec(m) else
        if abs(m-k)<2 then inc(m);
      end else begin
        if (k-m>0) and (m<n) then inc(m) else
        if abs(m-k)<2 then dec(m);
      end;
    end;
  end else begin
    if s[i]='1' then begin
      if k>n div 2 then m:=n else m:=1;
    end else begin
      if k-m>0 then begin
        if (k-m>1) and (m<n) then inc(m) else
        if abs(m-k)<2 then dec(m);
      end else begin
        if (m-k>0) and (m>1) then dec(m) else
        if abs(m-k)<2 then inc(m);
      end;
    end;
  end;
  if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin
    r:=i;
    break;
  end;
end;
end;
if r=-1 then write('Stowaway') else write('Controller ',r);
end.

//writeln(FormatDateTime('hh:mm:ss.zzz', now));

var
max,f,n,m,i,j,k,off,tr: longint;
tt : longint;
s : String;
q : char;
a : Array[0..1000]of longint;
b : Array[0..70,0..70,-5..5,0..201]of longint;
function rec(x,y,shag,z : longint) : longint;
var i,tr,h,ht,shah: Longint;
begin
 if z > max then max := z;
 if z = f then
  begin
   b[x,y,shag,z] := maxlongint;
   exit(maxlongint);

  end;
 if x = y then
  begin
   b[x,y,shag,z] := z - 1;
   exit(b[x,y,shag,z]);
  end;
 if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);

 b[x,y,shag,z] := z;
 if a[z] = 1 then
  begin
   shah := shag;
    h := y + shag;
      if (h = 0)or(h = n + 1) then
       begin
        shag := -shag;
        h := y + shag;
       end;

   For i := 1 to n do
     begin
      if i = h then tr := z
      else
      tr := Rec(i,h,shag,z+1);
      if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;
     end;
    rec := b[x,y,shah,z];
  end
 else
  begin
    shah := shag;
    h := x + 1;
    if h <= n then
     begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if h = y then tr := z
      else if ht = h then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];
     end;

   h := x - 1;
   shag := shah;
   if h > 0 then
    begin
      ht := y + shag;
      if (ht = 0)or(ht = n + 1) then
       begin
        shag := -shag;
        ht := y + shag;
       end;
      if h = y then tr := z
      else if h = ht then tr := z
      else
      tr := Rec(h,ht,shag,z+1);
      if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];

    end;

   shag := shah;
   ht := y + shag;
   if (ht = 0)or(ht = n+1)
    then
     begin
      shag := -shag;
      ht := y + shag;
     end;
   if ht = x then tr := z
   else
   tr := Rec(x,ht,shag,z+1);
   if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;

   Rec := b[x,y,shah,z];
  end;
end;

 begin
  readln(n,m,k);
  readln(s);
  i := 0;
  while not seekeof do
    begin
     read(q);
     i := i + 1;
     if q = '1' then a[i] := 1
     else a[i] := 0;
    end;
   f := i;
   if s = 'to tail' then off := 1
   else off := -1;
   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 0 to f do
       b[i,j,k,tr] := -1;

   max := -maxlongint;
   Rec(m,k,off,1);

   for i := 1 to n do
    for j := 1 to n do
     for k := -1 to 1 do
      for tr := 1 to f do
       if b[i][j][k][tr] <>-1 then
        begin
         if tr > max then max := tr;
        end;

   if max = f then writeln('Stowaway')
   else writeln('Controller ',max
  );
 end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  f:=false;
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if ((k-m<m-k)and(m<n))and(m+1<>k) then inc(m) else if (m>1)and(m-1<>k) then dec(m);
  if s[i]='1' then
  begin
   f:=true;
   m:=0;
  end;
  inc(k,h);
  if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

var n,m,k,min,i,t:integer;
    s,time:string;
    controller: boolean;
begin
Read(n);
Read(m);
Readln(k);
Readln(s);
readln(time);
If (s='to head') then t:=-1 else t:=1;
For i:=1 to length(time)-1 do begin
If time[i]='0' then
    if ((t=-1) and (k>m)) or ((t=1) and (k<m)) then begin
                    If (m<>1) and (m<>n) then m:=m+t;
                    k:=k+t;
                    If (k=1) or (k=n) then t:=t*(-1)
                    end
    else if ((t=-1) and (k<m)) or ((t=1) and (k>m)) then begin
        If (m<>1) and (m<>n) then m:=m-t;
                    k:=k+t;
                    If (k=1) or (k=n) then t:=t*(-1)
                    end
else if time[i]='1' then begin
    k:=k+t;
    If (k=1) or (k=n) then t:=t*(-1);
    if ((t=-1) and (k<>n)) then m:=n else if ((t=1) and (k<>1)) then m:=1
    else if ((t=-1) and (k=n)) then m:=1 else if ((t=1) and (k=1)) then m:=n
    end;
If m=k then begin controller:=true; min:=i;break end
end;
    If controller then write('Controller ',min) else writeln('Stowaway')
end.

var
 x,z,n,m,i,j,k,h : longint;
 s,ss,p,t : string;
 q : integer;
 f : boolean;
begin
 readln(n,m,k);
 readln(p);
 if pos('head',p)>0 then h:=-1 else h:=1;
 readln(s);
 x:=length(s);
 for i:=1 to x do
 begin
  f:=false;
  if (i=x)and(s[x]='1') then
  begin
   writeln('Stowaway');
   halt;
  end;
  if k=1 then h:=1 else if k=n then h:=-1;
  if s[i]='0' then if ((k-m<=m-k)and(m<n))and(m+1<>k) then inc(m) else if (m>1)and(m-1<>k) then dec(m);
  if s[i]='1' then
  begin
   f:=true;
   m:=0;
  end;
  inc(k,h);
  if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else
  if k=1 then m:=n else if k=n then m:=1;
  if k=m then
  begin
   writeln('Controller ',i);
   halt;
  end;
 end;
 writeln('Stowaway');
end.

var
   i,j,n,m,k,p:longint;
   napr,t:string;

BEGIN
readln(n,m,k);
readln(napr);
if (napr='to head') then p:=-1 else p:=1;
readln(t);
for i:=1 to length(t) do
    begin
    {Zayac}
    if (t[i]='0') then
        begin
        if (p=-1)and(m>k)and(m+1<=n) then inc(m);
        if (p=-1)and(m<k)and(m>=2) then dec(m);
        if (p=1)and(m>k)and(m+1<=n) then inc(m);
        if (p=1)and(m<k)and(m>=2) then dec(m);
        end
    else
        begin
        if (p=-1)and(k<>n) then m:=n;
        if (p=-1)and(k=n) then m:=1;
        if (p=1)and(k<>1) then m:=1;
        if (p=1)and(k=1) then m:=n;
        end;
    {Controller}
    if (k+p>=1)and(k+p<=n) then k:=k+p
    else
        begin
        p:=-p;
        k:=k+p;
        end;
    {End game?}
    if (m=k) then
        begin
        writeln('Controller ',i);
        halt;
        end;
    end;
writeln('Stowaway');
END.