#!/bin/bash
read num1 num0 num card
max=0
while [ $card -gt 0 ]do
	if [ $num1 -gt 0 ]; then
		max=$(($max+1))
        num1=$(($num1-1))
        card=$(($card-1))
 	elif [ $num0 -gt 0 ]; then
    	num0=$(($num0-1))
        card=$(($card-1))
  	else
    	max=$(($max-1))
        card=$(($card-1))
  	fi
done
echo $max