One approach would be to use groups
func _ready():
pass
func _physics_process(delta):
if Input.is_action_just_pressed("left_click"):
var instance = scene.instance()
instance.global_position = get_global_mouse_position()
add_child(instance)
instance.add_to_group("INSTANCE")
and to get the count just use
var count = get_nodes_in_group("INSTANCE").size()
p.s. note that "INSTANCE" can be anything to identify your instances