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:
input()
A = list(input())
B = list(input())
C = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a, b, c = map(str, [input() for i in range(3)])
#print(n, a, b, c)
result = ""
sum = 0

def count_same(ca, cb, cc):
    ct = 0
    if ca == cb == cc:
        return 3
    if ca == cb:
        return ca
    if cb == cc:
        return cb
    if cc == ca:
        return cc
    return 0
for i in range(n):
    tmp = count_same(a[i], b[i], c[i])
    if tmp == 3:
        result += a[i]
    elif tmp == 0:
        result += a[i]
        sum += 2
    else:
        result += tmp
        sum += 1

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
abc = [input() for i in range(3)]
d = [0]*n
for i in range(n):
    if abc[0][i]==abc[1][i]==abc[2][i]:
        d[i]=0
    elif abc[0][i]!=abc[1][i]!=abc[2][i]!=abc[0][i]:
        d[i]=2
    else:
        d[i]=1
print(sum(d))

Submission status: Accepted

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

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

#output
difference = [0] * N
for i in range(N):
    if A[i] == B[i] == C[i]:
        difference[i] = 0
    elif A[i] == B[i] and A[i] != C[i]:
        difference[i] = 1
    elif A[i] == C[i] and A[i] != B[i]:
        difference[i] = 1
    elif B[i] == C[i] and B[i] != A[i]:
        difference[i] = 1
    else:
        difference[i] = 2
print(sum(difference))

Submission status: Accepted

Solution code:
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
a = stdin.readline().rstrip()
b = stdin.readline().rstrip()
c = stdin.readline().rstrip()

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

print(point)

Submission status: Accepted

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

count = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue 
    elif a[i] == b[i]:
        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:
        c[i] = a[i]
        b[i] = a[i]
        count+=2        

print(count)

Submission status: Accepted

Solution code:
N = input()
A, B, C = [input() for _ in range(3)]
ans = 0
for a, b, c in zip(A, B, C):
    if a == b == c:
        continue
    elif a != b and b != c and c != a:
        ans += 2
    elif a == b or b == c or c == a:
        ans += 1
print(ans)

Submission status: Accepted

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

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 and c != a:
        ans += 2
    elif a == b and b == c and c == a:
        pass
    else:
        ans += 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] and b[i] == c[i]:
        ans += 2
    elif a[i] == b[i]:
        ans += 1
    elif b[i] == c[i]:
        ans += 1
    elif a[i] == c[i]:
        ans += 1
print(n*2-ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n = int(input())
    a = input()
    b = input()
    c = input()

    cnt = 0
    for es in zip(a, b, c):
        ec = Counter(es)
        l = len(ec)
        if l == 3:
            cnt += 2
        elif l == 2:
            cnt += 1

    print(cnt)


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] and b[i] == c[i]:
    # すべて同じなので操作しなくて良い
    continue

  if a[i] != b[i] and a[i] != c[i] and b[i] != c[i]:
    # すべて異なるので操作2回
    ans = ans + 2
    continue

  # 1つ異なる
  ans = ans + 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [input() for i in range(3)]
res = 0
for i in range(n):
    if a[0][i] == a[1][i] == a[2][i]:
        continue
    if a[0][i] == a[1][i] or a[2][i] == a[1][i] or a[0][i] == a[2][i]:
        res += 1
    else:
        res += 2
print(res)

Submission status: Accepted

Solution code:
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 b[i] != c[i] and c[i] != a[i]:
        count += 2
    elif a[i] == b[i] and b[i] == c[i]:
        continue
    else:
        count += 1

print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


n = int(input())

al = list(input())
bl = list(input())
cl = list(input())

ans = 0
for i,j,k in zip(al,bl,cl):
    a = [i,j,k]
    if max(a.count(i), a.count(j), a.count(k)) == 1:
        ans += 2
    elif max(a.count(i), a.count(j), a.count(k)) == 2:
        ans += 1
    else:
        pass
    
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]:
        continue
    elif a[i]!=b[i] and b[i]!=c[i] and 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()

count = 0

for i, j, k in zip(A,B,C):
    #print(set([i,j,k]))
    count = count + len(set([i,j,k])) - 1

print(count)

Submission status: Accepted

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

cnt = 0

for i, j, k in zip(a, b, c):
    cnt += len(set([i, j, k])) - 1
print(cnt)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a,b,c = [input() for _ in range(3)]

ans = 0
for x,y,z in zip(a,b,c):
    c = Counter([x,y,z])
    ans += 3 - c.most_common()[0][-1]
        
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=input()
b=input()
c=input()
cnt=0
for i in range(n):
    x=[a[i],b[i],c[i]]
    cnt+=len(set(x))-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):
  c=list(Counter([A[i],B[i],C[i]]).values())
  if c==[1,1,1]:
    ans+=2
  elif c==[2,1] or c==[1,2]:
    ans+=1
  else:
    pass
print(ans)

Submission status: Accepted

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

for i in range(N):
    answer += len({A[i], B[i], C[i]}) - 1

print(answer)

Submission status: Accepted

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

ans=0
for i in range(int(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()
d=[{a[i],b[i],c[i]} for i in range(n)]
ans=0
for i in range(n):
    ans+=len(d[i])-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]==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=input()
B=input()
C=input()
ans=0
for i in range(n):
    a=A[i]
    b=B[i]
    c=C[i]
    if a==b and b==c:
        pass
    elif a==b or a==c or b==c:
        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]:
    continue
  elif A[i] == B[i] and B[i] != C[i]:
    ans += 1
  elif A[i] == C[i] and C[i] != B[i]:
    ans += 1
  elif B[i] == C[i] and C[i] != A[i]:
    ans += 1
  else:
    ans += 2
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] and a[i]!=c[i] and b[i]!=c[i]:
        ans+=2
    elif a[i]==b[i] and b[i]!=c[i]:
        ans+=1
    elif a[i]==c[i] and b[i]!=c[i]:
        ans+=1
    elif c[i]==b[i] and a[i]!=c[i]:
        ans+=1
    else:
        ans+=0
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ABC=[list(input()) for _ in range(3)]

R=[len(set(x))-1 for x in zip(*ABC)]

print(sum(R))

Submission status: Accepted

Solution code:
n = int(input())
a = tuple(map(str, input()))
b = tuple(map(str, input()))
c = tuple(map(str, input()))
ans = 2*n
for i in range(n):
    if a[i] == b[i] == c[i]:
        ans -= 2
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans -= 1
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1

def main():
    n=int(input())
    a=input()
    b=input()
    c=input()
    ans=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]:
            ans+=1
        else:
            ans+=2
    print(ans)

main()

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(3)]

ans = 0
for v in zip(*s):
    len_ = len(set(v))
    ans += len_ - 1

    # if len_ == 3:
    #     ans += 2
    # elif len_ == 2:
    #     ans += 1
    # else:
    #     # len_ == 1
    #     ans += 0

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(N):
    temp = [A[i], B[i], C[i]]
    temp = set(temp)
    ans += len(temp)-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] and B[i]==C[i] and C[i]==A[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(input())
a=list(reversed(list(input())))
b=list(reversed(list(input())))
c=list(reversed(list(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 = input()
A = list(input())
B = list(input())
C = list(input())

ans = 0
for a, b, c in zip(A, B, C):
    if len(set([a, b, c])) == 3:
        ans += 2
    elif len(set([a, b, c])) == 2:
        ans += 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 b[i]!=c[i]:
            ans+=1
    else:
        if b[i]==c[i]:
            ans+=1
        elif 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()
ans=0
for i in range(N):
  X=[0]*26
  X[ord(A[i])-ord('a')]+=1
  X[ord(B[i])-ord('a')]+=1
  X[ord(C[i])-ord('a')]+=1
  X.sort()
  ans+=3-X[25]
print(ans)

Submission status: Accepted

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

x = 0
for i,j,k in zip(a,b,c):
    if i != j and j != k and k != i:
        x += 2
    elif i == j and j == k:
        continue
    elif i == j or j == k or k == i:
        x += 1
print(x)

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] or a[i] == c[i] or b[i] == c[i]:
    count += 1
  else:
    count += 2
print(count)

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = str(input().rstrip('\n'))
    b = str(input().rstrip('\n'))
    c = str(input().rstrip('\n'))
    cnt = 0
    for i in range(n):
        s = collections.Counter([a[i], b[i], c[i]])
        if len(s) == 3:
            cnt += 2
        elif len(s) == 2:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: str, B: str, C: str):

    ans = 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 A[i] == C[i]):
            ans += 1
        else:
            ans += 2

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = next(tokens)  # type: str
    B = next(tokens)  # type: str
    C = next(tokens)  # type: str
    solve(N, A, B, C)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans=0
for i in range(n):
    l=set(list(a[i]+b[i]+c[i]))
    if len(l)==3:ans+=2
    elif len(l)==2:ans+=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] and b[i] != c[i] ) or ( b[i] == c[i] and c[i] != a[i] ) or ( c[i] == a[i] and a[i] != b[i] ):
        ans+=1
    elif a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        ans+=2
print(ans)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = str(input().rstrip('\n'))
    b = str(input().rstrip('\n'))
    c = str(input().rstrip('\n'))
    cnt = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            continue
        elif a[i] == b[i]:
            cnt += 1
        elif b[i] == c[i]:
            cnt += 1
        elif a[i] == c[i]:
            cnt += 1
        else:
            cnt += 2
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

ans = 0

for i in range(n):
    temp = set([a[i], b[i], c[i]])
    if len(temp) == 2:
        ans += 1
    elif len(temp) == 3:
        ans += 2

print(ans)

Submission status: Accepted

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


x=0

for i in range(len(a)):
    tmp = []
    tmp.append(a[i])
    tmp.append(b[i])
    tmp.append(c[i])
 
    d = len(list(set(tmp)))
    if d == 1:
        pass
    elif d == 2:
        x += 1
    else:
        x += 2

print(x)

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):
    ans += (len({a, b, c}) - 1)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=[0]*n

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

for i in range(n):
    if s[0][i]==s[1][i] and s[1][i]==s[2][i]:
        ans[i]=0
    elif s[0][i]==s[1][i] or s[0][i]==s[2][i] or s[1][i]==s[2][i]:
        ans[i]=1
    else:
        ans[i]=2

print(sum(ans))

Submission status: Accepted

Solution code:
import sys
def input():
	return sys.stdin.readline().strip()


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]:
		ans += 0
	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,B,C=[input() for i in range(3)]
ans=0
for i in range(N):
    if A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]:
        ans+=2
    elif A[i]!=B[i] or A[i]!=C[i]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

N, A, B, C = int(input()), input(), input(), input()
cnt = 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]) or (A[i] == C[i] and A[i] != B[i]) or (B[i] == C[i] and A[i] != B[i]):
        cnt += 1
    else:
        cnt += 2
print(cnt)

Submission status: Accepted

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

ans=0
for i in range(N):
  if A[i]==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(i,ans)
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    a = input()
    b = input()
    c = input()
    ans = 0
    for ai, bi, ci in zip(a, b, c):
        ans += len({ai, bi, ci}) - 1
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

diff_ch=[]
for i in range(n):
    diff_ch.append(len(set([a[i],b[i],c[i]]))-1)
print(sum(diff_ch))

Submission status: Accepted

Solution code:
# nikkei2019-qualB - Touitsu
def main():
    N, *S = open(0).read().split()
    ans = 0
    for i in zip(*S):
        x = len(set(i))
        if x == 3:
            ans += 2
        elif x == 2:
            ans += 1
    print(ans)


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

Submission status: Accepted

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

ans=0
for i in range(n):
    x,y,z=a[i], b[i], c[i]
    if x==y and y==z:
        continue
    elif x!=y and y!=z and z!=x:
        ans+=2
    else:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    num = int(input())
    data = [input() for i in range(3)]

    ans = 0
    for i in range(num):
        aaa = set([data[0][i], data[1][i], data[2][i]])
        ans += len(aaa) - 1
    print(ans)



if __name__ == '__main__':
    main()
    # test()

Submission status: Accepted

Solution code:

def main():

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

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

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):
	if a[i]==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=input()
B=input()
C=input()

list=[]
for i in range(N):
    a=A[i]
    b=B[i]
    c=C[i]

    if a==b and b==c:
        list.append(0)
    elif (a==b and b!=c) \
        or (a==c and a!=b) \
        or (b==c and a!=c):
        list.append(1)
    elif a!=b and b!=c and c!=a:
        list.append(2)

print(sum(list))

Submission status: Accepted

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

n = int(input())
a = input()
b = input()
c = input()
print(solve(n, a, b, c))

Submission status: Accepted

Solution code:
n = int(input())
a = str(input())
b = str(input())
c = str(input())
result = 0
for i in range(n):
    counter = 1
    if a[i] == b[i]:
        counter += 1
    if a[i] == c[i]:
        counter += 1
    elif b[i] == c[i]:
        counter += 1
    result += abs(3-counter)
print(result)

Submission status: Accepted

Solution code:
n,a,b,c=open(0);print(sum([0,1,2][(len(set(d))>1)+(len(set(d))>2)]for d in zip(a,b,c)))

Submission status: Accepted

Solution code:
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(n):
    ab = a[i] + b[i]
    bc = b[i] + c[i]
    ca = c[i] + a[i]
    count += 2 - max(ab.count(c[i]), bc.count(a[i]), ca.count(b[i]))
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]:
        count += 0
    elif A[i] == B[i] and A[i] != C[i]:
        count += 1
    elif A[i] == C[i] and A[i] != B[i]:
        count += 1
    elif B[i] == C[i] and B[i] != A[i]:
        count += 1
    else:
        count += 2

print(count)

Submission status: Accepted

Solution code:
n=int(input())
da=[input() for i in range(3)]
ans=0
for i in range(n):
    ans+=len(set([da[0][i],da[1][i],da[2][i]]))-1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

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

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

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, b, c = [ input() for i in range(3) ]
print(sum([ len(set([a[i], b[i], c[i]])) - 1 for i in range(n) ]))

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 b[i]!=c[i] and c[i]!=a[i]):
    ans += 2
  elif(not(a[i]==b[i]==c[i])):
    ans += 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] and B[i] != C[i]:
        ans += 1
    elif A[i] != B[i] and B[i] == C[i]:
        ans += 1
    elif A[i] == C[i] and B[i] != C[i]:
        ans += 1
    elif A[i] != B[i] and B[i] != C[i]:
        ans += 2
print(ans)

Submission status: Accepted

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

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

print(ans)

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


ans = 0
for i in range(n):
  array = [a[i],b[i],c[i]]
  setarray = set(array)
  ans += len(setarray)-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):
    ans += len(set([a, b, c])) - 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] == 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=[];b=[2,1,0,0];x=0
for i in range(3):
  a.append(input())
for j in range(n):
  m=0
  if a[0][j]==a[1][j]:m+=1
  if a[1][j]==a[2][j]:m+=1
  if a[2][j]==a[0][j]:m+=1
  x+=b[m]
print(x)

Submission status: Accepted

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

cnt = 0

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

print(cnt)

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=str(input())
B=str(input())
C=str(input())

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
a,b,c = sys.stdin
count = 0
for i in range(n):
  if a[i] == b[i] == c[i]:
    continue
  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 = 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] == 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()

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[input() for i in range(3)]
ans=0
for i in range(n):
  a=set([l[0][i],l[1][i],l[2][i]])
  ans+=len(a)-1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = input().rstrip()
B = input().rstrip()
C = input().rstrip()
ans = 0
for a, b, c in zip(A, B, C):
    if a != b and b != c and c != a:
        ans += 2
    elif (a != b and b !=c) or (b!= c and c != a) or (c != a and a != b):
        ans += 1
print(ans)

Submission status: Accepted

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

count = 0
for n in range(N):
	a, b, c = A[n], B[n], C[n]
	if a == b == c:
		continue
	if a == b or b == c or c == a:
		count += 1
		continue
	count += 2
print(count)

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):
    ans+=len(set((a,b,c)))-1

print(ans)

Submission status: Accepted

Solution code:
# nikkei2019-qualB - Touitsu
def main():
    n = int(input())
    S = [input().rstrip() for _ in range(3)]
    ans = 0
    for i in zip(S[0], S[1], S[2]):
        if len(set(i)) == 3:
            ans += 2
        elif len(set(i)) == 2:
            ans += 1
    print(ans)


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):
  aa,bb,cc=a[i],b[i],c[i]
  if aa==bb:
    if cc!=aa:
      ans+=1
  else:
    if cc!=aa and cc!=bb:
      ans+=2
    else:
      ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=input()
B=input()
C=input()
ans=0
for i,k,t in zip(A,B,C):
  if i==k==t:
    ans=ans
  elif i!=k and k!=t and t!=i:
    ans+=2
  else:
    ans+=1  
print(ans)

Submission status: Accepted

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

ans = 0
for z in zip(A, B, C):
    ans += len(set(z)) - 1
print(ans)