How to recieve the quantity of the collisions with my collider after setting the position of the gam

How to recieve the quantity of the collisions with my collider after setting the position of the game object with this collider?

UPD: I have tried to do

using UnityEngine;
public class GettingQuantityOfCollisions : MonoBehaviour
{
   private int QuantityOfTheObjectsInTheZone = 0;
   public int GetQuantityOfTheObjectsInTheZone() => QuantityOfTheObjectsInTheZone;

   private void OnCollisionEnter(Collision anyCollision) => QuantityOfTheObjectsInTheZone++;
   private void OnCollisionExit(Collision anyCollision) => QuantityOfTheObjectsInTheZone--;
}

But it does not work when I set the transform.position of the game object with the collider directly.

Yes because setting the transform position of an object is circumventing the physics system.

Expanding on what Spiney posts above…

With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

https://discussions.unity.com/t/866410/5

https://discussions.unity.com/t/878046/8