Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nn = 0
i = 357

while i <= n:
  s = str(i)
  if '3' in s:
    if '5' in s:
      if '7' in s:
        if ('0' in s or '1' in s or '2' in s or '4' in s or '6' in s or '8' in s or '9' in s) is False:
          #print(i)
          nn += 1
  if i % 10 == 7:
    i += 6
  else:
    i +=2
print(nn)

Fixed submission:
def nextn(n):
    if n == 0:
        return 3
    elif n % 10 == 3:
        return n+2
    elif n % 10== 5:
        return n+2
    elif n % 10 ==7:
        return nextn(n//10)*10 + 3

N = int(input())
n = 357
ans = 0
while n <= N:
    s = str(n)
    a = [False,False,False]
    for c in s:
        if c == '3':
            a[0] = True
        elif c == '5':
            a[1] = True
        elif c == '7':
            a[2] = True
        else:
            print(s)
    if all(a):
        ans += 1
    n = nextn(n) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nn = 0
i = 357

while i <= n:
  s = str(i)
  if ('0' in s or '1' in s or '2' in s or '4' in s or '6' in s or '8' in s or '9' in s) is False:
    if '3' in s:
      if '5' in s:
        if '7' in s:
          #print(i)
          nn += 1
  if i % 10 == 7:
    i += 6
  else:
    i +=2
print(nn)

Fixed submission:
def nextn(n):
    if n == 0:
        return 3
    elif n % 10 == 3:
        return n+2
    elif n % 10== 5:
        return n+2
    elif n % 10 ==7:
        return nextn(n//10)*10 + 3

N = int(input())
n = 357
ans = 0
while n <= N:
    s = str(n)
    a = [False,False,False]
    for c in s:
        if c == '3':
            a[0] = True
        elif c == '5':
            a[1] = True
        elif c == '7':
            a[2] = True
        else:
            print(s)
    if all(a):
        ans += 1
    n = nextn(n) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nn = 0

if n >= 357:
    for i in range(357,n+1):
        s = str(i)
        if ('0' in s or '1' in s or '2' in s or '4' in s or '6' in s or '8' in s or '9' in s) is False:
            if '3' in s:
              if '5' in s:
                if '7' in s:
                  #print(i)
                  nn += 1
print(nn)

Fixed submission:
def nextn(n):
    if n == 0:
        return 3
    elif n % 10 == 3:
        return n+2
    elif n % 10== 5:
        return n+2
    elif n % 10 ==7:
        return nextn(n//10)*10 + 3

N = int(input())
n = 357
ans = 0
while n <= N:
    s = str(n)
    a = [False,False,False]
    for c in s:
        if c == '3':
            a[0] = True
        elif c == '5':
            a[1] = True
        elif c == '7':
            a[2] = True
        else:
            print(s)
    if all(a):
        ans += 1
    n = nextn(n) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nn = 0

if n >= 357:
    for i in range(357,n+1):
        s = str(i)
        if ('0' in s or '1' in s or '2' in s or '4' in s or '6' in s or '8' in s or '9' in s) is False:
            if '3' in s and '5' in s and '7' in s:
                #print(i)
                nn += 1
print(nn)

Fixed submission:
def nextn(n):
    if n == 0:
        return 3
    elif n % 10 == 3:
        return n+2
    elif n % 10== 5:
        return n+2
    elif n % 10 ==7:
        return nextn(n//10)*10 + 3

N = int(input())
n = 357
ans = 0
while n <= N:
    s = str(n)
    a = [False,False,False]
    for c in s:
        if c == '3':
            a[0] = True
        elif c == '5':
            a[1] = True
        elif c == '7':
            a[2] = True
        else:
            print(s)
    if all(a):
        ans += 1
    n = nextn(n) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nn = 0

if n >= 357:
    for i in range(357,n+1):
        s = str(i)
        if '3' in s and '5' in s and '7' in s:
            if ('0' in s or '1' in s or '2' in s or '4' in s or '6' in s or '8' in s or '9' in s) is False:
                #print(i)
                nn += 1
print(nn)

Fixed submission:
def nextn(n):
    if n == 0:
        return 3
    elif n % 10 == 3:
        return n+2
    elif n % 10== 5:
        return n+2
    elif n % 10 ==7:
        return nextn(n//10)*10 + 3

N = int(input())
n = 357
ans = 0
while n <= N:
    s = str(n)
    a = [False,False,False]
    for c in s:
        if c == '3':
            a[0] = True
        elif c == '5':
            a[1] = True
        elif c == '7':
            a[2] = True
        else:
            print(s)
    if all(a):
        ans += 1
    n = nextn(n) 
print(ans)