The PLY format is fairly simple.
ply
format ascii 1.0
comment object: vertex cloud
element vertex 8
property uint x
property uint y
property uint z
property uchar red { start of vertex color }
property uchar green
property uchar blue
end_header
0 0 0 255 0 0 { start of vertex list }
0 0 1 255 0 0
0 1 1 255 0 0
0 1 0 255 0 0
[...]
In line 4, the number of vertices is defined.