A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle. Every minute the players move.The controller's move is as follows. The controller has the movement direction — to the train's head or to its tail. During a move the controller moves to the neighbouring wagon correspondingly to its movement direction. If at the end of his move the controller enters the 1-st or the n-th wagon, that he changes the direction of his movement into the other one. In other words, the controller cyclically goes from the train's head to its tail and back again during all the time of a game, shifting during each move by one wagon. Note, that the controller always have exactly one possible move.The stowaway's move depends from the state of the train. If the train is moving, then the stowaway can shift to one of neighbouring wagons or he can stay where he is without moving. If the train is at a station and is idle, then the stowaway leaves the train (i.e. he is now not present in any train wagon) and then, if it is not the terminal train station, he enters the train again into any of n wagons (not necessarily into the one he's just left and not necessarily into the neighbouring one). If the train is idle for several minutes then each such minute the stowaway leaves the train and enters it back.Let's determine the order of the players' moves. If at the given minute the train is moving, then first the stowaway moves and then the controller does. If at this minute the train is idle, then first the stowaway leaves the train, then the controller moves and then the stowaway enters the train.If at some point in time the stowaway and the controller happen to be in one wagon, then the controller wins: he makes the stowaway pay fine. If after a while the stowaway reaches the terminal train station, then the stowaway wins: he simply leaves the station during his move and never returns there again.At any moment of time the players know each other's positions. The players play in the optimal way. Specifically, if the controller wins, then the stowaway plays so as to lose as late as possible. As all the possible moves for the controller are determined uniquely, then he is considered to play optimally always. Determine the winner.

The first line contains three integers n, m and k. They represent the number of wagons in the train, the stowaway's and the controller's initial positions correspondingly (2 ≤ n ≤ 50, 1 ≤ m, k ≤ n, m ≠ k). The second line contains the direction in which a controller moves. "to head" means that the controller moves to the train's head and "to tail" means that the controller moves to its tail. It is guaranteed that in the direction in which the controller is moving, there is at least one wagon. Wagon 1 is the head, and wagon n is the tail. The third line has the length from 1 to 200 and consists of symbols "0" and "1". The i-th symbol contains information about the train's state at the i-th minute of time. "0" means that in this very minute the train moves and "1" means that the train in this very minute stands idle. The last symbol of the third line is always "1" — that's the terminal train station.

If the stowaway wins, print "Stowaway" without quotes. Otherwise, print "Controller" again without quotes, then, separated by a space, print the number of a minute, at which the stowaway will be caught.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    public class Train
    {
        public static void Main(string[] args)
        {
            var tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(x => int.Parse(x));
            var n = tokens[0];
            var m = tokens[1];
            var k = tokens[2];
            var dir = Console.ReadLine();
            var d = dir == "to head" ? -1 : 1;
            var state = Console.ReadLine();
            var time = 0;
            var caught = false;
            for (int i = 0; i < state.Length - 1; i++)
            {
                if (state[i] == '0')
                {
                    if (m + d > 0 && m + d <= n)
                    {
                        m += d;
                    }
                    k += d;
                    if (k == 1 || k == n)
                    {
                        d = -d;
                    }
                    if (m == k)
                    {
                        caught = true;
                        time = i + 1;
                        break;
                    }
                }
                else
                {
                    m = d == -1 ? n : 1;
                    k += d;
                    if (k == 1 || k == n)
                    {
                        d = -d;
                    }
                }
            }
            if (caught)
            {
                Console.WriteLine("Controller " + time);
            }
            else
            {
                Console.WriteLine("Stowaway");
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int L, S, C;
            L = Convert.ToInt32(data[0]);
            S = Convert.ToInt32(data[1]);
            C = Convert.ToInt32(data[2]);
            int dir = Console.ReadLine().Trim() == "to head" ? -1 : 1;
            string code = Console.ReadLine().Trim();

            if (S == C && code[0]!='1')
            {
                Console.WriteLine("Controller {0}", C);
                return;
            }
            for (int i = 0; i < code.Length; i++)
            {
                if (code[i] == '1')
                {
                    S = C;
                }

                if (code[i] == '0')
                {
                    if (S > C && S != L)
                    {
                        S++;
                    }
                    else if (S < C && S != 1)
                    {
                        S--;
                    }

                }
                if (C == 1 && dir == -1) dir = 1;
                if (C == L && dir == 1) dir = -1;
                C = C + dir;
                if (S == C)
                {
                    Console.WriteLine("Controller {0}", i+1);
                    return;
                }

            }
            Console.WriteLine("Stowaway");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            int k = int.Parse(input[2]);
            int r;
            if (Console.ReadLine().Equals("to head"))
                r = -1;
            else
                r = 1;
            string time = Console.ReadLine();
            for (int i = 0; i < time.Length; i++)
            {
                if (k == n || k == 1)
                {
                    if (k == 1)
                    {
                        if (r == -1)
                            r = (-1) * r;
                    }
                    else
                    {
                        if (r == 1)
                            r = (-1) * r;
                    }
                }
                if (time[i].Equals('0'))
                {
                    if (Math.Abs(m - k) > 1)
                        k += r;
                    else
                    {
                        if (m == k)
                        {
                            Console.WriteLine("Controller" + " " + (i + 1).ToString());
                            return;
                        }
                        else
                        {
                            if (m == 1 || m == n)
                            {
                                k += r;
                                if (m == k)
                                {
                                    Console.WriteLine("Controller" + " " + (i + 1).ToString());
                                    return;
                                }
                            }
                            else
                            {
                                m += r;
                                k += r;
                            }
                        }
                    }
                }
                else
                {
                    k += r;
                    if (r == 1)
                        m = 1;
                    else
                        m = n;
                }
            }
            Console.WriteLine("Stowaway");
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(tmp[0]);
            int zayc = int.Parse(tmp[1]);
            int controller = int.Parse(tmp[2]);
            int minut = -5;
            string naprav = Console.ReadLine();
            int znak = 0;
            if (naprav == "to head")
            {
                znak = -1;
            }
            else
            {
                znak = 1;
            }

            string mask = Console.ReadLine();
            bool win = true;

            for (int i = 0; i < mask.Length; i++)
            {
                if ((controller == 1) && (znak == -1))
                {
                    znak = -znak;
                }
                if ((controller == n) && (znak == 1))
                {
                    znak = -znak;
                }
                if (mask[i] == '0')
                {
                    if (zayc == 1 || zayc == n)
                    {

                    }
                    else
                    {
                        if (zayc < controller)
                            zayc--;
                        else
                            zayc++;
                    }
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                        break;
                    }

                }
                else
                {
                    controller += znak;
                    if (znak == 1)
                    {
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if(controller !=1)
                            if(controller !=n)
                        {
                            zayc = 1;
                        }
                    }
                    else
                    {
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller != 1)
                            if (controller != n)
                        {
                            zayc = n;
                        }
                    }
                }

            }

            if (win)
            {
                Console.WriteLine("Stowaway");
            }
            else
            {
                Console.WriteLine("Controller " + minut);
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest_74
{
    class Program
    {
        static void A()
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<string, int> p = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');
                p.Add(t[0], int.Parse(t[1]) * 100 - int.Parse(t[2]) * 50 + int.Parse(t[3]) + int.Parse(t[4]) + int.Parse(t[5]) + int.Parse(t[6]) + int.Parse(t[7]));
            }

            int max = int.MinValue;
            string name = "";
            foreach (var e in p)
            {
                if (e.Value > max)
                {
                    max = e.Value;
                    name = e.Key;
                }
            }

            Console.WriteLine(name);
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int a = int.Parse(t[1]);
            int b = int.Parse(t[2]);
            string dir = Console.ReadLine();
            int d = 1;
            if (dir.IndexOf("tail") == -1)
                d = -1;
            string s = Console.ReadLine();
            int l = s.Length;
            for (int i = 0; i < l; i++)
            {

                if ((b + d  > n) || (b +d < 1))
                    d *= -1;
                b += d;
                switch (s[i])
                {
                    case '0':
                        if ((a + d <= n) && (a + d > 0))
                            a += d;
                        break;
                    case '1':
                        a = (b - d);
                        break;
                }
                if (a == b)
                {
                    Console.WriteLine("Controller " + (i+1));
                    return;
                }
            }
            Console.WriteLine("Stowaway");
        }

        static void Main(string[] args)
        {
            B();
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            toS = Console.ReadLine().Trim();
            s = Console.ReadLine().Trim();
#endif
            kn = toS[3] == 'h' ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i+1==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n && kn>0) kn = -1;
                if (k == 1 && kn<0) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

using System;

class B
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var k = int.Parse(line[2]);

        var kto = (Console.ReadLine() == "to head") ? -1 : 1;
        var stat = Console.ReadLine();

        for (var i = 0; i < stat.Length; i++)
        {
            if (stat[i] == '1') m = 0;
            else if (m == k + kto)
                if ((m > 1) && (m < k)) m--;
                else if ((m < n) && (m > k)) m++;

            k += kto;
            if (k == 1) kto = 1;
            else if (k == n) kto = -1;

            if (m == k)
            {
                Console.WriteLine("Controller " + (i + 1));
                return;
            }

            if (stat[i] == '1') if ((k > 1) && ((kto == 1) || (k == n))) m = 1; else m = n;
        }

        Console.WriteLine("Stowaway");
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round68
{
    class B
    {
        public static void Main()
        {
            var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
            int n = xs[0],
                m = xs[1],
                k = xs[2];
            int dx = Console.ReadLine() == "to head" ? -1 : 1;
            var s = Console.ReadLine();

            for (int i = 0; i < s.Length; i++)
            {
                if (!(1 <= k + dx && k + dx <= n))
                    dx = -dx;
                k += dx;
                if (s[i] == '1')
                {
                    m = k - dx;
                }
                else
                {
                    if (1 <= m + dx && m + dx <= n)
                        m += dx;
                    if (k == m)
                    {
                        Console.WriteLine("Controller {0}", i + 1);
                        return;
                    }
                }
            }
            Console.WriteLine("Stowaway");
        }
    }
}

using System;

namespace CodeForces
{
    class _74b
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var split = line.Split(new[] { ' ' });
            var n = int.Parse(split[0]);
            var m = int.Parse(split[1]);
            var k = int.Parse(split[2]);
            line = Console.ReadLine();
            var dir = line.Contains("tail") ? 1 : -1;
            line = Console.ReadLine();
            for (var i = 0; i < line.Length; i++)
            {
                if (k == 1 && dir == -1)
                {
                    dir = 1;
                    k = 2;
                }
                else if (k == n && dir == 1)
                {
                    dir = -1;
                    k = n - 1;
                }
                else
                {
                    k += dir;
                }
                if (line[i] == '0')
                {
                    if (m != n && m != 1)
                    {
                        m += dir;
                    }
                    if (k == m)
                    {
                        Console.WriteLine("Controller {0}", i + 1);
                        return;
                    }
                }
                else
                {
                    if (dir == -1)
                    {
                        if (k == n)
                        {
                            m = 1;
                        }
                        else
                        {
                            m = n;
                        }
                    }
                    else
                    {
                        if (k == 1)
                        {
                            m = n;
                        }
                        else
                        {
                            m = 1;
                        }
                    }
                }
            }
            Console.WriteLine("Stowaway");
        }
    }
}

using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

class Program
{
  static void Main(string[] args)
  {
    int[] a = GetInts();
    int n = a[0], m = a[1], k = a[2];

    bool toHead = GetStr().Equals("to head");
    string s = GetStr();

    int min = -1;

    for (int i = 0; i < s.Length; i++)
    {
      if (toHead)
      {
        k -= 1;
        if (k == 0)
        {
          k = 2;
          toHead = false;
        }
      }
      else
      {
        k += 1;
        if (k > n)
        {
          k = n - 1;
          toHead = true;
        }
      }

      if (s[i] == '1') // stop
      {
        if (toHead)
          m = k + 1;
        else
          m = k - 1;
      }
      else if (m == k)
      {
        if (!toHead)
          m += 1;
        else
          m -= 1;
        if (m < 1 || m > n)
        {
          min = i + 1;
          break;
        }
      }
    }

    if (min == -1)
      WL("Stowaway");
    else
      WL("Controller " + min);

#if !ONLINE_JUDGE
    Console.ReadLine();
#endif
  }

  static int GetInt()
  {
    return int.Parse(GetStr());
  }

  static int GetInt(string s)
  {
    return int.Parse(s);
  }

  static int[] GetInts()
  {
    string[] ss = GetStrs();
    int[] nums = new int[ss.Length];

    int i = 0;
    foreach (string s in ss)
      nums[i++] = GetInt(s);

    return nums;
  }

  static string[] GetStrs()
  {
    return Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
  }

  static long GetLong()
  {
    return long.Parse(GetStr());
  }

  static string GetStr()
  {
    return Console.ReadLine();
  }

  static void WL<T>(T s)
  {
    Console.WriteLine(s);
  }

  static void W<T>(T s)
  {
    Console.Write(s);
  }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]) - 1; // rabbit
            int k = int.Parse(line[2]) - 1;
            int dir = Console.ReadLine() == "to tail" ? 1 : -1;
            string s = Console.ReadLine();

            if (k == 0)
                dir = 1;
            if (k == n - 1)
                dir = -1;

            bool rabbitbefore = m < k;
            bool caught = false;
            int time = 0;
            for (; time < s.Length; time++)
            {
                k += dir;

                if (s[time] == '1')
                {
                    rabbitbefore = (dir == 1);
                }
                else
                {
                    if (k == 0 && rabbitbefore || k == n - 1 && !rabbitbefore)
                    {
                        caught = true;
                        break;
                    }
                }

                if (k == 0 || k == n - 1)
                    dir = -dir;
            }

            if(caught)
                Console.WriteLine("Controller {0}", time + 1);
            else
                Console.WriteLine("Stowaway");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

class Solver
{
    //  test
    static CodeforcesUtils CF = new CodeforcesUtils( new[]{

@"
5 3 2
to head
0001001
"
,
@"
3 2 1
to tail
0001
"
    });

    public void Solve()
    {
        var ss = CF.ReadLine().Split(' ');
        int n = int.Parse(ss[0]);
        int m = int.Parse(ss[1]);
        int k = int.Parse(ss[2]);

        int dir = 1;
        if( CF.ReadLine() == "to head" )
            dir = -1;

        var s = CF.ReadLine();
        for (int i = 0; i < s.Length; i++)
        {
            if (i == s.Length - 1)
            {
                CF.WriteLine("Stowaway");
                return;
            }

            k += dir;
            if (k < 1)
            {
                k = 2;
                dir = +1;
            }
            if (k > n)
            {
                k = n - 1;
                dir = -1;
            }

            if (s[i] == '1')
            {
                if (dir == 1)
                    m = 1;
                else
                    m = n;
            }
            else
            {
                if (m == k)
                {
                    if (m == 1 || m == n)
                    {
                        CF.WriteLine("Controller " + (i + 1));
                        return;
                    }
                    m += dir;
                }
            }
        }

    }

    #region test

    static void Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ru-RU");

#if DEBUG
        for (int t=0;t<CF.TestCount;t++ )
        {
            CF.Test(t);
            new Solver().Solve();
        }
#else
        new Solver().Solve();
#endif
        CF.Close();
    }

    static void TLE()
    {
        for (; ; ) ;
    }

    class CodeforcesUtils
    {
        public void Test(int t)
        {
            _lines = new List<string>();
            string[] ss = _test_input[t].Replace("\n", "").Split('\r');
            for (int i = 0; i < ss.Length; i++)
            {
                if (
                    (i == 0 || i == ss.Length - 1) &&
                    ss[i].Length == 0
                    )
                    continue;

                _lines.Add(ss[i]);
            }
        }

        public int TestCount
        {
            get
            {
                return _test_input.Length;
            }
        }

        public string ReadLine()
        {
#if DEBUG
            string s = null;
            if (_lines.Count > 0)
            {
                s = _lines[0];
                _lines.RemoveAt(0);
            }
            return s;

#else
            //return _sr.ReadLine();
        return Console.In.ReadLine();
#endif
        }

        public void WriteLine(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine(o);
#else
            //_sw.WriteLine(o);
        Console.WriteLine(o);
#endif
        }

        public void Write(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.Write(o);
#else
                //_sw.Write(o);
        Console.Write(o);
#endif
        }

        string[] _test_input;

        List<string> _lines;

#if DEBUG
        public CodeforcesUtils(string[] test_input)
        {
            _test_input = test_input;
        }
#else

        public CodeforcesUtils(string[] dummy)
        {
            //_sr = new System.IO.StreamReader("input.txt");
            //_sw = new System.IO.StreamWriter("output.txt");
        }
#endif

        public void Close()
        {
            if( _sr!= null)
                _sr.Close();
            if( _sw != null)
                _sw.Close();
        }

        System.IO.StreamReader _sr=null;
        System.IO.StreamWriter _sw=null;

    }

    #endregion
}

using System;
using System.Text;
using System.Linq;

class Program
{
static void Main()
{
string s1 = Console.ReadLine();
int n = int.Parse(s1.Split(' ')[0]) - 1;
int win = -1;
int z0 = int.Parse(s1.Split(' ')[1]) - 1;
int c0 = int.Parse(s1.Split(' ')[2]) - 1;

string s2 = Console.ReadLine();

string s3 = Console.ReadLine();

for (int i=0; i<s3.Length; i++)
{
    if (s3[i] == '1')
    {
        z0 = -1;

        peremesh(n, ref c0, ref s2);

        if (s2 == "to tail")
            if (c0 != 0)
                z0 = 0;
            else
                z0 = n;
        else
            if (c0 != n)
                z0 = n;
            else
                z0 = 0;
    }
    else
    {
        if (z0 > c0)
        {
            if (z0 != n)
                z0++;
        }
        else
        {
            if (z0 != 0)
                z0--;
        }
    }

    if (s3[i] != '1')
        peremesh(n, ref c0, ref s2);

    if (c0 == z0)
    {
        Console.WriteLine("Controller {0}", (i+1).ToString());
        win = 1;
        break;
    }
}
if (win != 1)
Console.WriteLine("Stowaway");

Console.ReadKey();

}

static void peremesh(int n, ref int place, ref string dir)
{
if (dir == "to tail")
{
if (place < n)
place++;
else
{
dir = "to head";
place--;
}
}
else
if (place > 0)
place--;
else
{
dir = "to tail";
place++;
}
}
}

using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int L, S, C;
            L = Convert.ToInt32(data[0]);
            S = Convert.ToInt32(data[1]);
            C = Convert.ToInt32(data[2]);
            int dir = Console.ReadLine().Trim() == "to head" ? -1 : 1;
            string code = Console.ReadLine().Trim();

            if (S == C)
            {
                Console.WriteLine("Controller {0}", C);
                return;
            }
            for (int i = 0; i < code.Length; i++)
            {
                if (C == 1 && dir == -1) dir = 1;
                if (C == L && dir == 1) dir = -1;
                C = C + dir;
                if (S == C)
                {
                    Console.WriteLine("Controller {0}", C);
                    return;
                }
                if (code[i] == '0')
                {
                    if (S > C && S != L)
                    {
                        S++;
                    }
                    else if (S < C && S != 1)
                    {
                        S--;
                    }

                }
                else if (code[i]=='1')
                {
                    if (dir == -1)
                    {
                        S = C;

                    }
                    else if (dir == 1)
                    {
                        S = C;

                    }

                }
            }
            Console.WriteLine("Stowaway");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int L, S, C;
            L = Convert.ToInt32(data[0]);
            S = Convert.ToInt32(data[1]);
            C = Convert.ToInt32(data[2]);
            int dir = Console.ReadLine().Trim() == "to head" ? -1 : 1;
            string code = Console.ReadLine().Trim();

            for (int i = 0; i < code.Length; i++)
            {
                if (C == 1 && dir == -1) dir = 1;
                if (C == L && dir == 1) dir = -1;
                C = C + dir;
                if (S == C)
                {
                    Console.WriteLine("Controller {0}", C);
                    return;
                }
                if (code[i] == '0')
                {
                    if (S > C && S != L)
                    {
                        S++;
                    }
                    else if (S < C && S != 1)
                    {
                        S--;
                    }

                }
                else if (code[i]=='1')
                {
                    if (dir == -1)
                    {
                        S = C + 1;
                        if (C == 0)
                            S = L;
                    }
                    else if (dir == 1)
                    {
                        S = C - 1;
                        if (C == L)
                            S = 1;
                    }

                }
            }
            Console.WriteLine("Stowaway");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int L, S, C;
            L = Convert.ToInt32(data[0]);
            S = Convert.ToInt32(data[1]);
            C = Convert.ToInt32(data[2]);
            int dir = Console.ReadLine().Trim() == "to head" ? -1 : 1;
            string code = Console.ReadLine().Trim();

            if (S == C)
            {
                Console.WriteLine("Controller {0}", C);
                return;
            }
            for (int i = 0; i < code.Length; i++)
            {
                if (code[i] == '1')
                {
                    S = C;
                }
                if (C == 1 && dir == -1) dir = 1;
                if (C == L && dir == 1) dir = -1;
                C = C + dir;
                if (S == C)
                {
                    Console.WriteLine("Controller {0}", C);
                    return;
                }
                if (code[i] == '0')
                {
                    if (S > C && S != L)
                    {
                        S++;
                    }
                    else if (S < C && S != 1)
                    {
                        S--;
                    }

                }

            }
            Console.WriteLine("Stowaway");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int L, S, C;
            L = Convert.ToInt32(data[0]);
            S = Convert.ToInt32(data[1]);
            C = Convert.ToInt32(data[2]);
            int dir = Console.ReadLine().Trim() == "to head" ? -1 : 1;
            string code = Console.ReadLine().Trim();

            if (S == C && code[0]!='1')
            {
                Console.WriteLine("Controller {0}", C);
                return;
            }
            for (int i = 0; i < code.Length; i++)
            {
                if (code[i] == '1')
                {
                    S = C;
                }
                if (C == 1 && dir == -1) dir = 1;
                if (C == L && dir == 1) dir = -1;
                C = C + dir;
                if (S == C)
                {
                    Console.WriteLine("Controller {0}", C);
                    return;
                }
                if (code[i] == '0')
                {
                    if (S > C && S != L)
                    {
                        S++;
                    }
                    else if (S < C && S != 1)
                    {
                        S--;
                    }

                }

            }
            Console.WriteLine("Stowaway");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int L, S, C;
            L = Convert.ToInt32(data[0]);
            S = Convert.ToInt32(data[1]);
            C = Convert.ToInt32(data[2]);
            int dir = Console.ReadLine().Trim() == "to head" ? -1 : 1;
            string code = Console.ReadLine().Trim();

            if (S == C)
            {
                Console.WriteLine("Controller {0}", C);
                return;
            }
            for (int i = 0; i < code.Length; i++)
            {
                if (C == 1 && dir == -1) dir = 1;
                if (C == L && dir == 1) dir = -1;
                C = C + dir;
                if (S == C)
                {
                    Console.WriteLine("Controller {0}", C);
                    return;
                }
                if (code[i] == '0')
                {
                    if (S > C && S != L)
                    {
                        S++;
                    }
                    else if (S < C && S != 1)
                    {
                        S--;
                    }

                }
                else if (code[i]=='1')
                {
                    if (dir == -1)
                    {
                        S = C + 1;
                        if (C == 0)
                            S = L;
                    }
                    else if (dir == 1)
                    {
                        S = C - 1;
                        if (C == L)
                            S = 1;
                    }

                }
            }
            Console.WriteLine("Stowaway");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(tmp[0]);
            int zayc = int.Parse(tmp[1]);
            int controller = int.Parse(tmp[2]);
            int minut = -5;
            string naprav = Console.ReadLine();
            int znak = 0;
            if (naprav == "to head")
            {
                znak = -1;
            }
            else
            {
                znak = 1;
            }

            string mask = Console.ReadLine();
            bool win = true;

            for (int i = 0; i < mask.Length; i++)
            {

                if ((controller == 1) && (znak == -1))
                {
                    znak = -znak;
                }
                if ((controller == n) && (znak == 1))
                {
                    znak = -znak;
                }
                if (mask[i] == '0')
                {
                    if (zayc == 1 || zayc == n)
                    {

                    }
                    else
                    {
                        if (zayc < controller)
                            zayc--;
                        else
                            zayc++;
                    }
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }

                }
                else
                {
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }
                    if (znak == 1)
                    {
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        else
                        {
                            zayc = 1;
                        }
                    }
                    else
                    {
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        else
                        {
                            zayc = n;
                        }
                    }
                }

            }

            if (win)
            {
                Console.WriteLine("Stowaway");
            }
            else
            {
                Console.WriteLine("Controller " + minut);
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(tmp[0]);
            int zayc = int.Parse(tmp[1]);
            int controller = int.Parse(tmp[2]);
            int minut = -5;
            string naprav = Console.ReadLine();
            int znak = 0;
            if (naprav == "to head")
            {
                znak = -1;
            }
            else
            {
                znak = 1;
            }

            string mask = Console.ReadLine();
            bool win = true;

            for (int i = 0; i < mask.Length; i++)
            {

                if ((controller == 1) && (znak == -1))
                {
                    znak = -znak;
                }
                if ((controller == n) && (znak == 1))
                {
                    znak = -znak;
                }
                if (mask[i] == '0')
                {
                    if (zayc == 1 || zayc == n)
                    {

                    }
                    else
                    {
                        if (zayc < controller)
                            zayc--;
                        else
                            zayc++;
                    }
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }

                }
                else
                {
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }
                    if (znak == 1)
                    {
                        zayc = 0;
                    }
                    else
                    {
                        zayc = n;
                    }
                }

            }

            if (win)
            {
                Console.WriteLine("Stowaway");
            }
            else
            {
                Console.WriteLine("Controller " + minut);
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(tmp[0]);
            int zayc = int.Parse(tmp[1]);
            int controller = int.Parse(tmp[2]);
            int minut = -5;
            string naprav = Console.ReadLine();
            int znak = 0;
            if (naprav == "to head")
            {
                znak = -1;
            }
            else
            {
                znak = 1;
            }

            string mask = Console.ReadLine();
            bool win = true;

            for (int i = 0; i < mask.Length; i++)
            {

                if ((controller == 1) && (znak == -1))
                {
                    znak = -znak;
                }
                if ((controller == n) && (znak == 1))
                {
                    znak = -znak;
                }
                if (mask[i] == '0')
                {
                    if (zayc == 1 || zayc == n)
                    {

                    }
                    else
                    {
                        if (zayc < controller)
                            zayc--;
                        else
                            zayc++;
                    }
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }

                }
                else
                {
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }
                    if (znak == 1)
                    {
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if(controller !=1)
                            if(controller !=n)
                        {
                            zayc = 1;
                        }
                    }
                    else
                    {
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller != 1)
                            if (controller != n)
                        {
                            zayc = n;
                        }
                    }
                }

            }

            if (win)
            {
                Console.WriteLine("Stowaway");
            }
            else
            {
                Console.WriteLine("Controller " + minut);
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(tmp[0]);
            int zayc = int.Parse(tmp[1]);
            int controller = int.Parse(tmp[2]);
            int minut = -5;
            string naprav = Console.ReadLine();
            int znak = 0;
            if (naprav == "to head")
            {
                znak = -1;
            }
            else
            {
                znak = 1;
            }

            string mask = Console.ReadLine();
            bool win = true;

            for (int i = 0; i < mask.Length; i++)
            {

                if ((controller == 1) && (znak == -1))
                {
                    znak = -znak;
                }
                if ((controller == n) && (znak == 1))
                {
                    znak = -znak;
                }
                if (mask[i] == '0')
                {
                    if (zayc == 1 || zayc == n)
                    {

                    }
                    else
                    {
                        if (zayc < controller)
                            zayc--;
                        else
                            zayc++;
                    }
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                    }

                }
                else
                {
                    controller += znak;
                    if (znak == 1)
                    {
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if(controller !=1)
                            if(controller !=n)
                        {
                            zayc = 1;
                        }
                    }
                    else
                    {
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller != 1)
                            if (controller != n)
                        {
                            zayc = n;
                        }
                    }
                }

            }

            if (win)
            {
                Console.WriteLine("Stowaway");
            }
            else
            {
                Console.WriteLine("Controller " + minut);
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest_74
{
    class Program
    {
        static void A()
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<string, int> p = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');
                p.Add(t[0], int.Parse(t[1]) * 100 - int.Parse(t[2]) * 50 + int.Parse(t[3]) + int.Parse(t[4]) + int.Parse(t[5]) + int.Parse(t[6]) + int.Parse(t[7]));
            }

            int max = int.MinValue;
            string name = "";
            foreach (var e in p)
            {
                if (e.Value > max)
                {
                    max = e.Value;
                    name = e.Key;
                }
            }

            Console.WriteLine(name);
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int a = int.Parse(t[1]);
            int b = int.Parse(t[2]);
            string dir = Console.ReadLine();
            int d = 1;
            if (dir.IndexOf("tail") == -1)
                d = -1;
            string s = Console.ReadLine();
            int l = s.Length;
            for (int i = 0; i < l; i++)
            {
                b += d;
                if (b > l)
                    b %= l;
                if (b < 1)
                    b = l;
                switch (s[i])
                {
                    case '0':
                        if ((a + d < l) && (a + d > 0))
                            a += d;
                        break;
                    case '1':
                        a = b + d;
                        break;
                }
                if (a == b)
                {
                    Console.WriteLine("Controller " + (i+1));
                    return;
                }
            }
            Console.WriteLine("Stowaway");
        }

        static void Main(string[] args)
        {
            B();
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i+1==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n && kn>0) kn = -1;
                if (k == 1 && kn<0) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 1; i <= o; i++)
            {
                if (z == k)
                {
                    win = "Controller 0";
                    break;
                }
                if (i==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i-1] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+i.ToString();
                        break;
                    }
                }
                else // stop
                {
                    z = k;
                    k += kn;

                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i==(o-1))
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
       //     kn = toS[3] == 'h' ? -1 : 1;
            kn = n>4 ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i+1==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n && kn>0) kn = -1;
                if (k == 1 && kn<0) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i==(o-1))
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1);
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Сontroller 1";
                    break;
                }
                if (i==(o-1))
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Сontroller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i==(o-1))
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS[3] == 'h' ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 0; i < o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i+1==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n && kn>0) kn = -1;
                if (k == 1 && kn<0) kn = 1;

                if (s[i] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+(i+1).ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";
            for (int i = 1; i <= o; i++)
            {
                if (i==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i-1] == '0') //go
                {
                if (z > k) zn = 1;
                else zn = -1;
                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+i.ToString();
                        break;
                    }
                }
                else // stop
                {
                    z = k;
                    k += kn;

                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 1; i <= o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i-1] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+i.ToString();
                        break;
                    }
                }
                else // stop
                {
                    k += kn;
                    if (kn > 0)
                    {
                        if (k > 1) z = 1;
                        else z = n;
                    }
                    if (kn < 0)
                    {
                        if (k < n) z = n;
                        else z = 1;
                    }
                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";
            for (int i = 1; i <= o; i++)
            {
                if (i==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i-1] == '0') //go
                {
                if (z > k) zn = 1;
                else zn = -1;
                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+i;
                        break;
                    }
                }
                else // stop
                {
                    z = k;
                    k += kn;

                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

#define DEBUG
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OlympSchool_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,z,k,kn,zn;
            string s;
            string[] st;
            string toS;

#if DEBUG
            StreamReader sr = new StreamReader("b68.txt");
            s = sr.ReadLine();
#else
            s = Console.ReadLine();
#endif
            st = s.Split(' ');
            n = int.Parse(st[0].Trim());
            z = int.Parse(st[1].Trim());
            k = int.Parse(st[2].Trim());
#if DEBUG
            toS = sr.ReadLine().Trim();
            s = sr.ReadLine().Trim();
#else
            s = Console.ReadLine().Trim();
            toS = Console.ReadLine().Trim();
#endif
            kn = toS == "to head" ? -1 : 1;
            int o = s.Length;
            string win="";

            for (int i = 1; i <= o; i++)
            {
                if (z == k)
                {
                    win = "Controller 1";
                    break;
                }
                if (i==o)
                {
                    win = "Stowaway";
                    break;
                }

                if (k == n) kn = -1;
                if (k == 1) kn = 1;

                if (s[i-1] == '0') //go
                {
                    if (z > k) zn = 1;
                    else zn = -1;

                    if (zn > 0 && z < n) z++;
                    if (zn < 0 && z > 1) z--;

                    k += kn;
                    if(k==z)
                    {
                        win = "Controller "+i.ToString();
                        break;
                    }
                }
                else // stop
                {
                    z = k;
                    k += kn;

                }
            }

            Console.WriteLine(win);
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round68
{
    class B
    {
        public static void Main()
        {
            var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
            int n = xs[0],
                m = xs[1],
                k = xs[2];
            int dx = Console.ReadLine() == "to head" ? -1 : 1;
            var s = Console.ReadLine();

            for (int i = 0; i < n; i++)
            {
                if (!(1 <= k + dx && k + dx <= n))
                    dx = -dx;
                k += dx;
                if (s[i] == '1')
                {
                    m = k - dx;
                }
                else
                {
                    if (1 <= m + dx && m + dx <= n)
                        m += dx;
                    if (k == m)
                    {
                        Console.WriteLine("Controller {0}", i + 1);
                        return;
                    }
                }
            }
            Console.WriteLine("Stowaway");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]) - 1; // rabbit
            int k = int.Parse(line[2]) - 1;
            int dir = Console.ReadLine() == "to tail" ? 1 : -1;
            string s = Console.ReadLine();

            if (k == 0)
                dir = 1;
            if (k == n - 1)
                dir = -1;

            bool caught = false;
            int time = 0;
            bool afterstop = false;
            bool before = false;
            for (; time < s.Length && !caught; time++)
            {
                //k += dir;
                if (s[time] == '0' && !afterstop)
                {
                    if (m == 0 && (k == 1 || k == 2) && dir == -1)
                    {
                        caught = true;
                        time++;
                        break;
                    }

                    if (m == n - 1 && (k == n - 2 || k == n - 3) && dir == 1)
                    {
                        caught = true;
                        time++;
                        break;
                    }

                    if (Math.Abs(k - m) > 2)
                    {
                        k += dir;
                        m += -dir;
                    }
                    else
                    {
                        k += dir;
                        m += dir;
                    }
                }
                else if (s[time] == '1')
                {
                    afterstop = true;
                    k += dir;
                    before = dir > 0;
                }
                else if (s[time] == '0' && afterstop)
                {
                    k += dir;
                    if (k == 0 && before || k == n - 1 && !before)
                    {
                        caught = true;
                        break;
                    }
                }

                if (k == 0)
                    dir = 1;
                if (k == n - 1)
                    dir = -1;
            }

            if(caught)
                Console.WriteLine("Controller {0}", time);
            else
                Console.WriteLine("Stowaway");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]) - 1; // rabbit
            int k = int.Parse(line[2]) - 1;
            int dir = Console.ReadLine() == "to tail" ? 1 : -1;
            string s = Console.ReadLine();

            if (k == 0)
                dir = 1;
            if (k == n - 1)
                dir = -1;

            bool caught = false;
            int time = 0;
            bool afterstop = false;
            bool before = false;
            for (; time < s.Length && !caught; time++)
            {
                //k += dir;
                if (s[time] == '0' && !afterstop)
                {
                    if (m == 0 && (k == 1) && dir == -1)
                    {
                        caught = true;
                        time++;
                        break;
                    }

                    if (m == n - 1 && (k == n - 2) && dir == 1)
                    {
                        caught = true;
                        time++;
                        break;
                    }

                    if (Math.Abs(k - m) > 2)
                    {
                        k += dir;
                        m += -dir;
                    }
                    else
                    {
                        k += dir;
                        m += dir;
                    }
                }
                else if (s[time] == '1')
                {
                    afterstop = true;
                    k += dir;
                    before = dir > 0;
                }
                else if (s[time] == '0' && afterstop)
                {
                    k += dir;
                    if (k == 0 && before || k == n - 1 && !before)
                    {
                        caught = true;
                        break;
                    }
                }

                if (k == 0)
                    dir = 1;
                if (k == n - 1)
                    dir = -1;
            }

            if(caught)
                Console.WriteLine("Controller {0}", time);
            else
                Console.WriteLine("Stowaway");
        }
    }
}

using System;
using System.Text;
using System.Linq;

class Program
{
static void Main()
{
string s1 = Console.ReadLine();
int n = int.Parse(s1.Split(' ')[0]) - 1;
int win = -1;
int z0 = int.Parse(s1.Split(' ')[1]) - 1;
int c0 = int.Parse(s1.Split(' ')[2]) - 1;

string s2 = Console.ReadLine();

string s3 = Console.ReadLine();

for (int i=0; i<s3.Length; i++)
{
    if (s3[i] == '0')
    {
        z0 = -1;

        peremesh(n, c0, ref s2, out c0);

        if (s2 == "to tail")
            if (c0 != 0)
                z0 = 0;
            else
                z0 = n;
        else
            if (c0 != n)
                z0 = n;
            else
                z0 = 0;
    }
    else
    {
        if (z0 > c0)
        {
            if (z0 != n)
                z0++;
        }
        else
        {
            if (z0 != 0)
                z0--;
        }
    }

    if (s3[i] != '0')
        peremesh(n, c0, ref s2, out c0);

    if (c0 == z0)
    {
        Console.WriteLine("Controller");
        win = 1;
        break;
    }
}
if (win != 1)
Console.WriteLine("Stowaway");

Console.ReadKey();

}

static void peremesh(int n, int place, ref string dir, out int N)
{
N = -1;
if (dir == "to tail")
{
if (place < n)
place++;
else
{
dir = "to head";
place--;
}
}
else
if (place > 0)
place--;
else
{
dir = "to tail";
place++;
}
}
}

using System;
using System.Text;
using System.Linq;

class Program
{
static void Main()
{
string s1 = Console.ReadLine();
int n = int.Parse(s1.Split(' ')[0]) - 1;
int win = -1;
int z0 = int.Parse(s1.Split(' ')[1]) - 1;
int c0 = int.Parse(s1.Split(' ')[2]) - 1;

string s2 = Console.ReadLine();

string s3 = Console.ReadLine();

for (int i=0; i<s3.Length; i++)
{

    if (s3[i] == '0')
    {
        if (s2 == "to tail")
            if (c0 != 0)
                z0 = 0;
            else
                z0 = n;
        else
            if (c0 != n)
                z0 = n;
            else
                z0 = 0;
    }
    else
    {
        if (z0 > c0)
        {
            if (z0 != n)
                z0++;
        }
        else
        {
            if (z0 != 0)
                z0--;
        }
    }
    peremesh(n, c0, ref s2, out c0);

    if (c0 == z0)
    {
        Console.WriteLine("Controller");
        win = 1;
        break;
    }
}
if (win != 1)
Console.WriteLine("Stowaway");

Console.ReadKey();

}

static void peremesh(int n, int place, ref string dir, out int N)
{
N = -1;
if (dir == "to tail")
{
if (place < n)
place++;
else
{
dir = "to head";
place--;
}
}
else
if (place > 0)
place--;
else
{
dir = "to tail";
place++;
}
}
}