users table

In the Registration time every user have to put parent_id , who registration under parent_id, so i made different table for it
sponser table
after that make tree like that

and i want to count record like that

so plz guide me how can i count record like that or there is any way i mean to say for this kind of counting i have to change in database , thanks in advance
i have Adjacency model structure in table, so i got it very nice solution count user_id under parent_id
that function count user_id under parent_id
call function