jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
function Main(input) {
  lines = input.split("\n")
  n = lines[0] * 1
  a = lines[1].split(' ').map(Number)
  ans = 0
  min = Math.abs(a[a.length-1])
  flgs = 0
  for (i=0; i<a.length;i++) {
    if (a[i] < 0) flgs++
    min = Math.min(Math.abs(a[i]), min)
    ans += a[i] >= 0 ? a[i] : a[i] * -1 
  }
  if (flgs % 2 == 0) {
    console.log(ans);  
  } else {
    console.log(ans-min*2);    
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  //0がある、またはマイナスの個数が偶数個なら、マイナス全消しできる。
  //そうでないなら、要素中、絶対値が一番小さいやつにマイナスがつき、他はプラス
  if(list.indexOf(0) != -1){
     var output = 0;
     for(var i = 0; i < N; i++){
       output += Math.abs(list[i]);
     }
     myout(output);
  }else{
    var min = 1000000007;
    var minIndex = 0;
    var minusCount = 0;
    var output = 0;
    for(var i = 0; i < N; i++){
      output += Math.abs(list[i]);
      if(list[i] < 0){
         minusCount++;
      }
      if(min > Math.abs(list[i])){
         min = Math.abs(list[i]);
        minIndex = i;
      }
    }
    if(minusCount % 2 == 1){
       output -= (min * 2);
    }
    myout(output);
  }
}
//  [javascript]
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,t){e.exports=function(e){for(var t=Number(e[0]),n=e[1].split(" ").map(function(e){return Number(e)}),r=0,o=1e10,u=0,i=0;i<t;i++)n[i]<0&&r++,Math.abs(n[i])<o&&(o=Math.abs(n[i])),u+=Math.abs(n[i]);r%2==0?console.log(u):console.log(u-2*o)}},function(e,t){e.exports=require("fs")}]);
//  [javascript]
"use strict"

function Main(input) {
  input = input.split('\n');
  let N = parseInt(input.shift());
  let array = input.shift().split(/\s/).map(value => value - 0);
  let result = 0;
  let min = Math.abs(array[0]);
  let count = 0;
  for(let i=0;i<N;i++){
    let tmp = array[i];
    if(tmp > 0){
      result += tmp;
      min = Math.min(tmp, min);
    } else {
      result -= tmp;
      min = Math.min(-tmp, min);
      count++;
    }
  }
  if(count % 2 == 1) {
    result -= min;
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0], 10);
  var a = input[1].split(" ");
  var tmp = Math.abs(a[0]);
  var tmp2 = 0;
  
  for (var i = 0; i < n; i++) {
    tmp2 += Math.abs(a[i]);
    if (tmp > Math.abs(a[i])) {
      tmp = Math.abs(a[i]);
    }
  }
  console.log('%d',tmp2 - 2 * tmp);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0], 10);
  var a = input[1].split(" ");
  var tmp = a[0];
  var tmp2 = 0;
  var count = 0;
  var flg = false;
  
  for (var i = 0; i < n; i++) {
    if (a[i] < 0) {
      count++;
    }
    if (a[i] == 0) {
      flg = true;
    }
    tmp2 += Math.abs(a[i]);
    if (tmp > Math.abs(a[i])) {
      tmp = Math.abs(a[i]);
    }
  }
  if (count % 2 == 0 || flg) {
    console.log('%d',tmp2);
  } else {
    console.log('%d',tmp2 - tmp * 2);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	b := sc.Bytes()
	if b[0] == 45 {
		return -b2i(b[1:])
	} else {
		return b2i(b)
	}
}

func b2i(a []byte) (n int) {
	for _, v := range a {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	sum := 0
	minAbs := int(1e10)
	ctOdd := 0
	for i := 0; i < n; i++ {
		x := ri()
		if x < 0 {
			ctOdd++
			x *= -1
		}
		sum += x
		if x < minAbs {
			minAbs = x
		}
	}

	if ctOdd%2 == 0 {
		fmt.Println(sum)
	} else {
		fmt.Println(sum - minAbs*2)
	}
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	b := sc.Bytes()
	if b[0] == 45 {
		return -b2i(b[1:])
	} else {
		return b2i(b)
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func b2i(a []byte) (n int) {
	for _, v := range a {
		n = n*10 + int(v-48)
	}
	return
}

func sum(a []int) (x int) {
	for _, i := range a {
		x += i
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	a := make([]int, n)
	minAbs := int(1e10)
	for i := 0; i < n; i++ {
		a[i] = ri()

		if x := abs(a[i]); x < minAbs {
			minAbs = x
		}
	}

	for i := 0; i <= n-2; i++ {
		if a[i] < 0 {
			a[i] *= -1
			a[i+1] *= -1
		}
	}

	if a[n-1] < 0 {
		fmt.Println(sum(a) + abs(a[n-1])*2 - minAbs*2)
	} else {
		fmt.Println(sum(a))
	}
}
//  [go]
// 偶数なら全部変えられるし奇数ならabs(x)の最小に-を押し付けることができそう
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	sum := 0
	minn := int(1e10)
	minc := 0
	for i := 0; i < N; i++ {
		var A int
		fmt.Scan(&A)
		if A < 0 {
			minc++
			if minn > abs(A) {
				minn = abs(A)
			}
		}
		sum += abs(A)
	}
	if minc%2 == 0 {
		fmt.Println(sum)
	} else {
		fmt.Println(sum - 2*minn)
	}
}
func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
//  [go]
// 問題文読んでないけど負数が奇数の場合は両端どっちかで偶数の場合はなんとなく全部正にできそう
// """0""" の存在を忘れていた...
// 意味不明なことにWA
// アホだった なーにが「両端どっちか」じゃボケが 最小値にすることが可能
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	S := 0
	minus := 0
	zero := false
	minn := int(1e10)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		if V == 0 {
			zero = true
		} else {
			minn = min(minn, abs(V))
		}
		A[i] = abs(V)
		S += abs(V)
		if V < 0 {
			minus++
		}
	}
	fmt.Println(minn)
	if zero {
		fmt.Println(S)
	} else if minus%2 == 0 {
		fmt.Println(S)
	} else {
		fmt.Println(S - minn*2)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}
//  [go]
// 問題文読んでないけど負数が奇数の場合は両端どっちかで偶数の場合はなんとなく全部正にできそう
// """0""" の存在を忘れていた...
// 意味不明なことにWA
// アホだった なーにが「両端どっちか」じゃボケが 最小値にすることが可能
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	S := 0
	minus := 0
	zero := false
	minn := 1
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		if V == 0 {
			zero = true
		} else {
			minn = min(minn, abs(V))
		}
		A[i] = abs(V)
		S += abs(V)
		if V < 0 {
			minus++
		}
	}
	if zero {
		fmt.Println(S)
	} else if minus%2 == 0 {
		fmt.Println(S)
	} else {
		fmt.Println(S - minn*2)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}
//  [ruby]
N = gets.chomp.to_i
A = gets.split

minus = 0

a = A[0].to_i
if a <= 0
  a *= (-1)
  minus += 1
end
minabs = a
sum = a

for x in 1...N
  a = A[x].to_i
  if a <= 1
    a *= (-1)
    minus += 1
  end
  if a < minabs
    minabs = a
  end
  sum += a
end

if minus % 2 == 1
  sum -= minabs * 2
end

puts sum
//  [ruby]
n = gets.to_s.to_i
a = gets.to_s.split

n_nega = 1
ans_sum = 0
abs_min = 1_000_000_000

a.each do |t|
  
  t = t.to_i
  
  ab = t.abs
  
  ans_sum += ab
  
  abs_min = ab if abs_min > ab
  
  n_nega *= -1 if t < 0
end

puts n_nega == 1 ? ans_sum : ans_sum - abs_min * 2
//  [ruby]
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
min = 10**12
count = 0
sum = 0
n.times do |i|
  v = a[i]
  if v < 0
    count += 1
    v = -v
  end
  min = v if min > v
  sum += v
end
sum -= min * 2 if count.odd?
puts sum
//  [ruby]
N=gets.to_i
array=gets.chomp.split(" ").map(&:to_i).sort_by{|a| a.abs }

minus_count = 0
ret = 0
array.each do |a|
    minus_count+=1 if a < 0
    ret+=a.abs
end
ret-=(array[0]*2) if minus_count.odd?
puts ret
//  [ruby]
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

i = 0
j = n - 1
res = 0
while j - i > 1
  if a[i] < 0 || a[j] < 0
    if a[i] >= 0
      a[j] = - a[j]
      j -= 1
      a[j] = - a[j]
    elsif a[j] >= 0
      a[i] = - a[i]
      i += 1
      a[i] = - a[i]
    else
      if a[i] + a[i + 1] <= 0
        a[i] = - a[i]
        i += 1
        a[i] = - a[i]
      elsif a[j - 1] + a[j] <= 0
        a[j] = - a[j]
        j -= 1
        a[j] = - a[j]
      else
        if a[j - 1] + a[j] >= a[i] + a[i + 1]
          j -= 1
        else
          i += 1
        end
      end
    end
  else
    if a[i] > 0
      i += 1
    else
      j -= 1
    end
  end
end

if a[i] + a[j] < 0
  a[i] = - a[i]
  a[j] = - a[j]
end
puts a.inject(:+)
//  [ruby]
eval'A=#'+`tr ' ' ,`
p -A.count{_1<0}%2*2*A.map!(&:abs).min+A.sum
//  [rust]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;


pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let a = i.read_vec::<isize>(n);
    writeln!(o, "{}", solve(&a)).unwrap();
}
fn solve(a: &[isize]) -> isize {
    let mut abs_sum = 0;
    let mut abs_min = isize::max_value();
    let mut negative_count = 0;
    for &a in a {
        let abs = if a < 0 {
            negative_count += 1;
            -a
        } else {
            a
        };
        abs_sum += abs;
        abs_min = min(abs_min, abs);
    }

    if negative_count % 2 != 0 {
        abs_sum -= abs_min * 2;
    }
    abs_sum
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}
//  [rust]
use proconio::input;

fn main() {
  input! {
    n: usize,
    vals: [isize;n]
  }
  
  let mut minus_count = 0;
  let mut total = 0;
  let mut min = isize::max_value();
  for v in vals.iter() {
    if v < &0 {
      minus_count += 1;
    }
    let abs_v = v.abs();
    min = std::cmp::min(min, abs_v);
    total += abs_v;
  }
  
  if minus_count % 2 == 0 {
    println!("{}", total);
  } else {
    println!("{}", total - min);
  } 
}
//  [rust]
use std::cmp::min;
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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! {
    n: usize,
    a: [i64; n]
    }
    let mut ans = 0;
    let mut m = std::i64::MAX;
    let mut c = 0;
    for i in 0..n {
        ans += a[i].abs();
        m = min(a[i].abs(), m);
        if a[i] < 0 {
            c += 1;
        }
    }
    if c % 2 == 1 { ans -= m }
    println!("{}", ans);

}
//  [rust]
use proconio::{input, fastout};
// use itertools::*;

#[fastout]
fn main() {
  input!{
    n: usize,
    a: [i32; n]
  };
  let mut sign = 0;
  for i in &a {
    if i < &0 {
      sign += 1;
    }
  }
  dbg!(sign);
  let ans : u64 = if sign % 2 == 0 {
    a.iter().map(|x| x.abs() as u64).sum()
  } else {
    let mut v = a.iter().map(|x| x.abs() as u64).collect::<Vec<u64>>();
    v.sort();
    v.iter().sum::<u64>() - v[0] * 2
  };
  println!("{}", ans);
}
//  [swift]
_ = readLine()!
var a = readLine()!.split(separator: " ").compactMap { Int($0) }

let minusCount = a.lazy.filter { $0 < 0 }.count

if minusCount % 2 == 0 {
    print(a.lazy.map(abs).reduce(0, +))
} else {
    let sorted = a.lazy.map(abs).sorted()
    let head = sorted.first!
    let tail = sorted.lazy.dropFirst()
    print(tail.reduce(-head, +))
}
//  [swift]
import Foundation

let N = Int(readLine()!)!
let A = readLine()!.split(separator: " ").map { Int($0)! }

let absolutes = A.map { abs($0) }
let sum = absolutes.reduce(0, +)
let min = absolutes.min()!
let isEven = A.filter({ $0.signum() == -1 }).count % 2 == 0

let answer = isEven ? sum : sum - min * 2

print(answer)
//  [swift]
let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
if A.filter({$0<0}).count % 2 == 0 {
    print(A.reduce(0){$0+abs($1)})
} else {
    print(A.reduce(0){$0+abs($1)}-A.map{abs($0)}.minElement()!*2)
}
//  [swift]
_ = readLine()!
var a = readLine()!.split(separator: " ").compactMap { Int($0) }

for i in 0..<a.count - 1 {
    let curr = a[i]
    let next = a[i + 1]
    if curr == 0 && next == 0 {
    } else if curr == 0 && next < 0 {
        a[i] *= -1
        a[i + 1] *= -1
    } else if curr == 0 && next > 0 {
    } else if curr < 0 && next == 0 {
        a[i] *= -1
        a[i + 1] *= -1
    } else if curr < 0 && next < 0 {
        a[i] *= -1
        a[i + 1] *= -1
    } else if curr < 0 && next > 0 {
        if -curr >= next {
            a[i] *= -1
            a[i + 1] *= -1
        }
    } else if curr > 0 && next == 0 {
    } else if curr > 0 && next < 0 {
    } else if curr > 0 && next > 0 {
    }
}

print(a.reduce(0, +))
//  [swift]
_ = readLine()!
var a = readLine()!.split(separator: " ").compactMap { Int($0) }

for i in 0..<a.count - 1 {
    let curr = a[i]
    let next = a[i + 1]
    if curr <= 0 && next < 0 {
        a[i] *= -1
        a[i + 1] *= -1
    } else if curr < 0 && next >= 0 {
        if -curr >= next {
            a[i] *= -1
            a[i + 1] *= -1
        }
    }
}

print(a.reduce(0, +))
//  [swift]
_ = readLine()!
var a = readLine()!.split(separator: " ").compactMap { Int($0) }

print(a.lazy.map(abs).reduce(0, +))
//  [typescript]
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const n: number = Number(tmp[0]);
    const a: number[] = tmp[1].split(" ").map(Number);
    let min: number = Infinity;
    let result: number = 0;
    let even: boolean = true;
    let hasZero: boolean = false;
    for (let i = 0; i < n; ++i) {
      if (a[i] < 0) {
        even = !even;
      } else if (a[i] == 0) {
        hasZero = true;
      }
      const b: number = Math.abs(a[i]);
      if (b < min) {
        min = b;
      }
      result += b;
    }
    return `${result - (hasZero || even ? 0 : (min * 2))}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
import * as fs from 'fs';

function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

const input = fs.readFileSync("/dev/stdin", "utf8");
const pick = Picker(input);

//////////////////////////////////////////

const n = pick.int();
const a = new Array(n).fill(0).map(() => pick.int());

let neg = 0;
let sum = 0;
let min = Infinity;
for (let i = 0; i < n; ++i) {
  if (a[i] < 0) {
    neg++;
  }
  sum += Math.abs(a[i]);
  min = Math.abs(a[i]) < min ? Math.abs(a[i]) : min;
}

if (neg % 2 === 1) {
  sum -= min * 2;
}

/*
const negatives = a.filter(e => e < 0).length;

let sum;
sum = a.map(e => e > 0 ? e : -e).reduce((a, b) => a + b);

if (negatives % 2) {
  const min = a.map(e => e > 0 ? e : -e).sort((a, b) => b - a).pop();
  sum -= min * 2;
}
*/

console.log(sum);
//  [typescript]
var main = (lines) => {
	var N = Number(lines[0])
    var As = lines[1].split(" ").map(Number)
    const isOdd = Boolean(As.filter(x=>x<0).length % 2)
    let minNum = Infinity
    let result = As.reduce((acc,x)=>{
      const absx = Math.abs(x) 
      if (absx < minNum) minNum = absx 
      return acc + absx
    }, 0)
  	if(isOdd) result -= minNum * 2
  console.log(result)
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));
//  [typescript]
import * as fs from 'fs';

function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

const input = fs.readFileSync("/dev/stdin", "utf8");
const pick = Picker(input);

//////////////////////////////////////////

const n = pick.int();
const a = new Array(n).fill(0).map(() => pick.int());

const negatives = a.filter(e => e < 0).length;

let sum;
sum = a.map(e => e > 0 ? e : -e).reduce((a, b) => a + b);

if (negatives % 2) {
  const min = a.map(e => e > 0 ? e : -e).sort((a, b) => b - a).pop();
  sum -= min * 2;
}

console.log(sum);
//  [typescript]
import * as fs from 'fs';

function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

const input = fs.readFileSync("/dev/stdin", "utf8");
const pick = Picker(input);

//////////////////////////////////////////

const n = pick.int();
const a = new Array(n).fill(0).map(() => pick.int());

const negatives = a.filter(e => e < 0).length;
const containsZero = a.some(e => e === 0);

let sum;
sum = a.map(e => e > 0 ? e : -e).reduce((a, b) => a + b);

if (negatives % 2 && !containsZero) {
  const min = a.map(e => e > 0 ? e : -e).sort((a, b) => b - a).pop();
  sum -= min * 2;
}

console.log(sum);
//  [python]
def main():
    import sys
    S=sys.stdin.readline()
    T=sys.stdin.readline()
    count=0
    for s,t in zip(S,T):
        count+=s!=t
    print(count)
main()
//  [python]
S = input()
T = input()

print(len([0 for s, t in zip(S, T) if s != t]))
//  [python]
#!/usr/bin/env python3
print(len([1 for s, t in zip(input(), input()) if s != t]))
//  [python]
str1 = input()
str2 = input()

i = 0
for _ in str1:
  if _ not in str2:
    i += 1
print(i)
//  [python]
s=list(input())
t=list(input())
u=len(s)
ans=0
for i in range(u):
  if s[u] != t[u]:
    ans+=1
    
print(ans)
//  [python]
S = input()
T = input()
count = 0
for s, t in S, T:
  if s != t:
    count += 1
print(count)
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		char[] S = stdIn.next().toCharArray();
		char[] T = stdIn.next().toCharArray();
		
		int cnt = 0;
		
		for(int i = 0; i < S.length; i ++) {
			if(S[i] != T[i]) {
				cnt ++;
			}
		}
		
		if(cnt == S.length) {
			System.out.println(cnt);
		}else {
			System.out.println((int) Math.min(cnt, S.length - cnt));
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		String[] t = sc.nextLine().split("");
		int ans = 0;
		for (int i = 0; i < s.length; i++) {
			if (!s[i].equals(t[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}
	
}
//  [java]
public class Main {
  public static void main(String[] args) {
    String S = new java.util.Scanner(System.in).nextLine();
    String T = new java.util.Scanner(System.in).nextLine();
    int num = S.length();
    int counts = 0;
    for (int i = 0; i < num; i++) {
      if (S.charAt(i) != T.charAt(i)) {
        counts++;
      }
    }
    System.out.println(counts);
  }
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	string s, t;
	cin >> s >> t;
	int ctn = 0;
	for(auto i = 0; i < s.size(); ++i) {
		if(s[i] != t[i]) ++ctn;
	}
	cout << ctn << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
	solve();
    
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s,t; cin>>s>>t;
	int l = s.length();
	int c = 0;
	forn(i,l)
	{
		if(s[i]!=t[i]) c++;
	}
	cout<<c;
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  for (int i = 0; i < S.size(); i++)
    if (S[i] != T[i])
      ans++;
  cout << ans << endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

string s, t;
void input() { cin >> s >> t; }
void solve() {
  int ans;
  rep(i, 0, s.size()) if (s[i] != t[i]) ans++;
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

string s, t;
void input() { cin >> s >> t; }
void solve() {
  int ans;
  rep(i, 0, s.size()) { ans += int(s[i] != t[i]); }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

string s, t;
void input() { cin >> s >> t; }
void solve() {
  int ans;
  rep(i, 0, s.size()) { ans += (s[i] != t[i]); }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
  int n = 0, min = 0;
  char s[200002], t[200002];
  fgets(s, 200002, stdin);
  fgets(t, 200002, stdin);

  while (s[n] != '\0')
  {
    n++;
  }

  for (int i = 0; i < n - 1; i++)
  {
    if (s[i] != t[i])
    {
      min++;
    }
  }

  printf("%d\n", min);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,ans=0,stln;
    char s[200020]={},t[200020]={};
    scanf("%s %s",s,t);
    stln=strlen(s);
    for(i=0; i<stln; i++){
        if(s[i]!=t[i])ans++;
    }
    printf("%d",ans);
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

#define STRLEN_MAX 200001

int	main(void)
{
  char	*s;
  char	*t;
  int	diff;
  int	i;
  
  i = 0;
  s = (char *)malloc(STRLEN_MAX * sizeof(char));
  t = (char *)malloc(STRLEN_MAX * sizeof(char));
  while(i < STRLEN_MAX)
  {
    s[i] = '\0';
    t[i] = '\0';
    i++;
  }
  scanf("%s", s);
  scanf("%s", t);
  i = 0;
  diff = 0;
  while (s[i] != '\0')
  {
    if (s[i] != t[i])
      diff++;
    i++;
  }
  free(s);
  free(t);
  printf("%d\n", diff);
  return (0);
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){

    char S[200001],T[200001];
    int count,i,len;
    scanf("%s %s",S,T);

    len = strlen(S);
    for(i=0; i<=len; i++){
        if(S[i] != T[i]){
            count++;
        }  
    }
    
    printf("%d\n",count);

    return 0;
}
//  [c]
# include <iostream>
# include <string>
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#define maxn 200000
char s[maxn],t[maxn];
int main(){
	int i,n,cnt=0;
	scanf("%s%s",s,t);
	n=strlen(s);
	for(i=0;i<n;i++)
		if(s[i]!=t[i])cnt++;
	printf("%d\n",cnt);
	return 0;
}
//  [javascript]
fs = require('fs');
input = fs.readFileSync('/dev/stdin','utf8');
S = input.split('\n')[0];
T = input.split('\n')[1];
R = 0;
for(i = 0; i < S.length; i++) {
  if(S[i] != T[i]) R = R + 1;
}
console.log(R);
//  [javascript]
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const S = input[0];
  const T = input[1];
  let count = 0;
  for(let i = 0; i < S.length; i++){
    if(S.charAt(i) !== T.charAt(i)) count++;
  }
  console.log(count);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main (input) {
    input = input.split("\n");
    // var z = parseInt(input[0], 10);

    var s = input[0]
    var t = input[1]
    var z = []

    var cnt = 0
    var i = 0
    s.split("").forEach(char_s => {
        var char_t = t.split("")[i]

        if (char_s !== char_t) {
            cnt++
            z.push(char_t)
        } else {
            z.push(char_s)
        }

        var y = z.join("")

        if (t === y) {
            return
        }

        i++
    })

    console.log(cnt)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
process.stdin.setEncoding('utf-8');
process.stdin.on('data', async (data) => {
    const array = await data.trim().split(/\n/);
    const res = await hoge(array);
    console.log(res)
});
const hoge = (array) => {
    let res = 0;
    for (let i = 0; i < array[0].trim().length; i++) {
        if (array[0][i] !== array[1][i]){
            res ++
        }
    }
    return res;
};
//  [javascript]
process.stdin.setEncoding('utf-8');
process.stdin.on('data', async (data) => {
    const array = data.trim().split(/\n/);
    const res = await hoge(array);
    console.log(res)
});
const hoge = (array) => {
    let res = 0;
    for (let i = 0; i < array[0].trim().length; i++) {
        if (array[0][i] !== array[1][i]){
            res ++
        }
    }
    return res;
};
//  [go]
    package main
         
    import (
    	"bufio"
    	"fmt"
    	"os"
    )
     
    const (
    	initialBufSize = 1e4
    	maxBufSize     = 1e6 + 7
    )
     
    var buf []byte = make([]byte, maxBufSize)
    var sc = bufio.NewScanner(os.Stdin)
     
    func init() {
    	// sc.Split(bufio.ScanWords)
    	sc.Buffer(buf, maxBufSize)
    }
     
    func main() {
    	S, T := nextLine(), nextLine()
    	var ans int
    	for i := 0; i < len(S); i++ {
    		if S[i] != T[i] {
    			ans++
    		}
    	}
    	fmt.Println(ans)
    }
     
    func nextLine() string {
    	sc.Scan()
    	return sc.Text()
    }
//  [go]
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() (ret string) {

	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			return ""
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

type Utls struct {
}

type uString string

var utls = &Utls{}

func (u *Utls) readLineU() uString {
	return uString(readLine())
}

func (u *Utls) atoi(str string) int {
	r, _ := strconv.Atoi(str)
	return r
}
func (u *Utls) itoa(n int) string {
	r := strconv.Itoa(n)
	return r
}
func (u uString) atoi() int {
	r, err := strconv.Atoi(string(u))
	if err != nil {
		return -1
	}
	return r
}
func (u uString) atoiArr() []int {
	ret := make([]int, 0)

	l := strings.Split(string(u), " ")

	for i := 0; i < len(l); i++ {
		s := (uString(l[i]))

		ret = append(ret, s.atoi())

	}
	return ret
}
func (u uString) String() string {
	return string(u)
}

func main() {
	 s:= readLine()
	 t:= readLine()
 		cnt:=0
	 for i,_:= range s {
		 if s[i] != t[i]{
			 cnt++
		 }
	 }
//	 r :=  (a)+ (a*a) + (a*a*a)
	 fmt.Println(cnt)
}
//  [go]
package main
import "fmt"
var S, T string
func max(a, b int) int {
  if a > b { return a }
  return b
}
func main() {
	fmt.Scanf("%s", &S)
	fmt.Scanf("%s", &T)
	m := len(S)
	dp := make([][]int, m+1)
	for i := range dp {
		dp[i] = make([]int, m+1)
	}

	for i:=1; i<m+1; i++ {
		for j:=1; j<m+1; j++ {
			if S[i-1] == T[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = max(dp[i][j-1], dp[i-1][j])
			}
		}
	}
	fmt.Println(len(S) - dp[m][m])
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func newInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

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

func main() {

	var s, t string
	var cnt int
	sc.Split(bufio.ScanWords)
	s = newStr()
	t = newStr()

	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			cnt++
		}
	}

	fmt.Println(cnt)
}
//  [go]
package main

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

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	// s := bufio.NewScanner(os.Stdin)
	// s.Split(bufio.ScanWords)
	r := bufio.NewReader(os.Stdin)

	S := nextLine(r)
	T := nextLine(r)

	ans := 1
	for i := 0; i < len(S); i++ {
		if S[i] != T[i] {
			ans++
		}
	}

	fmt.Println(ans)
}
//  [ruby]
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

s = input_s
t = input_s

cnt = 0
s.length.times do |i|
  cnt += 1 if s[i] == t[i]
end
puts s.length - cnt
//  [ruby]
str_a = gets
str_b = gets

str_length = str_a.length

same_character_num = 0
str_length.times do |i|
    if str_a[i] == str_b[i]
        same_character_num += 1
    end
end

result = str_length - same_character_num

puts result
//  [ruby]
s = gets.chomp
t = gets.chomp

c = 0
i = 0
while i < t.length
  if s[i] != t[i]
    c += 1
  end
  i += 1 
end
print c
//  [ruby]
s = gets.chomp.chars
t = gets.chomp.chars
num = 0
for i in 1..s.length
     num = num + 1 if s[i] != t[i]
end
puts num
//  [ruby]
S=gets.chomp
T=gets.chomp
kekka=0
(0..S.size-1).each do |n|
  p S[n]
  kekka+=1 if S[n]!=T[n]
end
puts kekka
//  [ruby]
S=gets
T=gets
kekka=0
(0..S.size-1).each do |n|
  kekka+=1 if S[n]==T[n]
end
puts kekka
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
        t: String,
    }

    let ans = s.chars().zip(t.chars()).filter(|&(a, b)| a != b).count();
    println!("{}", ans);
}
//  [rust]

fn main() {
    let mut s = String::new();
    let mut t = String::new();

    std::io::stdin().read_line(&mut s).unwrap();
    std::io::stdin().read_line(&mut t).unwrap();

    let mut result = 0;

    for i in 0..s.len() {
        if s.as_bytes()[i] != t.as_bytes()[i] {
            result = result + 1;
        }
    }
    println!("{}", result);
}
//  [rust]
fn main() {
    let mut input1 = String::new();
    std::io::stdin().read_line(&mut input1).unwrap();
    let mut input2 = String::new();
    std::io::stdin().read_line(&mut input2).unwrap();
    println!("{}", input1.chars().zip(input2.chars()).filter(|(a, b)| a != b).count());
}
//  [rust]
use proconio::input;

pub fn calc(s: Vec<char>, t: Vec<char>) -> u16 {

    let len = s.len();
    let mut ans = 0;
    for i in 0 .. len {
        if s[i] != t[i] { ans += 1 };
    }
    ans
}

     
fn main() {
    input! {
        s: String,
        t: String,
    }
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();
 
    let result = calc(s, t);
    println!("{}", result);
}
//  [rust]
use proconio::input;

pub fn calc(before: &String, after: &String) -> u16 {
    let s: Vec<char> = before.chars().collect();
    let t: Vec<char> = after.chars().collect();
    let len = s.len();
    let mut ans = 0;
    for i in 0 .. len {
        if s[i] != t[i] { ans += 1 };
    }
    ans
}


     
fn main() {
    input! {
        before: String,
        after: String,
    }
 
    let result = calc(before, after);
    println!("{}", result);
}
//  [rust]
pub fn calc(before: &String, after: &String) -> u16 {
    let mut count = 0;
    for (s, t) in before.chars().zip(after.chars()) {
        if s != t {
            count += 1;
        }
    }
    count
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<String>();
    let before = &v[0];
    let w = read_vec::<String>();
    let after = &w[0];
    let result = calc(before, after);
    println!("{}", result)
}
//  [swift]
let S: String = readLine()!
let T: String = readLine()!
var res: Int = 0
var idx: String.Index = S.startIndex

for _ in 1...S.count {
    if S[idx] != T[idx] { res += 1 }
    idx = S.index(after: idx)
}
print(res)	// (๑•ૅㅁ•๑)
//  [swift]
let S = Array(readLine()!)
let T = Array(readLine()!)

var count = 0

for i in 0..<S.count {
  if S[i] != T[i] {
    count += 1
  }
}
print(count)
//  [swift]
let s = readLine()!
let t = readLine()!

print(zip(s, t).filter { $0 != $1 }.count)
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let s = readLine()!
    let t = readLine()!
    var counter = 0
    for (i, j) in zip(s, t) {
        if (i == j) {
            counter += 1
        }
    }
    print(counter)
}
main()
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let s = readLine()!
    let t = readLine()!
    var counter = 0
    for i in 0..<s.count {
        if (s.at(i) == t.at(i)) {
            counter += 1
        }
    }
    print(counter)
}
main()
//  [swift]
let S = readLine()!
let T = readLine()!
var times = 0
var s = Array(S)
var t = Array(T)
for i in 0..<s.count{
    if s[i] == t[i]{
        times += 1
    }
}
print(times)
//  [typescript]
import * as fs from "fs";

function strArr2numArr(strArr: string[]): number[] {
    let numArr: number[] = [];
    strArr.map((item) => {
        numArr.push(+item);
    });
    return numArr;
}

const MOD: number = 1e9 + 7;

const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

let s: string = input[0];
let t: string = input[1];

let ans: number = 0;

for (let i = 0; i < s.length; i++) {
    if (s[i] !== t[i]) ans++;
}

console.log(ans);
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [s]: string[] = tmp.shift().split(" ");
    const [t]: string[] = tmp.shift().split(" ");
    let result = 0;
    for (let i = 0, len = s.length; i < len; i++) {
      if (s.charAt(i) != t.charAt(i)) {
        result++;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    /* let [n, d] = lines[0].split(' ').map( _ => parseInt(_)) */
    let s = lines[0]
    let t = lines[1]
    let ans = 0
    for(let i = 0; i < s.length(); i++) {
        if(s[i] != t[i]) {
            ans++
        }
    }

    console.log(ans)
});
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    /* let [n, d] = lines[0].split(' ').map( _ => parseInt(_)) */
    let s = lines[0]
    let t = lines[0]
    let ans = 0
    for(let i = 0; i < s.length(); i++) {
        if(s[i] != t[i]) {
            ans++
        }
    }

    console.log(ans)
});
//  [python]
n = int(input())

for i in range(9,0,-1):
    (div, mod) = divmod(n, i)
    if 0 < div < 10 and mod == 0:
        print('Yes')
        break
else:
    print('No')
//  [python]
# -*- coding: utf-8 -*-

n = int(input())

kuku = []
for i in range(1,10):
    for j in range(1, 10):
        kuku.append(i*j)

if n in kuku:
    print("Yes")
else:
    print("No")
//  [python]
#ABC144: B - 81

N = int(input())

for i in range(1,10):
    if N % i == 0:
        n = N / i
        for j in range(1,10):
            if n / j == 1:
                print('Yes')
                exit()

print('No')
//  [python]
N=int(input())

for i in range(1,10):
	for j in range(1,10):
		if i+j==N:
			print("Yes")
			exit()
		
print("No")
//  [python]
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        break
    else:
        print('No')
//  [python]
N = int(input())

for i in range(1, 9 + 1):
    if i % N == 0 and N / i <= 9:
        print('Yes')
        break
    else:
        print('No')
//  [java]
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	//static final long MOD = 998244353;
	static final long MOD = 1000000007;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.ni();
		for (int a = 1; a < 10; a++) {
			for (int b = 1; b < 10; b++) {
				if (a*b==N) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
    
    public static long power(long x, long y, long p) { 
        // Initialize result
        long res = 1;
         
        // Update x if it is more   
        // than or equal to p 
        x = x % p;  
      
        while (y > 0) 
        { 
            // If y is odd, multiply x 
            // with result 
            if((y & 1)==1) 
                res = (res * x) % p; 
      
            // y must be even now 
            // y = y / 2 
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    }
    
    public static long dist(int[] point, int[] point2) {
    	return (long)(Math.pow((point2[1]-point[1]),2)+Math.pow((point2[0]-point[0]),2));
    }
    
    public static long gcd(long a, long b) {
    	if (b == 0)
    		return a;
    	else
    		return gcd(b,a%b);
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr2[1]-arr1[1];
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}