l,r,m = map(int, input().split()) if r>=l+m: print(m) else: print(r-l)