import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm; void main(){ int[] buf = readln().strip().split().map!(to!int)().array(); int ans = buf.reduce!min(); buf[] -= ans; for(;;) { int maxs, maxp; foreach(immutable int i; 0 .. 3) { if(maxs < buf[i]) { maxs = buf[i]; maxp = i; } } if(maxs < 3) { break; } else if(maxs == 3 || maxs == 4) { if(buf.reduce!"a + b" - maxs == 0) { break; } else { buf = buf.map!"max(a-1, 0)"().array(); buf[maxp] -= 2; ++ ans; } } else { buf = buf.map!"max(a-1, 0)"().array(); if(buf.reduce!"a + b" - maxs == 0) { buf[maxp] -= 4; } else { buf[maxp] -= 2; } ++ ans; } } writeln(ans); }