class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
if x==0:
return 0
n=1
step=x
while step>=4:
step>>=2
n<<=1
step=n
while step>0:
if (n+step)*(n+step)<=x:
n+=step
step>>=1
return n