alethio june cook off TLE help

s = raw_input()
slen = len(s)
maxnum=0
if slen==1:
if(‘0’ <= s[0] <=‘9’):
print s[0]
else:S
print “9”
else:
for i in range(slen):
k=0
temp=""
count=0
j=i
while(j<slen):
if(‘0’<= s[j] <=‘9’):
temp+=(s[j])
else:
count+=1
if count==2:
tmp = int(temp)
if(maxnum<tmp):
maxnum=tmp
break
else:
temp+=(‘9’)
tmp = int(temp)
if(maxnum<tmp):
maxnum=tmp
j+=1
print maxnum

why this code is giving TLE, complexity is O(n^2).

Please help ?