The size of an interior angle of a regular polygon is x^2 while its exterior angle is 3x. Find the number of sides of the polygon