asm("mark\soutchar;outchar;push\s0;return"); asm("mark\soutnum;outnum;push\s0;return"); asm("mark\sreadchar;push\s0;dup;readchar;retrieve;return"); asm("mark\sreadnum;push\s0;dup;readnum;retrieve;return"); asm("mark\snextInt;push\s0;mark\snextIntloop;push\s0;dup;readchar;retrieve;push\s48;sub;dup;jneg\snextIntend;dup;push\s9;swap;sub;jneg\snextIntend;swap;push\s10;mul;add;jump\snextIntloop;mark\snextIntend;disc;return"); def main() { var a = nextInt(); var b = nextInt(); var s = nextInt(); outnum(solve(a,b,s)); outchar('\n'); } def solve(a,b,s) { var la = abs(a-s); var lb = abs(b-s); if (s == 1) { return la + 1; } if (la <= lb) { return la + s; }else{ return min(lb + abs(a-s) + a, lb + (s-1) + a); } } def abs(n) { if (n < 0) { return -n; } return n; } def min(a,b) { if (a < b) { return a; } return b; } -