```
class Solution(object):
def removeKdigits(self, num, k):
num = list(num)
for _ in range(k):
i = 0
while i < len(num)-1:
if num[i] > num[i+1]:
num.pop(i)
i = -1
break
i += 1
if i >= 0:
num.pop()
return str(int(''.join(num))) if num else '0'
```