qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
n=int(input())

def ju(n):
    l=list(str(n))
    j=[0]*3
    for i in range(len(l)):
        if l[i]=='3':
            j[0]=1
        elif l[i]=='5':
            j[1]=1
        elif l[i]=='7':
            j[2]=1
    if sum(j)==3:
        return 1
    else:
        return 0

zenbu=[3,5,7]

for i in range(10):
    tmp=[]
    for j in zenbu:
        tmp.append(j*10+3)
        tmp.append(j*10+5)
        tmp.append(j*10+7)
  
ans=0
for i in zenbu:
    if i<=n and ju(i)==1:
        ans+=1
print(ans)
      

# Fixed code:
n=int(input())

def ju(n):
    l=list(str(n))
    j=[0]*3
    f=0
    for i in range(len(l)):
        if l[i]=='3':
            j[0]=1
        elif l[i]=='5':
            j[1]=1
        elif l[i]=='7':
            j[2]=1
        else:
            f=1
    if sum(j)==3 and f==0:
        return 1
    else:
        return 0

zenbu=[3,5,7]

for i in range(8):
    tmp=[]
    for j in zenbu:
        tmp.append(j+3*(10**(i+1)))
        tmp.append(j+5*(10**(i+1)))
        tmp.append(j+7*(10**(i+1)))
        tmp.append(j)
    zenbu=tmp
  
ans=0
for i in zenbu:
    if i<=n and ju(i)==1:
        ans+=1
print(ans)
# Buggy code:
s = input()
l = len(s)
n = int(s)
ans = 0
import itertools
for li in range(3, l+1):
    for i in itertools.product([7, 5, 3], repeat=li):
        if len(set(i)) == 3:
            ans += 1
        num = int(''.join(map(str, i)))
        if num > n:
            continue
print(ans)

# Fixed code:
s = input()
l = len(s)
n = int(s)
ans = 0
import itertools
for li in range(3, l+1):
    for i in itertools.product([7, 5, 3], repeat=li):
        num = int(''.join(map(str, i)))
        if num > n:
            continue
        if len(set(i)) == 3:
            ans += 1
print(ans)
# Buggy code:
from itertools import product
n=int(input())

ans = 0
for i in range(3, 10):
    for s in product('357', repeat=i):
        if len(set(s)) < 3:
            continue
        753num = int(''.join(s))
        if  753num> n:
            break
        ans += 1
print(ans)


# Fixed code:
from itertools import product
n=int(input())

ans = 0
for i in range(3, 10):
    for s in product('357', repeat=i):
        if len(set(s)) < 3:
            continue
        num = int(''.join(s))
        if  num > n:
            break
        ans += 1
print(ans)
# Buggy code:
def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n==0 and num_used==3:
    return 1
  elif n==0 or n+num_used<3:
    return 0
  else:
    a = int(N[0])
    if a > 7:
      return sum([f(i, 0) for i in range(3, n+1)])
    elif a == 7:
      return f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return f(n-1, k|1)
    elif a == 3:
      return solve(N[1:], k|1)
    elif a > 0:
      return 0

N = input()
base = sum([f(i, 0) for i in range(3, len(N))])
print(solve(N) + base)

# Fixed code:
def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n==0 and num_used==3:
    return 1
  elif n==0 or n+num_used<3:
    return 0
  else:
    a = int(N[0])
    if a > 7:
      return f(n-1, k|1) + f(n-1, k|2) + f(n-1, k|4)
    elif a == 7:
      return f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return f(n-1, k|1)
    elif a == 3:
      return solve(N[1:], k|1)
    else:
      return 0

N = input()
base = sum([f(i, 0) for i in range(3, len(N))])
print(solve(N) + base)
# Buggy code:
#coding: utf-8
from collections import Counter
N = int(input())
l = ["0", "3", "5", "7"]
ans = ["0" for _ in range(9)]
cnt = 0
for a in l:
    ans[0] = a
    for b in l:
        ans[1] = b
        for c in l:
            ans[2] = c
            for d in l:
                ans[3] = d
                for e in l:
                    ans[4] = e
                    for f in l:
                        ans[5] = f
                        for g in l:
                            ans[6] = g
                            for h in l:
                                ans[7] = h
                                for i in l:
                                    ans[8] = i
                                    ans_c = Counter(ans)
                                    ans_i = int("".join(ans))
                                    #if ans_i <= N and sum([l[j] in str(ans_i) for j in range(len(l))]) == 3 and len(ans_c.values()) == 3:
                                    if ans_i <= N and "0" not in str(ans_i) and len(ans_c.keys()) == 4 and len(str(ans_i)) >= 3:
                                        cnt += 1
print(cnt)

# Fixed code:
#coding: utf-8
from collections import Counter
N = int(input())
l = ["0", "3", "5", "7"]
ans = ["0" for _ in range(9)]
cnt = 0
for a in l:
    ans[0] = a
    for b in l:
        ans[1] = b
        for c in l:
            ans[2] = c
            for d in l:
                ans[3] = d
                for e in l:
                    ans[4] = e
                    for f in l:
                        ans[5] = f
                        for g in l:
                            ans[6] = g
                            for h in l:
                                ans[7] = h
                                for i in l:
                                    ans[8] = i
                                    ans_i = int("".join(ans))
                                    ans_c = Counter(str(ans_i))
                                    if ans_i <= N and "0" not in str(ans_i) and len(ans_c.keys()) == 3 and len(str(ans_i)) >= 3:
                                        cnt += 1
print(cnt)
# Buggy code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

def main():
  n=I()

  l=[]
  for i in range(pow(4,10)):
    l.append(ten2n(i,4).replace('3','7').replace('2','5').replace('1','3'))

  cnt=0
  for x in l:
    if int(x)<=n:
      if '3' in x and '5' in x and '7' in x and '0' not in x:
        cnt+=1
    else:
      break

  return cnt

print(main())


# Fixed code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

def main():
  n=I()

  l=[]
  for i in range(pow(4,9)):
    l.append(ten2n(i,4).replace('3','7').replace('2','5').replace('1','3'))

  cnt=0
  for x in l:
    if int(x)<=n:
      if '3' in x and '5' in x and '7' in x and '0' not in x:
        cnt+=1
    else:
      break

  return cnt

print(main())
# Buggy code:
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = input()
n = int(N)
ans = 0
for i in range(len(N)+1):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)


# Fixed code:
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = input()
n = int(N)
ans = 0
for i in range(3, len(N)+1):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)
# Buggy code:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

return(dfs('0'))

# Fixed code:
N = int(input())
 
def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

print(dfs('0'))
# Buggy code:
n = int(input())

def bfs(s):
  if int(s) >= n:
    return 0
  return ('3' in s and '5' in s and '7' in s) + bfs(s+'3') + bfs(s+'5') + bfs(s+'7')

print(bfs(''))

# Fixed code:
n = int(input())
 
def bfs(s):
  if int(s) > n:
    return 0
  return ('3' in s and '5' in s and '7' in s) + bfs(s+'3') + bfs(s+'5') + bfs(s+'7')
 
print(bfs('0'))
# Buggy code:
N=int(input())

def dfs(cur,use,counter):
    if cur>N:
        return 0
    
    if use==0b111:
        counter=1

    counter+=dfs(cur*10+7,use | 0b001, counter)
    counter+=dfs(cur*10+5,use | 0b010, counter)
    counter+=dfs(cur*10+3,use | 0b100, counter)

    return counter

print(dfs(0,0,0))


# Fixed code:
N=int(input())

def dfs(cur,use,counter):
    if cur>N:
        return 0
    
    counter=int(use==0b111)

    counter+=dfs(cur*10+7,use | 0b001, counter)
    counter+=dfs(cur*10+5,use | 0b010, counter)
    counter+=dfs(cur*10+3,use | 0b100, counter)

    return counter

print(dfs(0,0,0))
# Buggy code:
n=int(input())
import bisect
import itertools
ans=[]
num=[]
for i in range(3,l+1):
    m=list(itertools.product(x, repeat=i))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_left(ans, n))

# Fixed code:
n=int(input())
import bisect
import itertools
l=len(str(n))
ans=[]
num=[]
x=['3', '5', '7']
for k in range(3,l+1):
    m=list(itertools.product(x, repeat=k))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_right(ans, n))
# Buggy code:
def p_c():
    import sys
    sys.setrecursionlimit(10 ** 9)
    n = int(input())
    ans = 0

    def dfs(s):
        """
        :type s: str
        """
        if int(s) > n:
            return 0
        ret = 1 if all(s.count(c) for c in "753") else 0
        for c in "753":
            ret += dfs(s.join(c))
        return ret

    print(dfs("0"))
    
p_c()

# Fixed code:
def p_c():
    import sys
    sys.setrecursionlimit(10 ** 9)
    n = int(input())
    ans = 0

    def dfs(s):
        """
        :type s: str
        """
        if int(s) > n:
            return 0
        ret = 1 if all(s.count(c) for c in "753") else 0
        for c in "753":
            ret += dfs(s + c)
        return ret

    print(dfs("0"))
    
p_c()
# Buggy code:
import itertools as t;N=input();X=[];for i in range(9):X+=list(t.product('357',repeat=i));print(sum(len(set(i))>2and int(''.join(i))<=int(N)for i in X))

# Fixed code:
import itertools as t;N=input();X=[]
for i in range(10):X+=list(t.product('357',repeat=i))
print(sum(len(set(i))>2and int(''.join(i))<=int(N)for i in X))
# Buggy code:
N = int(input())
def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0
    for c in '753':
        ret += dfs(s+c)

print(dfs('0'))

# Fixed code:
N = int(input())


def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s + c)
    return ret

print(dfs("0"))
# Buggy code:
n = int(input())
 
def dfs(s):
    print(s)
    if int(s) > n:
        return 0
    if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
        cnt = 1
    else:
        cnt = 0
    cnt += dfs(s + '3')
    cnt += dfs(s + '5')
    cnt += dfs(s + '7')
    return cnt
 
 
print(dfs('0'))

# Fixed code:
n = int(input())
 
def dfs(s):

    if int(s) > n:
        return 0
    if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
        cnt = 1
    else:
        cnt = 0
    cnt += dfs(s + '3')
    cnt += dfs(s + '5')
    cnt += dfs(s + '7')
    return cnt
 
 
print(dfs('0'))
# Buggy code:
n = int(input())

import bisect
l = []
def dfs(num, index):
    if index == 9:
        if (num.find("3") != -1) and (num.find("5") != -1) and (num.find("7") != -1):
            l.append(int(num))
        return 0
        
    if num == "":
        ret0 = dfs(num + "" , index+1)
    ret1 = dfs(num + "3", index+1)
    ret2 = dfs(num + "5", index+1)
    ret3 = dfs(num + "7", index+1)

    return 0

dfs("", 0)

count = bisect.bisect_left(l,n)
count += 1 if n == l[bisect.bisect_left(l,n)] else 0
print (count)

# Fixed code:
n = int(input())

import bisect
l = []
def dfs(num, index):
    if index == 9:
        if (num.find("3") != -1) and (num.find("5") != -1) and (num.find("7") != -1):
            l.append(int(num))
        return 0
        
    if num == "":
        ret0 = dfs(num + "" , index+1)
    ret1 = dfs(num + "3", index+1)
    ret2 = dfs(num + "5", index+1)
    ret3 = dfs(num + "7", index+1)

    return 0

dfs("", 0)

print (bisect.bisect_right(l,n))
# Buggy code:
# coding: utf-8
import itertools
N = input()
ans = 0

for i in range(3, len(N)+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)

# Fixed code:
# coding: utf-8
import itertools
N = int(input())
ans = 0

for i in range(3, len(str(N))+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)
# Buggy code:
N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0

        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
            print(str(i))
        if flag == 0:
            i += 1
        if N <= i:
            break

print(count)

# Fixed code:
N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0
        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N < i:
            break

print(count)
# Buggy code:
import itertools
n=str(input())
ans=0
for i in range(3,len(n)+1):
    for j in itertools.product([3,5,7], repeat=i):
        if (3 not in j) or (5 not in j) or (7 not in j):
            continue
        a=''.join(list(map(str,j)))
        if a<=n:
            ans+=1
print(ans)

    

# Fixed code:
import itertools
n=str(input())
ans=0
for i in range(3,len(n)+1):
    for j in itertools.product([3,5,7], repeat=i):
        if (3 not in j) or (5 not in j) or (7 not in j):
            continue
        a=''.join(list(map(str,j)))
        if int(a)<=int(n):
            ans+=1
print(ans)
# Buggy code:
n=int(input())

def dfs(s):
  if n<int(s) : return 0
  res = if all(s.count(c) for c in "753") : 1 else 0
  for i in "753":
    res += dfs(s+i)
  return res

print(dfs("0"))

# Fixed code:
n=int(input())

def dfs(s):
  if n<int(s) : return 0
  res = 1 if all(s.count(c)>0 for c in "753") else 0
  for i in "753":
    res += dfs(s+i)
  return res

print(dfs("0"))
# Buggy code:
n = input()

def f(s):
    if int(s) > int(n):
        return 0
    if all(['3' in s,'5' in s,'7' in s]):
        ans += 1
    for t in '3','5','7':
        f(s+t)

ans = 0
f('0')
print(ans)


# Fixed code:
n = input()

def f(s):
    if int(s) > int(n):
        return 0
    if all(['3' in s,'5' in s,'7' in s]):
        ans.append(1)
    for t in '3','5','7':
        f(s+t)

ans=[]
f('0')
print(sum(ans))
# Buggy code:
n = input()
n.replace('1', 'x')
n.replace('9', '1')
n.replace('x', '9')
print(int(n))

# Fixed code:
n = str(input())
n = n.replace("1", "x")
n = n.replace('9', '1')
n = n.replace('x', '9')
print(int(n))
# Buggy code:
n = input()
r = [10 - int(n[i]) for i in range(n)]
print("".join(map(str, r)))



# Fixed code:
n = input()
r = [10 - int(n[i]) for i in range(3)]
print("".join(map(str, r)))
# Buggy code:
s = list(input())
for i in range(len(s)):
  if ls[i] == "9":
    ls[i] = "1"
  elif ls[i] == "1":
    ls[i] = "9":
for i in s:
  print(i,end="")

# Fixed code:
s = list(input())
for i in range(len(s)):
    if s[i] == "9":
        s[i] = "1"
    elif s[i] == "1":
        s[i] = "9"
for i in s:
    print(i,end="")
# Buggy code:
n = input()
n.replace('1', '2')
n.replace('9', '1')
n.replace('2', '9')
print(n)

# Fixed code:
n = input()
n = n.replace('1', '2')
n = n.replace('9', '1')
n = n.replace('2', '9')
print(n)
# Buggy code:
input = str(input())
input.replace('9', '_').replace('1', '9').replace('_', '1')
print(input)

# Fixed code:
input = str(input())
input = input.replace("9", "_")
input = input.replace("1", "9")
input = input.replace("_", "1")
print(input)
# Buggy code:
n = str(input())

ans = 0
if n[0] == "1":
    ans += 900
else:
    ans += 100

if n[0] == "1":
    ans += 90
else:
    ans += 10

if n[0] == "1":
    ans += 9
else:
    ans += 1

print(ans)

# Fixed code:
n = str(input())

ans = 0
if n[0] == "1":
    ans += 900
else:
    ans += 100

if n[1] == "1":
    ans += 90
else:
    ans += 10

if n[2] == "1":
    ans += 9
else:
    ans += 1

print(ans)
# Buggy code:
s = input()
l = ""
for i in range(3):
  if s[0] == "1":
    l += "9"
  else:
    l += "1"
    
print(l)

# Fixed code:
s = input()
l = ""
for i in range(3):
  if s[i] == "1":
    l += "9"
  else:
    l += "1"
    
print(int(l))
# Buggy code:
n = input()
ln = list(n)

for i in range(len(ln)):
    if ln[i] == '1':
        ln[i] = '9'
    elif ln[i] == '9':
        ln[i] = '1'
        
n = ''.join(ln)
print(n = ''.join(ln))

# Fixed code:
n = input()
ln = list(n)
 
for i in range(len(ln)):
    if ln[i] == '1':
        ln[i] = '9'
    elif ln[i] == '9':
        ln[i] = '1'
        
n = ''.join(ln)
print(int(n))
# Buggy code:
a=input()
a.replace(9,8)
a.replace(1,9)
a.replace(8,1)
print(a)

# Fixed code:
a=input()
print(a.replace("1","8").replace("9","1").replace("8","9"))
# Buggy code:
text = list(input())

def swap(char, a, b):
    if char == a:
        return(b)
    if char == b:
        return(a)

res = list(map(lambda x: swap(x, "1", "9"), text))
print("".join(res))
~                     

# Fixed code:
text = list(input())

def swap(char, a, b):
    if char == a:
        return(b)
    if char == b:
        return(a)

res = list(map(lambda x: swap(x, "1", "9"), text))
print("".join(res))
# Buggy code:
n = input()
ans = ""

for i in range(3):
    if n[i] == 1:
        ans = ans + "9"
    else:
        ans = ans + "1"

print(ans)

# Fixed code:
s = input()
ans = ""

for i in range(3):
    if s[i] == "1":
        ans = ans + "9"
    else:
        ans = ans + "1"

print(ans)
# Buggy code:
n = input()
s = ''
for c in n:
  if c == '1':
    s += '9'
  else:
  	if c == '9':
    	s += '1'
    else:
      s += c
print(s)
  

# Fixed code:
n = input()
s = ''
for c in n:
  if c == '1':
    s += '9'
  else:
    if c == '9':
        s += '1'
    else:
        s += c
print(s)
# Buggy code:
N=input()
answer=""
if N[0]==1:
  answer+="9"
else:
  answer+="1"
if N[1]==1:
  answer+="9"
else:
  answer+="1"
if N[1]==1:
  answer+="9"
else:
  answer+="1"
print(answer)

# Fixed code:
N=input()
answer=""
if N[0]=="1":
  answer+="9"
else:
  answer+="1"
if N[1]=="1":
  answer+="9"
else:
  answer+="1"
if N[2]=="1":
  answer+="9"
else:
  answer+="1"
print(answer)
# Buggy code:
print(input().replace('1', '9').replace('9', '1'))

# Fixed code:
print(input().replace('1', 'o').replace('9', '1').replace('o', '9'))
# Buggy code:
n=int(input())
for i in range(len(n)):
  if n[i] == 1:print(9,end='')
  else:print(print(1,end=''))

# Fixed code:
n=input()
for i in range(3):
  if int(n[i]) == 1:print(9,end='')
  else:print(1,end='')
# Buggy code:
n=input()
print(n.replace("1","x").replace("9","1").replace("x","1"))

# Fixed code:
n=input()
print(n.replace("9","x").replace("1","9").replace("x","1"))
# Buggy code:
n=input()
n.replace('1','a')
n.replace('9','1')
n.replace('a','9')
print(n)

# Fixed code:
n=input()
n=n.replace('9','a')
n=n.replace('1','9')
n=n.replace('a','1')
print(n)
# Buggy code:
n = list(map( int, split()))
 
h = 3
for i in range(h):
  if( n[i] == 1):
    n[i] = 9
    n[i] = str(n[i])   
  else:
    n[i] = 1
    n[i] = str(n[i])
    
a = "".join(n)
 
print(a)

# Fixed code:
n = list(map( int, input()))
 
h = 3
for i in range(h):
  if( n[i] == 1):
    n[i] = 9
    n[i] = str(n[i])   
  else:
    n[i] = 1
    n[i] = str(n[i])
    
a = "".join(n)
 
print(a)
# Buggy code:
c=list(input())
ans=str()
for i in range(len(c)):
    if c[i]=='9':
        c[i]='1'
    ans+=c[i]
print(int(ans))

# Fixed code:
c=list(input())
ans=str()
ans=str()
for i in range(len(c)):
    if c[i]=='9':
        c[i]='1'
    else:
        c[i]='9'
        
    ans+=c[i]
    
print(int(ans))
# Buggy code:
from functools import reduce

N = int(input())
N_list = [int(x) for x in list(str(N))]

N_ = []
for i in N_list:
    print("i", i)
    if i == 1:
        i = 9
    elif i == 9:
        i = 1
    N_.append(i)

new_N = int(reduce(lambda x,y: x+y, [str(x) for x in N_]))

print(new_N)

# Fixed code:
from functools import reduce

N = int(input())
N_list = [int(x) for x in list(str(N))]

N_ = []
for i in N_list:
    if i == 1:
        i = 9
    elif i == 9:
        i = 1
    N_.append(i)

new_N = int(reduce(lambda x,y: x+y, [str(x) for x in N_]))

print(new_N)
# Buggy code:
n = input()

def change(d):
  if d == '1':
    return '9'
  elif d == '9':
   	return '1'
  else
  	return d

print(''.join([change(d) for d in n]))

# Fixed code:
n = input()

def change(d):
  if d == '1':
    return '9'
  elif d == '9':
    return '1'
  else:
    return d

print(''.join([change(d) for d in n]))
# Buggy code:
n=int(input())

N=[0]*3
m=[0]*3

N[0]=int(n/10)
N[1]=int(N[0]/10)
N[2]=int(N[1]/10)

m[0]=int(n%10)
m[1]=int(N[0]%10)
m[2]=int(N[1]%10)

for i in range(0,3):
    if m[i]==1:
        m[i]=9
    elif [i]==9:
        m[i]=1
print(N[0],N[1],N[2])        
print(m[0],m[1],m[2])
print(int(m[2]*100+m[1]*10+m[0]))

# Fixed code:
n=int(input())

N=[0]*3
m=[0]*3

N[0]=int(n/10)
N[1]=int(N[0]/10)
N[2]=int(N[1]/10)

m[0]=int(n%10)
m[1]=int(N[0]%10)
m[2]=int(N[1]%10)

for i in range(0,3):
    if m[i]==1:
        m[i]=9
    elif m[i]==9:
        m[i]=1

print(int(m[2]*100+m[1]*10+m[0]))
# Buggy code:
num = input()
lis = ""

for i in num:
    if i == "1":
        lis+="9"
    else:
        lis+="1"

print(int(num))

# Fixed code:
num = input()
lis = ""

for i in num:
    if i == "1":
        lis+="9"
    else:
        lis+="1"

print(int(lis))
# Buggy code:
N=input()
ans=[]
for i in range(len(N)):
  if N[i]=="0":
    ans.append(9)
  else:
    ans.append(0)
print(*ans,sep="")

# Fixed code:
N=input()
ans=[]
for i in range(len(N)):
  if N[i]=="1":
    ans.append(9)
  else:
    ans.append(1)
print(*ans,sep="")
# Buggy code:
n=input()
d={"9":"1","1":"9"}
"".join(d[x] for in n)

# Fixed code:
n=input()
d={"9":"1","1":"9"}
print("".join(d[x] for x in n))