int len = 0;
struct node *temp = p;
while(temp!=NULL){
  len++;
  temp = temp->next;
}
return len;