function ItemCount(id: integer): int64;  overload;     // подсчет кол-ва итемов по ID
var i: integer;
begin
  result:= 0;                                          
  for i:= 0 to Inventory.User.Count-1 do begin         // пробегаемся по инвентарю юзера
    if (Inventory.User.Items(i).ID = id) then          // если id совпали, то
      Inc(result, Inventory.User.Items(i).Count);      // увеличиваем результат на кол-во предметов в стаке
  end; 
  for i:= 0 to Inventory.Quest.Count-1 do begin        // аналогично для квестового инвентаря
    if (Inventory.Quest.Items(i).ID = id) then
      Inc(result, Inventory.Quest.Items(i).Count); 
  end;
end;

function ItemCount(const Name: string): int64;  overload;   // подсчет кол-ва итемов по названию
var i: integer;
begin
  result:= 0;
  for i:= 0 to Inventory.User.Count-1 do begin         // пробегаемся по инвентарю юзера
    if (Inventory.User.Items(i).Name = Name) then      // если названия совпали, то
      Inc(result, Inventory.User.Items(i).Count);      // увеличиваем результат на кол-во предметов в стаке
  end; 
  for i:= 0 to Inventory.Quest.Count-1 do begin        // аналогично для квестового инвентаря
    if (Inventory.Quest.Items(i).Name = Name) then
      Inc(result, Inventory.Quest.Items(i).Count); 
  end;
end;

begin
  Print(ItemCount(57));
  Print(ItemCount('Адена'))
end.