Why the code is giving Runtime error

I am solving the problem http://www.codechef.com/problems/DIGJUMP
and my code is given below.Can anyone please tell me why it is giving runtime error.

import sys
visited=[0]*10
graph=[]
for i in range(10):
    graph.append([])

queue=[]

def bfs(v,e):
    visited[int(v)]=1
    #print v
    queue.append(v)
    '''
    for i in graph[int(i)]:
        if visited[int(i)]==0:
            bfs(i,e)
    '''
    global count
    count=0
    while len(queue)>0:
        s=queue.pop(0)
        count+=1
        if s==e:
            break

        for i in graph[int(s)]:
            if visited[int(i)]==0:
                visited[int(i)]=1
                queue.append(i)




a=raw_input()
l=len(a)
if l>0:
    for i in xrange(l-1):
        graph[int(a[i])].append(a[i+1])
        graph[int(a[i+1])].append(a[i])

    #print graph
    bfs(a[0],a[l-1])
    print count