Problem:
Score : 200 points

Problem Statement

You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.

Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:

Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.

What is the minimum number of operations required to achieve the objective?

Constraints

1 \leq N \leq 100

Each of the strings A, B and C is a string of length N.

Each character in each of the strings A, B and C is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

N
A
B
C

Output

Print the minimum number of operations required.

Sample Input 1

4
west
east
wait

Sample Output 1

3

In this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:

Change the second character in A to a. A is now wast.

Change the first character in B to w. B is now wast.

Change the third character in C to s. C is now wast.

Sample Input 2

9
different
different
different

Sample Output 2

0

If A, B and C are already equal in the beginning, the number of operations required is 0.

Sample Input 3

7
zenkoku
touitsu
program

Sample Output 3

13

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut scan = Scanner::new(cin);

    let n = scan.read::<i32>();
    let mut s = vec![vec![];3];
    for i in 0..3 {s[i] = scan.read_chars();}
    let mut t = vec![];
    for i in 0..n {
        let ith = vec![s[0][uz(i)], s[1][uz(i)], s[2][uz(i)]];
        let hmap = count(&ith);
        let m = hmap.iter().map(|(_, &k)| k).max().unwrap();
        if m == 1 {
            t.push(s[0][uz(i)]);
        } else {
            t.push(hmap.iter().filter(|&(_, &k)| k == m).map(|(&c, _)| c).collect::<Vec<char>>()[0]);

        }
    }
    let mut cnt = 0;
    for i in 0..3 {
        cnt += diffcnt(&s[i], &t);
    }
    println!("{}", cnt);
}

fn diffcnt(a: &[char], b: &[char]) -> i32 {
    let mut cnt = 0;
    for i in 0..a.len() {
        if a[i] != b[i] {cnt+=1}
    }
    cnt
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

// region template
#[allow(dead_code)]
fn uz(i: i32) -> usize { i as usize }

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read_opt<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_opt().unwrap()
    }

    fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion