a={} def _(*b):c,d,e=b;f=a[b]=a.get(b,(c<=d)*e)or _(_(c-5,d,e),_(d-5,e,c),_(e-5,c,d));return f while 1:print _(*map(int,raw_input().split()))