import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int r = sc.nextInt(); int m = sc.nextInt(); int ans = Math.min(r-l+1, m); System.out.println(ans); } }