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



Sample input:
4
west
east
wait


Sample output:
3

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())
d = []
for i in range(n):
    if a[i] == b[i] == c[i]:
        d.append(0)
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        d.append(1)
    else:
        d.append(2)
print(sum(d))

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

#%%
# n = 4
# a = "west"
# b = "east"
# c = "wait"


#%%
(a[0] == b[0]) + (a[0]==c[0]) + (b[0]==c[0])

#%%
ans = 0
for i in range(n):
    if (a[i] == b[i]) + (a[i] == c[i]) + (b[i] == c[i]) == 1:
        ans+=1
    if (a[i] == b[i]) + (a[i] == c[i]) + (b[i] == c[i]) == 3:
        pass
    if (a[i] == b[i]) + (a[i] == c[i]) + (b[i] == c[i]) == 0:
        ans+=2
print(ans)



#%%

Submission status: Accepted

Solution code:
def check(a,b,c):
  s={a,b,c}
  if len(s)==3:
    return 2
  elif len(s)==2:
    return 1
  else:
    return 0

n = int(input())
a_list=list(input())
b_list=list(input())
c_list=list(input())

ans=0
for i in range(n):
  ans+=check(a_list[i],b_list[i],c_list[i],)
  
print(ans)

Submission status: Accepted

Solution code:
import collections
N=int(input())
A=list(input())
B=list(input())
C=list(input())
ans=0
for i in range(N):
  ans+=len(collections.Counter([A[i],B[i],C[i]]))-1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np


N = int(input())
A = list(input())
B = list(input())
C = list(input())

R_A = [None] * N
R_B = [None] * N
R_C = [None] * N

for i in range(N):
    if A[i] == B[i] and A[i] == C[i]:
        R_A[i] = 0
    elif A[i] == B[i]:
        R_A[i] = 1
    elif A[i] == C[i]:
        R_A[i] = 1
    else:
        R_A[i] = 2

for i in range(N):
    if B[i] == A[i] and B[i] == C[i]:
        R_B[i] = 0
    elif B[i] == A[i]:
        R_B[i] = 1
    elif B[i] == C[i]:
        R_B[i] = 1
    else:
        R_B[i] = 2

for i in range(N):
    if C[i] == A[i] and C[i] == B[i]:
        R_C[i] = 0
    elif C[i] == A[i]:
        R_C[i] = 1
    elif C[i] == B[i]:
        R_C[i] = 1
    else:
        R_C[i] = 2

R = np.array([R_A, R_B, R_C])

print(sum(R.min(axis=0)))

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    a,b,c = A[i],B[i],C[i]
    t = len(list(set([a,b,c])))
    if t == 1:
        pass
    elif t == 2:
        ans += 1
    elif t == 3:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
N = int(raw_input())
A = raw_input()
B = raw_input()
C = raw_input()
count = 0
for i in range(N):
    if (A[i] == B[i]) & (B[i]==C[i]):
        count += 0
    elif (A[i] == B[i])|(A[i]==C[i])|(B[i]==C[i]):
        count += 1
    else:
        count += 2
print (count)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
    if A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        count += 2
    elif A[i] == B[i] and B[i] != C[i] and C[i] != A[i]:
        count += 1
    elif A[i] != B[i] and B[i] == C[i] and C[i] != A[i]:
        count += 1
    elif A[i] != B[i] and B[i] != C[i] and C[i] == A[i]:
        count += 1
    else:
        count += 0
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    if a[i]==b[i] and b[i]==c[i]:
        cnt = cnt
    elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        cnt += 1
    else:
        cnt += 2
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

count = 0
def count_dif(s, t, u):
    x = list(set([s, t, u]))
    return len(x)

for i in range(N):
    d = count_dif(A[i], B[i], C[i])
    count += d-1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0
for i in range(n):
    if (a[i] == b[i]) and (b[i] == c[i]):
        ans += 0
    elif (a[i] != b[i]) and (a[i] != c[i]) and (b[i] != c[i]):
        ans += 2
    else:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = input()
A = raw_input()
B = raw_input()
C = raw_input()

ans = 0
for i in range(N):
  ans += len(set([A[i], B[i], C[i]])) - 1
print ans

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())
ans = 0
for i in range(N):
    if A[i] == B[i]:
        if A[i] != C[i]:
            ans += 1
    else:
        if A[i] == C[i]:
            ans += 1
        elif B[i] == C[i]:
            ans += 1
        else:
            ans += 2
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

n = int(input())
ans = 0
A = list(input())
B = list(input())
C = list(input())

for i in range(n):
    a = A[i]
    b = B[i]
    c = C[i]
    if a == b and b != c:
        ans += 1
    elif a == c and b != c:
        ans += 1
    elif b == c and a != b:
        ans += 1
    elif a == b and b == c:
        ans += 0
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
 
count = 0
 
for i in range(n):
    if a[i] != b[i] and b[i] == c[i]:
        count += 1
    elif a[i] != b[i] and a[i] != c[i]:
        count += 2
    elif a[i] != b[i] or a[i] != c[i]:
        count += 1
        
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
  s = len(set([a[i], b[i], c[i]]))
  if (s == 3):
    ans += 2
  elif (s == 2):
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
def A():
    n, a, b = map(int, input().split())
    print(min(a, b), max(a + b - n, 0))
#A()

def B():
    N = int(input())
    A = input()
    B = input()
    C = input()
    cnt = 0
    ans = 0
    for i in range(N):
        cnt = 0
        if A[i] == B[i]:
            if B[i] == C[i]:
                cnt = cnt
            elif B[i] != C[i]:
                cnt += 1
        if A[i] != B[i]:
            if A[i] != C[i] and B[i] != C[i]:
                cnt += 3
            elif A[i] != C[i] and B[i] == C[i]:
                cnt += 1
            elif A[i] == C[i] and B[i] != C[i]:
                cnt += 1
        if cnt == 1:
            ans += 1
        elif cnt == 3:
            ans += 2

    print(ans)
B()

Submission status: Accepted

Solution code:
N=int(input())
A=list(input())
B=list(input())
C=list(input())
ans=0
for i in range(N):
    if A[i]==B[i] and B[i]==C[i]:
        ans+=0
    elif A[i]==B[i] or B[i]==C[i] or A[i]==C[i]:
        ans+=1
    else:
        ans+=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    d, e, f = a[i], b[i], c[i]
    if d == e == f:
        pass
    elif d == e or d == f or e == f:
        cnt += 1
    else:
        cnt += 2
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(len(A)):
    if(A[i] == B[i] and B[i] == C[i]):
        continue
    if(A[i] == B[i] or B[i] == C[i] or A[i] == C[i]):
        ans +=1
        continue
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    tmp = 100
    for c in [A[i], B[i], C[i]]:
        cnt = 0
        for a in [A[i], B[i], C[i]]:
            if c!=a: cnt+=1
        tmp = min(tmp, cnt)
    ans += tmp
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N = n()

S = [line.strip() for line in sys.stdin]

M = len(S)

cost = 0
for i in xrange(N):
    count = collections.Counter()
    for j in xrange(M):
        count[S[j][i]] += 1
    cost += M - count.most_common(1)[0][1]

print cost

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
cnt=0
for i in range(n):
    if(a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]):
        cnt+=2
    elif(a[i]==b[i] and a[i]==c[i] and b[i]==c[i]):
        continue
    else:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

same = [2]*N
for i in range(N):
    if A[i] == B[i] == C[i]:
        same[i] = 0
    elif A[i] == B[i] or A[i] == C[i] or B[i] == C[i]:
        same[i] = 1

ans = sum(same)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=str(input())
b=str(input())
c=str(input())
ans=0
for i in range(n):
  if(a[i]==b[i] and b[i]==c[i]):
    continue
  elif(a[i]==b[i] or b[i]==c[i] or c[i]==a[i]):
    ans+=1
  else:
    ans+=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = str(input())
b = str(input())
c = str(input())
count = 0
for i in range(n):
    if a[i]==b[i]==c[i]:
        count += 0
    elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        count += 1
    else:
        count += 2
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    elif a[i] != b[i]:
        if a[i] == c[i] or b[i] == c[i]:
            count += 1
        else:
            count += 2
    elif b[i] != c[i]:
        if b[i] == a[i] or c[i] == a[i]:
            count += 1
        else:
            count += 2
    elif c[i] != a[i]:
        if c[i] == b[i] or a[i] == b[i]:
            count += 1
        else:
            count += 2
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, C):
    ans = 0
    for i in range(N):
        ans += len(set([A[i], B[i], C[i]])) - 1
    return ans


def main():
    N = read_int()
    A = read_str()
    B = read_str()
    C = read_str()
    print(slv(N, A, B, C))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def calc(a,b,c):
    res = 0
    if not a == b:
        res+=1
    if not a == c:
        res+=1
    if not b == c:
        res+=1
    if res > 1:
        return res - 1
    else:
        return res
        
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
    ans+=calc(A[i],B[i],C[i])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
  S = {A[i], B[i], C[i]}
  ans += S.__len__() - 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(3)]

ans = 0
table = [2, 1, 10 * 9 + 7, 0]
for i in range(N):
    score = 0
    if S[0][i] == S[1][i]: score += 1
    if S[1][i] == S[2][i]: score += 1
    if S[2][i] == S[0][i]: score += 1
    ans += table[score]

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    c = Counter()
    c[A[i]] += 1
    c[B[i]] += 1
    c[C[i]] += 1
    for j, (c, v) in enumerate(c.most_common()):
        if j == 0:
            continue
        ans += v
print(ans)

Submission status: Accepted

Solution code:
from string import ascii_lowercase
def inpl(): return list(map(int, input().split()))
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    if A[i] == B[i] == C[i]:
        pass
    elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        pass
    elif a[i] == b[i] or b[i] == c[i] or a[i] == c[i]:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for a, b, c in zip(A, B, C):
    s = {a, b, c}
    if len(s) == 1:
        pass
    elif len(s) == 2:
        cnt += 1
    else:  # len(s) == 3
        cnt += 2
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
X = input()
Y = input()
Z = input()

ans = 0

for i in range(N):
  if  X[i] == Y[i] and Y[i] == Z[i]:
    ans += 0
  elif X[i] == Y[i] or Y[i] == Z[i] or Z[i] == X[i]:
    ans += 1
  else:
    ans += 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

a=input()
b=input()
c=input()

ans = 0

for i in range(N):
    if a[i]==b[i] and a[i]!=c[i]:
        ans = ans+1
    elif a[i]!=b[i] and a[i]==c[i]:
        ans = ans+1
    elif c[i]==b[i] and a[i]!=c[i]:
        ans = ans+1
    elif c[i]!=b[i] and a[i]!=c[i] and a[i]!=c[i]:
        ans = ans+2
    
print(ans)

Submission status: Accepted

Solution code:
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy as np
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        pass
    elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    n = get_int()
    a = get_char_list()
    b = get_char_list()
    c = get_char_list()

    ret = 0
    for x, y, z in zip(a, b, c):
        if x == y == z:
            continue
        elif x == y or x == z or y == z:
            ret += 1
        else:
            ret += 2
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
import copy




def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input())
a=input()
b=input()
c=input()
def func():
    result=0
    for idx in range(0,len(a)):
        if a[idx]==b[idx]==c[idx]:
            result+=0
        elif a[idx]!=b[idx] and a[idx]!=c[idx] and b[idx]!=c[idx]:
            result+=2
        else:
            result+=1
    return result

print(func())

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

cnt = 0
for i in range(n):
    cnt += len(set([a[i], b[i], c[i]])) - 1
    
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(N):
  if A[i] == B[i] == C[i]:
    cnt += 0
  elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
    cnt += 2
  else:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(raw_input())
a = raw_input()
b = raw_input()
c = raw_input()
ans = 0
for i in range(n):
	ans += len(set([a[i], b[i], c[i]])) - 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for a, b, c in zip(A, B, C):
    if a == b and b == c:
        continue
    if a == b or b == c or c == a:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())

counter = 0

for i in range(N):
  if A[i] == B[i] and B[i] == C[i]:
    pass
  elif (A[i] == C[i] and A[i] != B[i]) or (A[i] == B[i] and C[i] != B[i]) or (B[i] == C[i] and A[i] != B[i]):
    counter += 1
  elif (A[i] != B[i] and B[i] != C[i] and C[i] != A[i]):
    counter += 2

print(counter)

Submission status: Accepted

Solution code:
n = int(input())
lis = [str(input()) for i in range(3)]
ans = 0
for i in range(n):
  if lis[0][i] == lis[1][i]:
    if lis[1][i] != lis[2][i]:
      ans += 1
  else:
    if lis[1][i] != lis[2][i] and lis[0][i] != lis[2][i]:
      ans += 2
    else:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
abc = [input() for _ in range(3)]
sol = 0
for i in range(n):
  sol += -1 + len(set([abc[j][i] for j in range(3)]))
print(sol)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input())
B = list(input())
C = list(input())

res = 0

for a, b, c in zip(A, B, C):
    if a == b and b == c:
        res += 0
    elif a == b or b == c or c == a:
        res += 1
    else:
        res += 2

print(res)

Submission status: Accepted

Solution code:
from collections import Counter

if __name__ == '__main__':
    n = int(input())
    a = input()
    b = input()
    c = input()
    ans = 0
    for t in zip(a, b, c):
        count = Counter(t)
        ans += len(count.values()) - 1
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    tmp = set()
    tmp.add(A[i])
    tmp.add(B[i])
    tmp.add(C[i])
    ans += len(tmp)-1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

A = input()
B = input()
C = input()

cnt = 0

for i in range(N):
  if A[i] != B[i]:
    cnt += 1
    if A[i] != C[i] and B[i] != C[i]:
      cnt  += 1
  else:
    if A[i] != C[i]:
      cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    a = input()
    b = input()
    c = input()
    ans = 0
    for i in range(N):
        C = Counter([a[i], b[i], c[i]]).most_common(1)[0][1]
        if C == 1: ans += 2
        elif C == 2: ans += 1
    return ans


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    ans += len(set([A[i], B[i], C[i]])) - 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

count = 0
for a, b, c in zip(A, B, C):
    var = set([a, b, c])
    count += len(var) - 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
As = input()
Bs = input()
Cs = input()

ans = 0
for A, B, C in zip(As, Bs, Cs):
    if A == B == C:
        pass
    elif A == B or B == C or C == A:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
N,A,B,C = int(input()), input(), input(), input()
ans = 0
for i in range(N):
    ans += len(set([A[i],B[i],C[i]])) - 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

s = 0

for i in range(n):
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        s += 2
    elif a[i] != b[i] or b[i] != c[i] or c[i] != a[i]:
        s += 1
    else:
        s += 0

print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(3)]
c = 0
for i in range(len(s[0])):
    if s[0][i] == s[1][i] == s[2][i]:
        continue;
    if s[0][i] == s[1][i] or s[1][i] == s[2][i] or s[2][i] == s[0][i]:
        c+=1
    else :
        c+=2
print(c)

Submission status: Accepted

Solution code:
n = int(input())
a = str(input())
b = str(input())
c = str(input())

count = 0

def match_func(x, y, z):
  if x == y and y == z:
    return 0
  elif x == y:
    return 1
  elif y == z:
    return 1
  elif x == z:
    return 1
  else:
    return 2

for i in range(n):
  count += match_func(a[i], b[i], c[i])

print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())

d = []
ans = 0
for i in range(n):
    if a[i] ==  b[i] == c[i]:
        ans += 0
    elif (a[i] == b[i]) or (b[i] == c[i]) or (a[i] == c[i]):
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

cnt = 0
for x in range(N):
    aa = A[x]
    bb = B[x]
    cc = C[x]
    s = {aa, bb, cc}
    cnt = cnt + (len(s) - 1)

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()
a = 0
for i in range(N):
    if A[i] == B[i] == C[i]:
        continue
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        a += 2
    else:
        a += 1

print(a)

Submission status: Accepted

Solution code:
def nikkei2019_qual_b():
    n = int(input())
    a = input()
    b = input()
    c = input()

    count = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            continue
        elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
            count += 1
        else:
            count += 2

    print(count)


nikkei2019_qual_b()

Submission status: Accepted

Solution code:
n = int(input())
l = []
a = input()
b = input()
c = input()
s =0
for i in range(n):
    m = [a[i],b[i],c[i]]
    s +=  len(set(m))-1
print(s)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt += 1
    else:
        cnt +=2
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())

count = 0
for i in range(n):
    seta = set()
    seta.add(a[i])
    seta.add(b[i])
    seta.add(c[i])
    count += len(seta) - 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
ans =0

for i in range(n):
    x = a[i]
    y = b[i]
    z = c[i]
    if (x == y and y == z):
        pass
    elif (x == y or y == z or z == x):
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

counter = 0

for i in range(N):
    if A[i] != B[i] and A[i] != C[i] and B[i] != C[i]:
        counter += 2

    elif A[i] == B[i] and A[i] != C[i] or A[i] == C[i] and A[i] != B[i] or B[i] == C[i] and A[i] != B[i]:
        counter += 1

print(counter)

Submission status: Accepted

Solution code:
# S = input()
N = int(input())
A = input()
B = input()
C = input()

# a = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

ans = 0


for i in range(N):
    if(A[i] == B[i] and A[i] == C[i]):
        ans += 0
    elif(A[i] == B[i] or A[i] == C[i] or B[i] == C[i]):
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
  if a[i] == b[i] == c[i]:
    pass
  elif a[i] == b[i] != c[i]:
    ans+=1
  elif b[i] ==c[i] != a[i]:
    ans += 1
  elif a[i] == c[i] != b[i]:
    ans+=1
  else:
    ans+=2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input()
B = input()
C = input()

counter = 0

for a, b, c in zip(A, B, C):
    counter += len(set([a, b, c])) - 1
print(counter)

Submission status: Accepted

Solution code:
n = int(input())
A = input()
B = input()
C = input()

count = 0
for a,b,c in zip(A,B,C):
    if a == b == c:
        continue
    if a != b:
        if a == c:
            count += 1
        else:
            if b == c:
                count += 1
            else:
                count += 2
    else:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
A=list(input())
B=list(input())
C=list(input())

count=0
for i in range(n):
    count+=len(set([A[i],B[i],C[i]]))-1
    #print(len(set([A[i],B[i],C[i]])))
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(str(input()))
b = list(str(input()))
c = list(str(input()))
count = 0
for i in range(n):
  count += len(set([a[i], b[i], c[i]])) - 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = str(input())
B = str(input())
C = str(input())

ans = 0
for i in range(N):
    if len(list(set([A[i], B[i], C[i]])))== 2:
        ans += 1
    elif len(list(set([A[i], B[i], C[i]]))) == 3:
        ans += 2


print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()

score=0
for i in range(N):
    chas=[]
    chas.append(A[i])
    chas.append(B[i])
    chas.append(C[i])
    lens=len(list(set(chas)))
    score+=(lens-1)

print(score)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    A = read_func().strip()
    B = read_func().strip()
    C = read_func().strip()
    count = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        c = C[i]
        if a != b and b != c and a != c:
            count += 2
        elif a == b and a == c and b == c:
            count += 0
        else:
            count += 1
    print count


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()

ans=0
for i in range(N):
  if A[i]!=B[i]:
    if A[i]!=C[i] and B[i]!=C[i]:
      ans+=2
    else:
      ans+=1
  else:
    if A[i]!=C[i]:
      ans+=1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()


ans = 0
for a,b,c in zip(A,B,C):
	if a==b:
		if b==c:
			continue
		else:
			ans+=1
	else:
		if a==c:
			ans+=1
		elif b==c:
			ans+=1
		else:
			ans+=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
#a,b=map(int,input().split()) #横並び
a=input()
b=input()
c=input()
cnt = 0
for i in range(n):
    ret = 0
    if a[i] != b[i] :
        ret+=1
    if b[i] != c[i] :
        ret+=1
    if c[i] != a[i]:
        ret+=1
    if ret % 3 != 0 :
        cnt+=1
    elif ret == 3:
        cnt+=2
#x=[int(input()) for i in range(3)] #縦に並んだのを配列に
#y=list(map(int,input().split())) #横に並んだのを配列に
print(cnt)
#print('YNEOS'[1::2])

Submission status: Accepted

Solution code:
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0

for i in range(n):
    li = []
    li.append(a[i])
    li.append(b[i])
    li.append(c[i])
    ans += len(set(li))-1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i]:
        continue
    else:
        if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
            count += 1
        else:
            count += 2
print(count)

Submission status: Accepted

Solution code:
import collections
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
    strings = [A[i], B[i], C[i]]
    strings = collections.Counter(strings)
    strings = strings.most_common()
    ans += len(strings) - 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
sum=0
for i in range(n):
  x=a[i]
  y=b[i]
  z=c[i]
  if (x==y and x!=z) or (x==z and x!=y) or (y==z and y!=x):
    sum+=1
  elif x!=y and x!=z and y!=z:
    sum+=2
print(sum)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = input()
    b = input()
    c = input()
    count = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            count+=0
        elif a[i] == b[i]:
            count+=1
        elif a[i] == c[i]:
            count+=1
        elif b[i] == c[i]:
            count+=1
        else:
            count+=2
    print(count)

Submission status: Accepted

Solution code:
n = input()
a = input()
b = input()
c = input()
cnt = 0
for i,j,k in zip(a,b,c):
    if i == k:
        pass
        if i == j:
            pass
        else:
            cnt += 1
    else:
        cnt += 1
        if i == j:
            pass
        else:
            if j == k:
                pass
            else:
                cnt += 1
print(cnt)