How to find the degree of polynomial?