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())

if A == B and B == C:
	print(0)
else:
	counter = 0
	for j, k, l in zip(A,B,C):
		if j == k and k == l:
			pass
		elif j == k or k == l or j == l:
			counter += 1
		else:
			counter += 2

	print(counter)

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
N=int(stdin.readline().rstrip())
A=[x for x in input()]
B=[x for x in input()]
C=[x for x in input()]
arr=[A,B,C]
arr=np.array(arr)
ans=0
cnt=0
for i in range(N):
    if len(set(arr[:,i]))==3:
        ans+=3
        cnt+=1
    else:
        if len(set(arr[:,i])) != 1:
            ans+=(3-len(set(arr[:,i])))
print(ans-cnt)

Submission status: Accepted

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

count=0
for i,word in enumerate(A):

    if B[i]==C[i]:
        if B[i]==C[i] and B[i]==A[i]:
            count=count+1
        count=count-1
    if B[i]!=word:
        count=count+1
    if C[i]!=word:
        count=count+1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
S = []
S.append([c for c in input()])
S.append([c for c in input()])
S.append([c for c in input()])

count = 0
for i in range(N):
    if S[0][i] == S[1][i] and S[1][i] == S[2][i]: continue
    elif S[0][i] == S[1][i] or S[1][i] == S[2][i] or S[0][i] == S[2][i]: count += 1
    else: count += 2
print(count)

Submission status: Accepted

Solution code:
n, a, b, c = [input() for i in range(4)]
n = int(n)

ret = 0
for i in range(n):
    if (a[i] == b[i]) and (a[i] == c[i]):
        pass

    elif (a[i] == b[i]) and (a[i] != c[i]):
        c = c[:i] + a[i] + c[i + 1:]
        ret += 1

    elif a[i] == c[i] and a[i] != b[i]:
        b = b[:i] + a[i] + b[i + 1:]
        ret += 1

    elif a[i] != c[i] and b[i] == c[i]:
        a = a[:i] + b[i] + a[i + 1:]
        ret += 1

    elif a[i] != b[i] and a[i] != c[i]:
        b = b[:i] + a[i] + b[i + 1:]
        c = c[:i] + a[i] + c[i + 1:]
        ret += 2


print(ret)

Submission status: Accepted

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

str_len = len(A)

count = 0


for i in range(str_len):
    #print(f'i: {i}')
    if A[i]==B[i]:
        if C[i]==B[i]:
            continue
        else:
            count = count + 1
    elif A[i]==C[i]:
        count = count + 1
    elif B[i]==C[i]:
        count = count + 1
    else:
        count = count + 2
print(str(count))

Submission status: Accepted

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

a = list(A)    
b = list(B)
c = list(C)

count = 0
for i in range(0,N):
    if a[i] == b[i] and a[i] == c[i]:
        count += 0
    elif a[i] == b[i] or a[i] == c[i] or 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()


def get_intersection(s1, s2):
    # s1とs2のようそすうは同じ

    ret = []

    for i in range(len(s1)):
        if s1[i] == s2[i]:
            ret.append(i)

    return ret


cm_ab = set(get_intersection(a,b))
cm_ac = set(get_intersection(a,c))
cm_bc = set(get_intersection(b,c))


all = set(range(n))
ncm_a = all - (cm_ab | cm_ac)
ncm_b = all - (cm_ab | cm_bc)
ncm_c = all - (cm_ac | cm_bc)


ncm_sum = len(ncm_a)+len(ncm_b)+len(ncm_c)
ncm_all_len = len(all - (cm_ab | cm_bc | cm_ac))

print(ncm_sum - ncm_all_len)

Submission status: Accepted

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
A = S()
B = S()
C = S()

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

print(cnt)

Submission status: Accepted

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

ans = 0
for i in range(N):
    tmp = list(A[i] + B[i] + C[i])
    cnt = Counter(tmp)
    max_cnt = max(cnt.values())

    if max_cnt == 3:
        # 出現する同じ英字の個数が3であれば、置換不要のためカウントしない。
        pass
    else:
        # 出現する同じ英字の個数が3以外の場合、3 - (出現する同じ英字の個数の最大値) 回置換する。
        # 例：w, e, w の場合、同じ個数の最大値は、wの2個。置換は、3-2=1回。
        ans = ans + (3 - max_cnt)

print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np

def parse(inp):
    N=int(next(inp))
    
    wordlist=np.array([list(next(inp))])
    for i in range(2):
        wordlist=np.append(wordlist,np.array([list(next(inp))]),axis=0)

#     print(wordlist)

    return N,wordlist

def main(inp):
    N,wordlist=parse(inp)
    sousa=0
    total=np.array([],dtype=int)
    
    tf01=(wordlist[0]==wordlist[1])
    tf02=(wordlist[0]==wordlist[2])
    tf12=(wordlist[1]==wordlist[2])
#    print(tf01,tf02,tf12)
    for i in range(N):
        total=np.append(total,sum([tf01[i],tf02[i],tf12[i]]))
#    print(total)
    
    for i in range(N):
        if(total[i]==0):
            sousa+=2
        elif(total[i]==1):
            sousa+=1
        else:
            continue
    
    return sousa
  
print(main(sys.stdin))

Submission status: Accepted

Solution code:
N = int(input())

s = []
for i in range(3):
    s.append(input())

ans = 0
for i in range(N):
    s1 = s[0][i]
    s2 = s[1][i]
    s3 = s[2][i]

    if s1==s2 and s2==s3 and s1==s3:
        ans += 0
    elif s1==s2 or s1==s3 or s2==s3:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
# N A,B,Cの文字数
# 制約：A,B,Cは英小文字
# いずれかの文字列を1文字抽出して別の文字列を変換する

# リスト化
N = int(input())
A = list(input())
B = list(input())
C = list(input())

count = 0
for i in range(N):
    if A[i] == B[i] and A[i] == C[i]:
        continue
    elif A[i] == C[i]:
        count += 1
    elif B[i] == C[i]:
        count += 1
    elif A[i] == B[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]:
        pass
    elif a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        count += 2
    else:
        count += 1

print(count)

Submission status: Accepted

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

n = 0
for a, b, c in zip(list(A), list(B), list(C)):
    if a == b:
        if c != a:
            n += 1
    else:
        if c != a:
            n += 1
        if c != b:
            n += 1

print(n)

Submission status: Accepted

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


cnt = 0
i = 0
while True:
    if i >= N:
        i = 0
    if A == B and B == C:
        break
    if  A[i] != B[i] and B[i] != C[i]:
        B[i] = A[i]
        # C[i] = A[i]
        cnt += 1
    elif A[i] == B[i] and B[i] != C[i]:
       C[i] = B[i]
       cnt += 1
    elif A[i] != B[i] and B[i] == C[i]:
        A[i] = B[i]
        cnt += 1
    elif A[i] != B[i] and A[i] == C[i]:
        B[i] = A[i]
        cnt += 1
    i += 1

print(cnt)

Submission status: Accepted

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

a = list(A)
b = list(B)
c = list(C)

ans = 0

for i,j in enumerate(a):
    if j == b[i] or j == c[i] or b[i] == c[i]:
        if j == b[i] == c[i]:
            continue
        ans += 1
    elif a[i] != b[i] != c[i]:
        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 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] and A[i] == C[i]: # AとCが同じ
    ans += 1
  elif A[i] == B[i] and A[i] != C[i]: # AとBが同じ
    ans += 1
  elif A[i] != B[i] and B[i] == C[i]: # BとCが同じ
    ans += 1
  elif A[i] != B[i] and B[i] != C[i]: # 3つとも異なる
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

countA = 0
countB = 0
countC = 0
countALL = 0

for i in range(N):
    if A[i] == B[i] and A[i] == C[i]:
        continue
    elif A[i] == B[i]:
        countC += 1
    elif B[i] == C[i]:
        countA += 1
    elif A[i] == C[i]:
        countB += 1
    else:
        countALL += 1


result = countA + countB + countC + int(countALL * 2)

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(N):
    alc = set()
    alc.add(a[i])
    alc.add(b[i])
    alc.add(c[i])
    r = len(alc)
    if r == 1:
        pass
    elif r == 2: 
        ans += 1
    elif r == 3:
        ans += 2
    else:
        raise Exception("nandeya")

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    A, B, C = [input() for _ in range(3)]
    res = sum(len({a,b,c})- 1 for a,b,c in zip(A,B,C))
    return str(res)
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
def func(s, i):
    return s[:i] + '*' + s[i+1:]


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

for i in range(N):
    if A[i] == B[i] == C[i]:
        A = func(A, i)
        B = func(B, i)
        C = func(C, i)
    elif A[i] == B[i]:
        A = func(A, i)
        B = func(B, i)
    elif A[i] == C[i]:
        A = func(A, i)
        C = func(C, i)
    elif B[i] == C[i]:
        B = func(B, i)
        C = func(C, i)

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

print(ans)

Submission status: Accepted

Solution code:
n = int(raw_input())
a = raw_input().strip()
b = raw_input().strip()
c = raw_input().strip()
ans = 0
for x, y, z in zip(a, b, c):
    s = set([x, y, z])
    ans += len(s) - 1
print ans

Submission status: Accepted

Solution code:
input()

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

total = 0

for i in range(len(A)):
    s = set()
    s.add(A[i])
    s.add(B[i])
    s.add(C[i])

    total += len(s) - 1

print(total)

Submission status: Accepted

Solution code:
n = int(input())
abc_list = []
for i in range(3):
    abc_list.append(input())
ans = 0
diff = 0

for i in range(n):
    if abc_list[0][i] != abc_list[1][i]:
        diff += 1
    if abc_list[0][i] != abc_list[2][i]:
        diff += 1

    if diff == 0:
        pass
    elif diff == 1:
        ans += 1
    elif diff == 2 and abc_list[1][i] == abc_list[2][i]:
        ans += 1
    else:
        ans += 2
    diff = 0

print(ans)

Submission status: Accepted

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


def fix_str(s1, s2, s3):
    if s1 == s2 == s3:
        return 0
    if s1 == s2 or s1 == s3 or s2 == s3:
        return 1
    else:
        return 2

res = 0
for i in range(n):
    res += fix_str(a[i], b[i], c[i])

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

base = []
for i in range(N):
    if (A[i] == B[i]):
        base.append(A[i])
    elif A[i] == C[i]:
        base.append(A[i])
    elif B[i] == C[i]:
        base.append(B[i])
    else:
        base.append(A[i])

def count(X):
    counter = 0
    for i in range(N):
        if X[i] != base[i]:
            counter += 1
    return counter

print(count(A)+count(B)+count(C))

Submission status: Accepted

Solution code:
N = input()
A = list(input())
B = list(input())
C = list(input())
count = 0
for i in range(int(N)):

  a = A[i]
  b = B[i]
  c  =C[i]
  if a != b and a != c and c != b:
    a = b = c = "a"
    count += 2
  elif a == b and a != c:
    count += 1
  elif a != b and a == c:
    count+=1
  elif c != a and b == c:
    count +=1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = [input() for i in range(3)]
ans = [0] * N
tmp = []
for i in range(N):
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
k = 0
for i in range(n):
    p = 0
    if a[i] != b[i]:
        p+=1
    if b[i] != c[i]:
        p+=1
    if c[i] != a[i]: 
        p+=1

    if p == 2:
        k += 1
    elif p == 3:
        k+=2
print(k)

Submission status: Accepted

Solution code:
n=int(input())
s=[list(input()) for i in range(3)]
p=list(s[0])
for j in range(n):
  if s[1][j]==s[2][j]:
    p[j]=s[1][j]
c=0
for k in range(n):
  if p[k]!=s[0][k]:
    c+=1
  if p[k]!=s[1][k]:
    c+=1
  if p[k]!=s[2][k]:
    c+=1
print(c)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(3):
    a.append(list(input()))
c = 0
for i in range(n):
    d,e = [],[]
    for j in range(3):
        d.append(a[j][i])
    e = [d.count(i) for i in d]
    c += 3 - max(e)
print(c)

Submission status: Accepted

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

x = 0

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

print(x)

Submission status: Accepted

Solution code:
n=int(input())
string_list=[input() for i in range(3)]

result = 0

for i in range(n):
  temp = set([string_list[0][i], string_list[1][i], string_list[2][i]])
  result += len(temp) - 1

print(result)

Submission status: Accepted

Solution code:
import collections

N = int(raw_input())
moji = []
moji.append(raw_input())
moji.append(raw_input())
moji.append(raw_input())

count = 0


for i in range(N):
	row = [moji[0][i],moji[1][i],moji[2][i]]
	count += 3 - collections.Counter(row).most_common()[0][1]

print count

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(0, 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] :
        count += 1
    else :
        count += 2
print(count)

Submission status: Accepted

Solution code:
def dist(A, B, C):
    res = 0
    for a, b, c in zip(A, B, C):
        res += len(set([a, b, c])) - 1
    return res

N = input()
A, B, C = [raw_input() for _ in range(3)]
print dist(A, B, C)

Submission status: Accepted

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

S = [0 for _ in range(n)]

for i in range(n):
    if a[i] == b[i] and a[i] == c[i]:
        S[i] = 0
    if a[i] == b[i] and b[i] != c[i] and c[i] != a[i]:
        S[i] = 1
    if a[i] != b[i] and b[i] == c[i] and c[i] != a[i]:
        S[i] = 1
    if a[i] != b[i] and b[i] != c[i] and c[i] == a[i]:
        S[i] = 1
    if a[i] == b[i] and b[i] == c[i] and c[i] != a[i]:
        S[i] = 1
    if a[i] != b[i] and b[i] == c[i] and c[i] == a[i]:
        S[i] = 1
    if a[i] == b[i] and b[i] != c[i] and c[i] == a[i]:
        S[i] = 1
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        S[i] = 2

ans = sum(S)

print(ans)

Submission status: Accepted

Solution code:
# 2019/01/27
# NIKKEI Programming Contest 2019 - B

# Input
n = int(input())
a = input()
b = input()
c = input()
sum = 0

# Choose Max
for idx in range(n):
    
    if a[idx] == b[idx]:
        if a[idx] == c[idx]:
            # All chars are same
            sum += 0
        else:
            # a=b, a!=c
            sum += 1
    else:
        if a[idx] == c[idx]:
            # a!=b, a=c
            sum += 1
        else:
            if b[idx] == c[idx]:
                # a!=b, b=c
                sum += 1
            else:
                # All chars are different
                sum += 2
# Output
print(sum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++

def cc(a,b,c):
	if a==b and a==c:
		return 0
	elif a==b or b == c or c == a:
		return 1
	return 2

def main(io):
	n = int(io.next())
	sa=io.next()
	sb=io.next()
	sc=io.next()
	ret=0
	for i in range(n):
		ret += cc(sa[i], sb[i],sc[i])
	return ret

#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)
	#print cc('a','b','c')

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

min = 0

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

print("{}".format(min))

Submission status: Accepted

Solution code:
data = input().split()

n = int(data[0])
word1 = input()
word2 = input()
word3 = input()

mod = 0

for i in range(n):
    if(word1[i] == word2[i] and word2[i] == word3[i]):
        continue
    elif(word1[i] == word2[i] or word2[i] == word3[i] or word1[i] == word3[i]):
        mod+=1
    else:
        mod+=2


print(mod)

Submission status: Accepted

Solution code:
def run(N, A, B, C):
    ret = 0
    for i in range(N):
        if A[i] == B[i] and B[i] != C[i]:
            ret += 1
        elif A[i] != B[i] and B[i] == C[i]:
            ret += 1
        elif A[i] == C[i] and A[i] != B[i]:
            ret += 1
        elif A[i] == B[i] and B[i] == C[i]:
            pass
        else:
            ret += 2
    return ret


def main():
    N = int(input())
    A = input()
    B = input()
    C = input()
    print(run(N, A, B, C))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

n=int(input())
string_list=[input() for i in range(3)]

a = string_list[0]
b = string_list[1]
c = string_list[2]

ans = 0
for ac, bc, cc in zip(a, b, c):
    tmp = ac+bc+cc
    c = collections.Counter(tmp)
    ans += 3 - c.most_common()[0][1]

print(ans)

Submission status: Accepted

Solution code:
num1 = int(input())
num2 = input()
num3 = input()
num4 = input()

num2 = list(num2)
num3 = list(num3)
num4 = list(num4)

_num = 0
for num in range(num1):
    if(num2[num] == num3[num]):
        if(num2[num] == num4[num]):
            _num += 0
        else:
            _num += 1
    else:
        if(num2[num] == num4[num]):
            _num += 1
        else:
            if(num3[num] == num4[num]):
                _num += 1
            else:
                _num += 2

print(_num)

Submission status: Accepted

Solution code:
import sys
file= lambda location: {True:sys.stdin, False:open(location,"r")}[location==""]

location=""#Enter location here
#sys.stdin=file(location)
raw_input=sys.stdin.readline

N=int(raw_input())
A=raw_input().strip()
B=raw_input().strip()
C=raw_input().strip()
ans=0
for i in xrange(N):
	m=len(set(A[i]+B[i]+C[i]))
	ans=ans+(m-1)
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]:
		if a[i] != c[i]:
			ans += 1
		
	else:
		if a[i] == c[i]:
			ans += 1
		else:
			if b[i] == c[i]:
				ans += 1
			else :
			 	ans += 2

print(ans)

Submission status: Accepted

Solution code:

def diff(a,b,c):
	string = [a,b,c]
	num = len(list(set(string)))
	if num == 3:
		return 2
	elif num == 2:
		return 1
	elif num == 1:
		return 0

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

count=0
for i in range(N):
	count += diff(A[i],B[i],C[i])

print(count)
exit()

Submission status: Accepted

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

Submission status: Accepted

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

print(retval)

Submission status: Accepted

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

import collections
answer=0
N=int(N)
for i in range(N):
    if len(set([A[i],B[i],C[i]]))==1:
        continue
    if len(set([A[i],B[i],C[i]]))==3:
        answer+=2
        continue
    i2=0
    #print(collections.Counter([A[i],B[i],C[i]]))
    for k,v in collections.Counter([A[i],B[i],C[i]]).items():
        if v!=max(collections.Counter([A[i],B[i],C[i]]).values()):
            #print(i2)
            #print(k,v)
            answer+=v
    
print(answer)

Submission status: Accepted

Solution code:
def data_input():
    a = input()
    b = input()
    c = input()
    d = input()
    return (int(a),b,c,d)
def answer():
    n,a,b,c = data_input()
    counta = 0
    for i in range(n):
        count = 0
        if a[i] != b[i]:
            count += 1
        if a[i] != c[i]:
            count += 1
        if b[i] != c[i]:
            count += 1
        if count != 0:
            count -= 1
        counta += count

    return counta

def output():
    res = answer()
    print(res)
output()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())

d = defaultdict(lambda : defaultdict(int))

for i in range(3):
    s = list(input())
    for j in range(n):
        d[j][s[j]] += 1
ans = 0
for i in range(n):
    mx = max(d[i], key=d[i].get)
    for j in d[i]:
        if mx != j:
            ans += d[i][j]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
a.append(input())
a.append(input())
a.append(input())

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

print(cnt)

Submission status: Accepted

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

for i in range(N):
    cash = 0
    if A[i] == B[i] and B[i] == C[i]:
        cash += 1
    if A[i] != B[i]:
        cash += 1
    if B[i] != C[i]:
        cash += 1
    if C[i] != A[i]:
        cash += 1
    count += cash - 1
print(count)

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]) & (A[i] != C[i]) & (B[i] != C[i])):
    count+=2
  else:
    if ( (A[i] != B[i]) & (A[i] == C[i]) & (B[i] != C[i]) ):
      count+=1
    if ( (A[i] != B[i]) & (A[i] != C[i]) & (B[i] == C[i]) ):
      count+=1
    if ( (A[i] == B[i]) & (A[i] != C[i]) & (B[i] != C[i]) ):
      count+=1

print(count)

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] and A[i]==C[i]:
        a+=0
    elif A[i]==B[i] or A[i]==C[i]:
        a+=1
    elif B[i]==C[i]:
        a+=1
    else:
        a+=2
print(a)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

result = 0

for i in range(N):
    if A[i] == B[i]  and B[i] == C[i] and A[i] == C[i]:
        # 全文字同じ
        pass
    elif A[i] == B[i]  or B[i] == C[i] or A[i] == C[i]:
        # 1個だけ違う
        result = result + 1
    else:
        result = result + 2

print(result)

Submission status: Accepted

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

cnt = 0

for n in range(N):
    if A[n] == B[n] and A[n] == C[n]:
        pass
    elif A[n] == B[n] or A[n] == C[n] or B[n] == C[n]:
        cnt += 1
    else:
        cnt += 2

print(cnt)

Submission status: Accepted

Solution code:
import string
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for x, y, z in zip(a, b, c):
    wl = [0]*26
    wl[string.ascii_lowercase.index(x)] += 1
    wl[string.ascii_lowercase.index(y)] += 1
    wl[string.ascii_lowercase.index(z)] += 1
    cnt += 3 - max(wl)
print(cnt)

Submission status: Accepted

Solution code:
n = input()
A = raw_input()
B = raw_input()
C = raw_input()
a = list(A)
b = list(B)
c = list(C)
count = 0
for i in range(0,n):
	if(a[i] == b[i]):
		if(a[i] == c[i]):
			pass
		else:
			c[i] = a[i]
			count+=1
	elif(a[i] == c[i]):
		b[i] = a[i]	
		count+=1
	elif(b[i] == c[i]):
		a[i] = b[i]
		count += 1
	else:
		b[i] = a[i]
		c[i] = a[i]
		count += 2
print(count)

Submission status: Accepted

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

ans = 0
for i in range(N):
    diff_c = 0
    tmp = {}
    for x in [A[i], B[i], C[i]]:
        if x in tmp.keys():
            tmp[x] += 1
        else:
            tmp[x] = 1
    common = max(tmp, key=tmp.get)
    if A[i] != common:
        diff_c += 1
    if B[i] != common:
        diff_c += 1
    if C[i] != common:
        diff_c += 1
    ans += diff_c
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]:
        if A[i] != C[i]:
            if B[i] != C[i]:
                ans += 2
            else:
                ans += 1
        else:
            ans += 1
    else:
        if B[i] != C[i]:
            if A[i] != C[i]:
                ans += 1
print(ans)

Submission status: Accepted

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


def get_n_trial(a_str, b_str, c_str):
    ret = 0
    for a, b, c in zip(a_str, b_str, c_str):
        if a == b == c:
            continue
        elif (a != b) and (b != c) and (c != a):
            ret += 2
        else:
            ret += 1
        # print(ret)
    return ret


print(get_n_trial(A, B, C))

Submission status: Accepted

Solution code:

n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    cnt = 2
    if a[i]==b[i]: cnt -= 1
    if b[i]==c[i]: cnt -= 1
    if c[i]==a[i]: cnt -= 1
    if cnt<0: cnt = 0
    ans += cnt

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a_list = list(input())
b_list = list(input())
c_list = list(input())
count = 0
for i in range(n):
    if a_list[i] == b_list[i] == c_list[i]:
        continue
    elif a_list[i] == b_list[i]:
        count += 1
        c_list[i] = a_list[i]
        continue
    elif b_list[i] == c_list[i]:
        a_list[i] =b_list[i]
        count += 1
        continue
    elif a_list[i] == c_list[i]:
        count += 1
        b_list[i] = a_list[i]
        continue
    else:
        count = count + 2
print(count)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
#print(n,a,b,c)
ans=0
for i in range(n):
  cnt=2
  if a[i]==b[i]:
    cnt-=1
  if b[i]==c[i]:
    cnt-=1
  if a[i]==c[i]:
    cnt-=1
  if cnt==-1:
    cnt=0
  ans=ans+cnt
print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

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

def t_count(a, b, c):
    if a == b:
        if a == c:
            return 0
        else:
            return 1
    elif b == c:
        return 1
    elif c == a:
        return 1
    else:
        return 2


counter = 0
for i in range(N):
    counter += t_count(A[i], B[i], C[i])

print(counter)

Submission status: Accepted

Solution code:
import collections

n = int(input())
# n = 7

# s = [ 'zenkoku', 'touitsu', 'program' ]
s = []
t = [ [], [], [] ]

for i in range(3):
    s.append(input())
    # t.append([])
    for j in range(n):
        t[i].append(s[i][j])

u = []
for j in range(n):
    u.append([])
    for i in range(3):
        u[j].append(s[i][j])

sum = 0
for j in range(n):
    c = collections.Counter(u[j])
    most = c.most_common()[0]
    sum += 3 - most[1]
    # print(most, 3 - most[1])

print(sum)

Submission status: Accepted

Solution code:
N, A, B, C = [input() for _ in range(4)]
N = int(N)

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