jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int sum = a + b + c;
  int max = max(a, max(b ,c));
  int ans;
  rep(i, max, 51) {
    if ( (i * 3 - sum) % 2 != 0 ) continue;
    ans = (i * 3 - sum) / 2;
    break;
  }
  printf("%d\n", ans);
  return 0;
}
//  [javascript]
"use strict"
function Main(input) {
  input = input.trim().split(' ').map(Number);
  const A = input[0];
  const B = input[1];
  const C = input[2];
  let sum = A + B + C;
  let max = Math.max(A, B, C);
  let M = 3 * max;

  let ret = 0;
  if(M%2 === sum%2){
    ret = (M-sum)/2;
  } else {
    ret = (M+3-sum)/2;
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;
    var c = input[0].split(" ")[2]-0;
    var ans = 0;
    var max = Math.max(Math.max(a,b),c);
    if(b==max){
        b = a;
        a = max;
    }else if(c==max){
        c = a;
        a = max;
    }
    ans += a-Math.max(b,c);
    if((a - ans - Math.min(b,c))%2 == 0){
        ans += (a-ans-Math.min(b,c))/2;
    }else{
        ans += ~~((a-ans-Math.min(b,c))/2)+2;
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


//1 2 3 4 5 6
//  [javascript]
function calc(input) {
  var array = input.split(' ');
  var A = parseInt(array[0]);
  var B = parseInt(array[1]);
  var C = parseInt(array[2]);

  if (A === B === C) {
    return 0;
  }

  var max = Math.max(A, B, C);
  var min = Math.min(A, B, C);

  if (A === B === max || B === C === max || C === A === max) {
    return Math.floor((max - min) / 2) + ((max - mod) % 2 === 0 ? 0 : 2);
  }

  if (A === B === min || B === C === min || C === A === min) {
    return max - min;
  }

  var mid;
  if (A === max) {
    mid = B === min ? C : B;
  } else if (B === max) {
    mid = A === min ? C : A;
  } else {
    mid = A === min ? B : A;
  }

  var diffFromMidToMax = max - mid;
  var diffFromMinToMid = mid - min;
  var isMod0 = diffFromMinToMid % 2 === 0;

  return diffFromMidToMax + Math.floor(diffFromMinToMid / 2) + (isMod0 ? 0 : 2);
}

function main(input) {
  console.log(calc(input));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

function main(input) {
    input = input.split(/\n|\s/).map(v => ~~v)
    let A = input[0]
    let B = input[1]
    let C = input[2]

    const sum = A + B + C
    let goal = Math.max.apply(null, input) * 3

    if (sum % 2 == goal % 2) {
        // console.log(sum % 2, goal % 2)
    } else {

        goal += 1
    }

    const ans = Math.ceil((goal - sum) / 2)



    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
import java.util.Scanner;

class Contest93C {

    static void Compare3Figures(int a, int b, int c) {
        if (b < a && a < c) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        else if (b < a && c < b) {
            int tmptwo = a;
            a = c;
            c = tmptwo;
        }

        else if (a < b && c < b && a < c) {
            int tmpthree = b;
            b = c;
            c = tmpthree;
        }

        else if (a < b && c < a) {
            int tmpfour = a;
            a = c;
            c = b;
            b = tmpfour;
        }

        else if (b < a && b < c && c < a) {
            int tmpfive = a;
            a = b;
            b = c;
            c = tmpfive;

        }

        OddEvenCheck(a, b, c);

    }

    static void OddEvenCheck(int a, int b, int c) {
        int OddorEvenOne = (b - a) % 2;
        int OddorEvenTwo = (c - b) % 2;

        if (OddorEvenOne == 0 && OddorEvenTwo == 0) {
            System.out.print(MakeEqual3Figures(a, b, c));
        }

        else if (OddorEvenOne != 0 && OddorEvenTwo != 0) {
            a = a + 1;
            c = c + 1;
            System.out.print(MakeEqual3Figures(a, b, c) + 1);
        }

        else if (OddorEvenOne == 0 && OddorEvenTwo != 0) {
            a = a + 1;
            b = b + 1;
            System.out.print(MakeEqual3Figures(a, b, c) + 1);
        }

        else if (OddorEvenOne != 0 && OddorEvenTwo == 0) {
            b = b + 1;
            c = c + 1;
            System.out.print(MakeEqual3Figures(a, b, c) + 1);
        }

    }

    static int MakeEqual3Figures(int a, int b, int c) {
        int countone = 0;
        int counttwo = 0;
        int resultone = 0;

        while (a != c) {
            a += 2;
            countone++;
        }

        while (b != c) {
            b += 2;
            counttwo++;
        }

        resultone = countone + counttwo;
        return resultone;
    }

    public static void main(String args[]) {
        Scanner stdIn = new Scanner(System.in);

        int A = 0;
        int B = 0;
        int C = 0;

        do {
            A = stdIn.nextInt();
        } while (A < 0 || 50 < A);

        do {
            B = stdIn.nextInt();
        } while (B < 0 || 50 < B);

        do {
            C = stdIn.nextInt();
        } while (C < 0 || 50 < C);

        Compare3Figures(A, B, C);

        System.out.println(" ");
    }
}
//  [javascript]
function calc(input) {
  var array = input.split(' ');
  var A = parseInt(array[0]);
  var B = parseInt(array[1]);
  var C = parseInt(array[2]);

  if (A === B === C) {
    return 0;
  }

  var max = Math.max(A, B, C);
  var min = Math.min(A, B, C);

  if (A === B || B === C || C === A) {
    return max - min;
  }

  var mid;
  if (A === max) {
    mid = B === min ? C : B;
  } else if (B === max) {
    mid = A === min ? C : A;
  } else {
    mid = A === min ? B : A;
  }

  var diffFromMidToMax = max - mid;
  var diffFromMinToMid = mid - min;
  var isMod0 = diffFromMinToMid % 2 === 0;

  return diffFromMidToMax + Math.floor(diffFromMinToMid / 2) + (isMod0 ? 0 : 2);
}

function main(input) {
  console.log(calc(input));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func max(x ...int) int {
	m := x[0]
	for i := 1; i < len(x); i++ {
		if m < x[i] {
			m = x[i]
		}
	}

	return m
}

func main() {
	a, b, c := nextInt(), nextInt(), nextInt()

	m := max(a, b, c)
	if m%2 == (a+b+c)%2 {
		fmt.Println((3*m - a - b - c) / 2)
	} else {
		fmt.Println((3*(m+1) - a - b - c) / 2)
	}
}
//  [go]
package main

import "fmt"

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	max := largest(a, b, c)
	sum := a + b + c

	diff := 3*max - sum
	if diff%2 == 1 {
		diff += 3
	}
	ans := diff / 2
	fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	max := max(A, max(B, C))
	sum := A + B + C

	if max%2 != sum%2 {
		max++
	}
	fmt.Println((3*max - sum) / 2)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	A := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scan(&A[i])
	}
	sort.Ints(A)

	ans := (A[2]*2-A[1]-A[0])/2 + (A[2]*2-A[1]-A[0])%2
	fmt.Println(ans)
}
//  [go]
package main
import (
	"fmt"
	"sort"
)
func main(){
	A := make([]int, 3)
	for i:=0; i<3; i++{
		fmt.Scan(&A[i])
	}
	sort.Ints(A)
	minimum,maximum := A[0], A[2]
	if minimum == maximum{
		fmt.Println(0)
		return
	}
	ans := 0
	if (maximum-minimum)%2 == 0{
		ans += (maximum - minimum)/2
		A[0] += (maximum - minimum)
	}else{
		A[1]++
		ans += (maximum - minimum)/2 + 1
		A[0] += (maximum - minimum)
	}
	sort.Ints(A)
	if (A[2]-A[0])%2==0{
		ans += (A[2]-A[0])/2
	}else{
		if A[2]-A[0]>1{
			ans += (A[2]-A[0])/2+2
		}else{
			ans++
		}
	}
	fmt.Println(ans)
}
//  [go]
// minをmaxにして残ったのをなんとかする
// なぜか2WA 意味不明 [0 1 1] -> [1 1 2] で[3 3 3]にしてしまっていたっぽい
// なんでふたつまえの提出でWAをくらったのかまるで理解できない たぶんジャッジがバグってるよ
package main
import (
	"fmt"
	"sort"
)
func main(){
	A := make([]int, 3)
	for i:=0; i<3; i++{
		fmt.Scan(&A[i])
	}
	sort.Ints(A)
	minimum, maximum := A[0], A[2]
	ans := 0
	if (maximum-minimum)%2 == 0{
		// ひたすら2だけやる
		ans += (maximum-minimum)/2
		A[0] = A[2]
	}else{
		// 1回だけ1をまぜる そのときA[1]にも加算
		ans += (maximum-minimum)/2 + 1
		A[0] = A[2]
		A[1]++
	}
	sort.Ints(A)
	if A[0]==A[1] && A[1] == A[2]{
		fmt.Println(ans)
	}else{
		if (A[2]-A[0]) % 2 == 1{
			if A[2]-A[0] == 1{
				fmt.Println(ans+1)
				return
			}else{
				A[1]++
				A[2]++
				ans++
			}
		}
		ans += (A[2] - A[0])/2
		fmt.Println(ans)
	}
}
//  [ruby]
a = gets.split.map(&:to_i).sort
count = 0
while a[-1] != a[-2]
  a[0] += 1
  a[1] += 1
  count += 1
end
while a[-2] > a[0]
  a[0] += 2
  count += 1
end
if a[-2] != a[0]
  count += 1
end
puts count
//  [ruby]
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,C=get_i.sort{|x,y| y<=>x}
dif1=A-C
dif2=A-B
if (dif1+dif2).even?
  puts (dif1+dif2)/2
else
  puts (dif1+dif2+1)/2+1
end
//  [ruby]
A,B,C=gets.split.map(&:to_i)
ary = [A,B,C].sort
x, y, z = ary
cnt = 0
while x < z do
    if y < z
        x += 1
        y += 1
    else
        x += 2
    end
    cnt += 1
end
cnt += 1 if x > z || y > z
puts cnt
//  [ruby]
a,b,c = gets.strip.split.map(&:to_i)
d = [a,b,c].sort
s = d[2]-d[0]
t = d[2]-d[1]
u = d[1]-d[0]
if u%2==0
  puts u/2+t
else
  puts 2*u+t
end
//  [ruby]
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,C=get_i
ab=(A-B).abs
bc=(B-C).abs
if (ab+bc).even?
    puts (ab+bc)/2
else
    puts (ab+bc+1)/2+1
end
//  [ruby]
ans = 0
x = gets.split.map(&:to_i).sort
loop do
  if x[1] - x[0] > 1
    x[0] += 2
  else
    x[0] += 1
    x[1] += 1
  end
  ans += 1
  break if x[0] == x[1] && x[1] == x[2]

  x.sort!
end
puts ans
//  [rust]
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer.trim_right().to_owned()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_single<T>() -> T
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    T::from_str(buffer.trim_right()).unwrap()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_multiple<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer
        .trim_right()
        .split_whitespace()
        .flat_map(|s| T::from_str(s))
        .collect()
}

#[allow(unused_macros)]
macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

struct State {
    a: i32,
    b: i32,
    c: i32,
}

fn main() {
    let mut inputs = parse_line_to_multiple::<i32>();
    inputs.sort();

    let mut operation_count = 0;

    while inputs[1] != inputs[2] {
        inputs[0] += 1;
        inputs[1] += 1;
        operation_count += 1;
    }

    while inputs[0] < inputs[1] {
        inputs[0] += 2;
        operation_count += 1;
    }

    if inputs[0] > inputs[1] {
        inputs[1] += 1;
        inputs[2] += 1;
        operation_count += 1;
    }

    assert_eq!(inputs[0], inputs[1]);
    assert_eq!(inputs[1], inputs[2]);

    println!("{}", operation_count);
}
//  [rust]
use std::cmp::max;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    a: usize,
    b: usize,
    c: usize,
    }
    let m = max(max(a, b), max(b, c));
    let l = 3 * m - (a + b + c);
    let ans = if l % 2 == 0 {l / 2}  else {l / 2 + 2};
    println!("{}", ans);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn f(src: i64, dst: i64) -> i64 {
    if src > dst {
        return src - dst;
    }
    if (dst - src) % 2 == 0{
        return (dst - src) / 2;
    }
    (dst - src) / 2 +2
}

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
    };
    println!(
        "{}",
        (-1..51)
        .map(|v| f(a, v) + f(b, v) + f(c, v))
        .min().unwrap()
    );
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: [usize; 3]};
    let mut a: Vec<usize> = a;

    a.sort();

    let mut count = a[2] - a[1];
    a[0] += count;
    count += (a[2] - a[0]) / 2;
    println!("{}", count)
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: [usize; 3]};
    let mut a: Vec<usize> = a;

    a.sort();

    let mut count = a[2] - a[1];
    a[0] += count;
    count = (a[2] -a[0]) / 2;
    // while a[0] != a[1] && a[1] != a[2] {
    //     if a[1] == a[2] {
    //         a[0] += 2;
    //         count += 1;
    //     } else {
    //         a[0] += 1;
    //         a[1] += 1;
    //         count += 1;
    //     }
    // }

    println!("{}", count)
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: [usize; 3]};
    let mut a: Vec<usize> = a;

    a.sort();

    let mut count = 0;
    while a[0] != a[1] || a[1] != a[2] {
        if a[1] == a[2] {
            a[0] += 2;
            count += 1;
        } else {
            a[0] += 1;
            a[1] += 1;
            count += 1;
        }
    }

    println!("{}", count)
}
//  [swift]
let ABC = readLine()!.characters.split(" ").map{Int(String($0))!}
let max = ABC.maxElement()!
let sum = ABC.reduce(0){max+$0-$1}
print(sum%2>0 ?sum/2+2:sum/2)
//  [swift]
let x=readLine()!.characters.split(" ").map{Int(String($0))!}.sort(),y=2*x[2]-x[0]-x[1];print(y/2+(y%2>0 ?2:0))
//  [swift]
let ABC = readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
let sum = 2*ABC[2]-ABC[0]-ABC[1]
print(sum/2+(sum%2>0 ?2:0))
//  [swift]
let ABC = readLine()!.chracters.split(" ").map{Int(String($0))!}
let max = ABC.maxElement()!
let sum = ABC.reduce(0){max+$0-$1}
print(sum%2>0 ?sum/2+2:sum/2)
//  [typescript]
function main(input) {
  const [a, b, c] = input.trim().split(" ").map(n => Number(n));
  const max = Math.max(...[a, b, c]);
  let target = max;
  if (3*max % 2 !== (a+b+c)%2) {
    target++;
  }
  const result = (target*3 - (a+b+c))/2;
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const s = [a, b, c].sort((a, b) => b - a)

const max = s[0]

const diff = s[0] - s[1] + s[0] - s[2]

const res = _ => {
  let count = Math.ceil(diff / 2)

  if (diff % 2 !== 0) count++

  return count
}

console.log(res())
//  [typescript]
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);
let inputNum = input.map(mp => +mp);
inputNum.sort((a,b) => b - a);
const diff1 = inputNum[0] - inputNum[1];
let changedMin = inputNum[2] + diff1;
const diff2  = Math.ceil((inputNum[0] - changedMin)/2);
const diff3 = inputNum[2] + diff1 + (diff2*2) === inputNum[0] ? 0 : 1;
console.log(diff1 + diff2 + diff3);
//  [typescript]
function main(input) {
  const [a, b, c] = input.trim().map(n => Number(n));
  const max = Math.max(...[a, b, c]);
  let target = max;
  if (3*max % 2 !== (a+b+c)%2) {
    target++;
  }
  const result = (target*3 - (a+b+c))/2;
  console.log(reuslt);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function Main(input) {
    input = input.split(' ');
    let A = Number(input[0]);
    let B = Number(input[1]);
    let C = Number(input[2]);

    let ans = 0;

    while (!(A == B && B == C)) {
        const max = Math.max(A, B, C);
        const ave = (A + B + C) / 3;

        if (Math.abs(max - ave) < 1.4) {
            switch (max) {
                case A:
                    B++; C++;
                    break;
                case B:
                    A++; C++;
                    break;
                case C:
                    A++; B++;
                    break;
            }
            ans++;
        }
        else {
            const min = Math.min(A, B, C);
            switch (min) {
                case A:
                    A += 2;
                    break;
                case B:
                    B += 2;
                    break;
                case C:
                    C += 2;
                    break;
            }
            ans++;
        }
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function Main(input) {
    input = input.split(' ');
    let A = Number(input[0]);
    let B = Number(input[1]);
    let C = Number(input[2]);

    let ans = 0;

    while (!(A == B && B == C)) {
        const max = Math.max(A, B, C);
        const ave = (A + B + C) / 3;

        if (Math.abs(max - ave) < 1.5) {
            switch (max) {
                case A:
                    B++; C++;
                    break;
                case B:
                    A++; C++;
                    break;
                case C:
                    A++; B++;
                    break;
            }
            ans++;
        }
        else {
            const min = Math.min(A, B, C);
            switch (min) {
                case A:
                    A += 2;
                    break;
                case B:
                    B += 2;
                    break;
                case C:
                    C += 2;
                    break;
            }
            ans++;
        }
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
x = int(input())
if x == 1:
    ans = 0
else:
    ans = 1
print(ans)
//  [python]
x = int(input())
if x == 1:
    print(0)
else:
    print(1)
//  [python]
x = int(input())

result = 0 if x == 1 else 1

print(result)
//  [python]
x = int(input())
if x == 0:
  print(1)
elif x == 1:
  print(0)
else:
  break
//  [python]
x = int(input())
print(0 if x == 1 else 0)
//  [python]
import sys

a = sys.argv[1]

print(f'{1 - a}')
//  [java]
import java.io.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    if(n==0)
      System.out.println("1");
    else
      System.out.println("0");
  }
}
//  [java]
import java.util.Scanner;

public class ProductMax {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextInt();
        long b = scan.nextInt();
        long c = scan.nextInt();
        long d = scan.nextInt();
        scan.close();
        long max = a * c;
        
        max = Math.max(max, a * d);
        max = Math.max(max, b * c);
        max = Math.max(max, b * d);

        System.out.println(max);
    }
    
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        scan.close();
        int max = a * c;
        for(int i = a; i <= b; i++){
            for(int j = c; j <= d; j++){
                if(i*j > max){
                    max = i*j;
                }
            }   
        }
        System.out.println(max);
    }
    
}
//  [java]
import java.util.*;

public class Main {
    public void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        if (x != 1) {
            System.out.println(0);
        } else if (x == 1) {
            System.out.println(1);
        }
    }

}
//  [cpp]
#include<stdio.h>
int main()
{
	int x;
	scanf("%d",&x);
	if(x==0)printf("1");
	else printf("0");
}
//  [cpp]


#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  cout<<(!n)<<'\n';
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << 1 - n;
    return 0;
}
//  [cpp]
#include <iostream>

int i;
cin >> i;
if (i == 0) {
    count << "1";
} else {
    count << "0";
}
//  [cpp]
#include <bits/stdc++.h>

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll x;
  cin >> x;
  cout << !x << endl;
}
//  [c]
#include <stdio.h>

int main(){
  int a;
  scanf("%d",&a);
  if(a==1) puts("0");
  else puts("1");
}
//  [c]
#include <stdio.h>

int main ()
{
	int n;

	scanf ("%d", &n);

	if (n == 0) printf ("1");
	if (n == 1) printf ("0");

	return 0;
}
//  [c]
#include<stdio.h>

int main ()
{
    int x;

    scanf("%d",&x);

    if(x==1)
        printf("0");

    else if(x==0)
        printf("1");

    return 0;
}
//  [c]
#include "bits/stdc++.h"
using namespace std;
#define ll long long
int main() {
	int x; cin >> x;
	if (x == 0) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}
//  [c]
#include <stdio.h>

int main(int argc, char *argv[])
{
int a;
int b;
int c;
int d;
int max;
int ret;
/* a<= x <= b, c<=y<=d */
ret=scanf("%d %d %d %d", &a,&b,&c,&d);

max = a*c;
if(max < a*d) max=a*d;
if(max < b*c) max=b*c;
if(max < b*d) max=b*d;
printf("%d", max);

}
//  [c]
#include <stdio.h>
 
int main(int argc, char *argv[])
{
int x;
scanf("%d", &x);
if(x==0) printf("1");
else print("0");
}
//  [javascript]
function Main(input){
if(parseInt(input) === 1){
  console.log(0)
}
else if (parseInt(input) === 0){
  console.log(1)
}
else {console.log(null)}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use script';

{
function Main(input) {

	const x = parseInt(input[0], 10);
  	let y = Math.abs(x-1);

	console.log(y);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

}
//  [javascript]
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    
    let x = Number(input[0]);
    if(x) console.log(0);
    else console.log(1);
    
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  const out = input == '0'? '1' : '0';
  console.log(out);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use script';

{
function Main(input) {
	//input = input.split("\n");
	tmp = input.split(" ");
	const a = parseInt(tmp[0], 10);
	const b = parseInt(tmp[1], 10);
	const c = parseInt(tmp[2], 10);
	const d = parseInt(tmp[3], 10);

  	let max = a*c;
  
	if(max < a*d){
      max = a*d;
    }
	if(max < b*c){
      max = b*c;
    }
  	if(max < b*d){
      max = b*d;
    }
  
  	console.log(max);
  
	}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

}
//  [javascript]
function main(input) {
  const x = parseInt(input);
  // この下の行から
  if(x=0){console.log("1");}else if(x=1){
    console.log("0");}

  // この上の行まででプログラムを書く
};
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [go]
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	if x == 1 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}
//  [go]
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	if x == 0 {
		x = 1
	} else {
		x = 0
	}
	fmt.Println(x)
}
//  [go]
package main

import (
	"fmt"
)


func main() {
	var x int
	fmt.Scan(&x)

	if x == 1 {
		fmt.Println(0)

		return
	}
	fmt.Println(1)

}
//  [go]
var a int
fmt.Scan(&a)

if a == 0 {
  fmt.Println(1)
} else if a == 1 {
  fmt.Println(0)
} else {
  
}
//  [go]
package main

import "fmt"

func main() {
	var a int
	fmt.Scan(a)
	if a == 1 {
		fmt.Println("0")
	} else if a == 0 {
		fmt.Println("1")
	}

}
//  [go]
package main

import "fmt"

func main() {
	var a int
	fmt.Scan(a)
	if a == 1 {
		fmt.Println("0")
	} else {
		fmt.Println("1")
	}

}
//  [ruby]
I = gets.to_i

puts I == 1 ? 0 : 1
//  [ruby]
x = gets.to_i

if x == 0
  puts 1
elsif x == 1
  puts 0
end
//  [ruby]
x = gets.to_i
puts 1 - x
//  [ruby]
n = gets.to_i

mod = 10**9 + 7

ans = 10.pow(n, mod)
ans -= 9.pow(n, mod) * 2
ans += 8.pow(n, mod)
puts ans % mod
//  [ruby]
n = gets.to_i

mod = 10**9 + 7

ans = 10.pow(n, mod)
ans -= 9.pow(n, mod) * 2
ans += 8.pow(n, mod)
puts ans / mod
//  [ruby]
std = gets
if std == 0 then
  printf("1")
elseif std == 1 then
 printf("0")
end
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {x: usize};

    if x == 1 {
        println!("0")
    } else {
        println!("1")
    }
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        x: i32,
    }

    let ans = if x == 0 { 1 } else { 0 };
    println!("{}", ans);
}
//  [rust]
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        x: usize
    }
    if x == 1 {
        println!("0");
        return;
    }
    println!("1");
}
//  [rust]
use std :: io ;
fn main(){
 loop{  
    let mut no = String::new();

  io :: stdin()
    .read_line(&mut no)
    .expect("failed to read line ");

 let no : i32 = no.trim().parse().expect("error!");

if no == 0 {
    println!("1");
 } else if no == 1 {
        println!("0");
    }else {
        println!("...");
    }
}
}
//  [rust]
use std::io;
use std::str::FromStr;
 
fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (n, m, l, k) = (it.next().unwrap(), it.next().unwrap(),
        it.next().unwrap(), it.next().unwrap());
    let mut v = Vec::new();
    v.push(n * l);
  v.push(n * k);
  v.push(m * l);
  v.push(m * k);
  if let Some(num) = v.iter().max() {
    	println!("{}", num);
  }
}
//  [swift]
print(readLine()! == "0" ? "1" : "0")
//  [swift]
let x = readLine()!
print(x == "0" ? "1" : "0")
//  [swift]
func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func mainA() {
    let x = readInt()
    print(x == 0 ? 1 : 0)
}
mainA()
//  [swift]

let n = Int(readLine()!)!
let devider = 1000_000_000 + 7

func powerOfTwo(num: Int, multiply: Int) -> Int {
    var result = 1
    for _ in 0..<num {
        result = (result * multiply) % devider
    }
    return result
}

let universe = powerOfTwo(num: n, multiply: 10)
let nWithoutZero = powerOfTwo(num: n, multiply: 9)
let nWithoutNine = powerOfTwo(num: n, multiply: 9)
let nWIthoutZeroAndNine = powerOfTwo(num: n, multiply: 8)

if n == 1 {
    print(0)
} else {
    let ans = (universe - nWithoutZero - nWithoutNine + nWIthoutZeroAndNine) % devider
    print(ans > 0 ? ans : (ans+devider) % devider)
}
//  [swift]

let n = Int(readLine()!)!
let devider = 1000_000_000 + 7

func powerOfTwo(num: Int, multiply: Int) -> Int {
    var result = 1
    for _ in 0..<num {
        result = (result * multiply) % devider
    }
    return result
}

let universe = powerOfTwo(num: n, multiply: 10)
let nWithoutZero = powerOfTwo(num: n, multiply: 9)
let nWithoutNine = powerOfTwo(num: n, multiply: 9)
let nWIthoutZeroAndNine = powerOfTwo(num: n, multiply: 8)

if n == 1 {
    print(0)
} else {
    var ans = (universe - nWithoutZero - nWithoutNine + nWIthoutZeroAndNine) % devider
    ans = (ans + devider) % devider
    print(ans)
}
//  [swift]

let n = Int(readLine()!)!
let devider = 1000_000_000 + 7

func powerOfTwo(num: Int, multiply: Int) -> Int {
    var result = 1
    for _ in 0..<num {
        result = (result * multiply) % devider
    }
    return result
}

let universe = powerOfTwo(num: n, multiply: 10)
let nWithoutZero = powerOfTwo(num: n, multiply: 9)
let nWithoutNine = powerOfTwo(num: n, multiply: 9)
let nWIthoutZeroAndNine = powerOfTwo(num: n, multiply: 8)

if n == 1 {
    print(0)
} else {
    var ans = universe - nWithoutZero - nWithoutNine + nWIthoutZeroAndNine % devider
    ans = (ans + devider) % devider
    print(ans)
}
//  [typescript]
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, bCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
type NumberOrBigintOrElse<T> = number | bigint extends T
  ? undefined
  : T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.max(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.min(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T extends number | bigint>(t: T) =>
  (isNumber(t)
    ? Math.abs(t)
    : isBigint(t)
    ? t >= 0n
      ? t
      : -t
    : undefined) as NumberOrBigintOrElse<T>;

/**
 * Program
 */
const getAns = (n: number): number => (n === 0 ? 1 : 0);

{
  const x = nCin();
  const ans = getAns(x);
  console.log(ans);
}
//  [typescript]
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);

console.log(input[0] === '1' ? '0' : '1');
//  [typescript]
var main = (input: string) => {
    if (input.trim() === '0') {
        console.log('1');
    } else {
        console.log('0');
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const isZero = (x: number) => x === 0 ? x : 1;

const  main = (standardInput) => {
  const  lengthList: string[] = standardInput.split(' ');
  const x: number = Number.parseInt(lengthList[0]);
  console.log(isZero(x))
  	
}
 
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
//  [typescript]
const someNumber: number = Math.random(0,1)

if(number === 0) {
  console.log(1)
} else if (number === 1) {
  console.log(0)
}
//  [typescript]
var main = (input: string) => {
    if (input === '0') {
        console.log('1');
    } else {
        console.log('0');
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n-2):
  target = p[i:i+3]
  target_s = sorted(target)
  if  target_s[1]== target[1]:
    count += 1
print(count)
//  [python]
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
    t = p[i: i + 3]
    t.sort()
    if t.index(p[i + 1]) == 1:
        ans += 1
print(ans)
//  [python]
n=int(input())
p=list(map(int, input().split()))
cnt=0
for i in range (n):
    if i == 0:
        continue
    if i == n - 1:
        break
    if p[i-1] <= p[i] and p[i] <= p[i+1] or p[i+1] <= p[i] and p[i] <= p[i-1]:
        cnt+=1

print(cnt)
//  [python]
n = int(input())
p = list(map(int, input().split()))
s = 0
for i in range(n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
        s += 1
print(s)
//  [python]
permutation_number = int(input())
permutation_value = list(map(int, input().split()))
condition_permutation = 0
for i in range(permutation_number - 1):
    if permutation_value[i - 1] < permutation_value[i] < permutation_value[i + 1] or permutation_value[i - 1] > permutation_value[i] > permutation_value[i + 1]:
        condition_permutation += 1
print(condition_permutation)
//  [python]
#ABC132 B

n = int(input())
K = 0
for i in range(n-2):
    if (P[i]<P[i+1] and P[i+1] < P[i+2]) or (P[i+2]<P[i+1] and P[i+1]<P[i]):
        K += 1
        
print(K)
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int n = sc.nextInt();
		int[] ary = new int[n];
		for (int i = 0; i < n; i++) {
			ary[i] = sc.nextInt();
		}
		int cnt = 0;
		for (int i = 0; i < n - 2; i++) {
			int p1 = ary[i];
			int p2 = ary[i + 1];
			int p3 = ary[i + 2];
			if ((p1 < p2 && p2 < p3) || (p3 < p2 && p2 < p1)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int n = reader.nextInt();
        int[] P = new int[n];
        for (int i=0; i<n; i++) P[i] = reader.nextInt();
        int ans = 0;
        for (int i=1; i<n-1; i++) {
            if (P[i-1]<P[i] && P[i]<P[i+1]) ans++;
            if (P[i-1]>P[i] && P[i]>P[i+1]) ans++;
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int result = 0;

		String str[] = br.readLine().split(" ");
		int list[] = new int[n];

		for (int i = 0; i < n; i++) {
			list[i] = Integer.parseInt(str[i]);
		}

		for (int i = 1; i < n - 1; i++) {
			if (list[i - 1] < list[i] && list[i] < list[i + 1]) {
				result++;
			} else if (list[i - 1] > list[i] && list[i] > list[i + 1]) {
				result++;
			}
		}
		System.out.println(result);
	}
}
//  [java]
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		  int N = nextInt();
		  ArrayList<Integer> list = nextIntArray();
		  int count = 0;
		  for(int i = 1; i < N - 1; i++){
		    if((list.get(i - 1) < list.get(i) && list.get(i) < list.get(i + 1)) || (list.get(i - 1) > list.get(i) && list.get(i) > list.get(i + 1)){
		      count++;
		    }
		  }
		  myout(count);
	}
	//Method addition frame start




	//Method addition frame end
}
//  [java]
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();    	
      	int[] a = new int[n];
      	int mid = 0;
      	int count = 1;
        for(int i = 0; i < a.length; ++i){
          a[i] = sc.nextInt();
        } 
        for(int i = 0; i <(n-1); i++){
            mid = a[(i+1)];
            if(mid > a[i] && mid < a[(i+2)]){
            count += 1; 
            }if(mid < a[i] && mid > a[(i+2)]){
            count += 1; 
            }
        }
       
      System.out.println(count);
    }
}
//  [java]
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();    	
      	int[] p = new int[n];
      	int mid = 0;
      	int count = 1;
        for(int i = 0; i < a.length; ++i){
          p[i] = sc.nextInt();
        } 
        for(int i = 0; i <(n-2); i++){
            mid = p[(i+1)];
            if(mid > p[i] && mid < p[(i+2)]){
            count += 1; 
            }if(mid < p[i] && mid > p[(i+2)]){
            count += 1; 
            }
        }
       
      System.out.println(count);
    }
}