# -*- coding:utf-8 -*-
class Solution:
    def GetNumberOfK(self, data, k):
        # write code here
        if len(data)==1:
            if data[0]==k:return 1
            else:return 0
        l=self.getleft(data, k)
        r=self.getleft(data, k+1)
        return r-l
    def getleft(self,data,k):
        left,right=0,len(data)
        while left<right:
            mid=(left+right)//2
            if data[mid]<k:left=mid+1
            elif data[mid]>=k:right=mid
        return left