--SP-信赖之心
function c87593005.initial_effect(c)
	--
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(87593005,0))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_COUNTER)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetTarget(c87593005.target)
	e1:SetOperation(c87593005.operation)
	c:RegisterEffect(e1)
end
function c87593005.filter1(c,e,tp)
	local lv=c:GetLevel()
	return lv>=2 and Duel.IsExistingTarget(c87593005.filter2,tp,LOCATION_GRAVE,0,1,nil,e,tp,math.floor(lv/2))
end
function c87593005.filter2(c,e,tp,lv)
	return c:IsLevelBelow(lv) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c87593005.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chk==0 then return Duel.IsExistingMatchingCard(c87593005.filter1,tp,LOCATION_HAND,0,1,nil,e,tp)
		and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end
	local rg=Duel.SelectMatchingCard(tp,c87593005.filter1,tp,LOCATION_HAND,0,1,1,nil,e,tp)
	local lv=rg:GetFirst():GetLevel()/2
	Duel.SendtoGrave(rg,REASON_COST)
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectTarget(tp,c87593005.filter2,tp,LOCATION_GRAVE,0,1,1,nil,e,tp,math.floor(lv))
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,tp,LOCATION_GRAVE)
end
function c87593005.operation(e,tp,eg,ep,ev,re,r,rp)
	local tc=Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
	Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
	end
	local f=Duel.GetMatchingGroup(Card.IsCode,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,87593200):GetFirst()
	if f:GetControler()==tp then cou=0x871 else cou=0x872 end
	f:AddCounter(cou,1)
end
