using System; using System.Collections.Generic; using static System.Console; namespace ConsoleApp { class Program { static void Main(string[] args) { string[] N = ReadLine().Split(' '); long X = long.Parse(N[0]); long Y = long.Parse(N[1]); long Z = long.Parse(N[2]); if(X > Z) { WriteLine(0); } else if(X <= Z && Y > Z || Y <= Z && X > Z || X == Y) { WriteLine(Z - 1); } else { WriteLine(Z - 2); } } } }