using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
string input ="";
List<string> commands = new List<string>();
string command ="";
for(int i =0; i< input.Length; i++)
if(input[i] == ' ') break;
foreach(string c in commands)
if(c.Length > i && c[i]==input[i])
// всё ещё подходит команда
if(c.Length-1 == i)
command = c; // нашли комманду
}
else
commands.Remove(c); // не подходит