static void Main()
        {
            var result = new StringBuilder();
            var queue  = new BucketList <string>();
            var names  = new Dictionary <string, int>();

            var input          = Console.ReadLine();
            var currentCommand = Command.Parse(input);

            while (true)
            {
                string name = string.Empty;

                switch (currentCommand.Name)
                {
                case "Append":
                    name = currentCommand.Parameters[0];
                    AddName(names, name);

                    queue.Add(name);
                    result.AppendLine("OK");
                    break;



                case "Insert":
                    var position = int.Parse(currentCommand.Parameters[0]);
                    name = currentCommand.Parameters[1];
                    AddName(names, name);

                    if (position > queue.Size || position < 0)
                    {
                        result.AppendLine("Error");
                        break;
                    }

                    queue.Insert(position, name);
                    result.AppendLine("OK");
                    break;

                case "Find":
                    name = currentCommand.Parameters[0];

                    if (!names.ContainsKey(name))
                    {
                        result.AppendLine("0");
                    }
                    else
                    {
                        result.AppendLine(names[name].ToString());
                    }
                    break;



                case "Serve":
                    var count = int.Parse(currentCommand.Parameters[0]);

                    if (count > queue.Size || count < 0)
                    {
                        result.AppendLine("Error");
                        break;
                    }

                    var currentResult = new List <string>();
                    for (int i = 0; i < count; i++)
                    {
                        currentResult.Add(queue[0]);
                        queue.Remove(0);
                    }

                    for (int i = 0; i < currentResult.Count; i++)
                    {
                        names[currentResult[i]]--;
                    }

                    result.AppendLine(string.Join(" ", currentResult));
                    break;

                case "End":
                    Console.WriteLine(result.ToString());
                    return;
                }

                input          = Console.ReadLine();
                currentCommand = Command.Parse(input);
            }
        }