https://www.acmicpc.net/problem/2875
import java.util.*;
fun main(args: Array<String>) {
val s=Scanner(System.`in`)
var n=s.nextInt();
var m=s.nextInt();
var k=s.nextInt();
var c=n/2
var count=if(c>=m) m else c
var re=n+m-3*count
n=n-2*count
m=m-count
k-=re
if(k>0){
var a=k/3
var b=k%3
if(b==0) count-=a
else count-=a+1
}
print(count)
}