Logic help with Variable not defined please

Logic help with Variable not defined please

Can you please tell me why this code comes back with variable not defined.

Thanks

if (count(Agents[Name == input.Name])  >  0)
{
rec = Agents [Name == input.Name];
input.Name = rec.Name;
openurl("#Form:Agents?Lookup_Agents=" + input.Name, "same window");
}

Error at line number : 1 
Variable 'Name' is not defined