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

count = [0*[10] for i in range(10)]

for i in range(1,n+1):
    first = int(str(i)[0])
    last = int(str(i)[-1])

    if first == 0 or last == 0:
        continue
    else:
        count[first][last] += 1

ans = 0
for first in range(1,10):
    ans += count[first][last] * count[last][first]

print(ans)

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

count = [[0]*10 for i in range(10)]

for i in range(1,n+1):
    first = int(str(i)[0])
    last = int(str(i)[-1])

    if first == 0 or last == 0:
        continue
    else:
        count[first][last] += 1

ans = 0
for first in range(1,10):
  for last in range(1,10):
    ans += count[first][last] * count[last][first]
print(ans)
# Buggy code:
n = int(input())

table = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n+1):
    i = str(i)
    a, b = i[0], i[-1]
    table[a][b] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += table[i][j] * table[j][i]

print(ans)


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

table = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n+1):
    i = str(i)
    a, b = int(i[0]), int(i[-1])
    table[a][b] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += table[i][j] * table[j][i]

print(ans)
# Buggy code:
n=int(input())
l=[[0]*9]*9
for  i in range(1,n):
  if i%10:
    l[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
ans=0
for i in range(9):
  for j in range(9):
    ans+=l[i][j]*l[j][i]
print(ans)

# Fixed code:
n=int(input())
l=[[0 for i in range(10)]for s in range(10)]
for  i in range(n+1):
  if i%10:
    l[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
ans=0
for i in range(9):
  for j in range(9):
    ans+=l[i][j]*l[j][i]
print(ans)
# Buggy code:
N = int(input())
sample = [0] * 100

for i in range(1,N+1):

    num = str(i)
    first = num[0]
    final = num[-1]
    print(first)
    print(final)

    sample[int(first+final)] += 1
    print(int(first+final))

ans = 0

for i in range(1,10):
    for j in range(1,10):
        ans += sample[int(str(i)+str(j))] * sample[int(str(j)+str(i))]

print(ans)


    


# Fixed code:
N = int(input())
sample = [0] * 100

for i in range(1,N+1):

    num = str(i)
    first = num[0]
    final = num[-1]
    
    sample[int(first+final)] += 1

ans = 0

for i in range(1,10):
    for j in range(1,10):
        ans += sample[int(str(i)+str(j))] * sample[int(str(j)+str(i))]

print(ans)
# Buggy code:
N = int(input())
ans = 0
for i in range(1,N+1):
    L = int(str(i)[0])
    R = int(str(i)[-1])
    if R == 0:
        continue
    if L == R:
        ans += 1
    for j in range(1,6):
        mini = R*10**j +L
        maxi = (R+1)*10**j +L-10
        if N < mini:
            break
        if maxi <= N:
            ans += 10**(j-1)
            continue
        tmp = int(str(N)[1:-1])
        if L <= int(str(N)[-1]):
            ans += tmp
        else:
            ans += tmp-1
        break
print(ans)


# Fixed code:
N = int(input())
ans = 0
tmp = int("0"+str(N)[1:-1])
NR = int(str(N)[-1])
for i in range(1,N+1):
    L = int(str(i)[0])
    R = int(str(i)[-1])
    if R == 0:
        continue
    if L == R:
        ans += 1
    for j in range(1,6):
        mini = (R*10**j) +L
        maxi = ((R+1)*10**j) +L-10
        if N < mini:
            break
        if maxi <= N:
            ans += 10**(j-1)
            continue
        
        if L <= NR:
            ans += tmp+1
        else:
            ans += tmp
        break
print(ans)
# Buggy code:
dic={}
for i in range(1,10):
  for j in range(0,10):
    dic[(i,j)]=0

N=int(input())
for i in range(1,min([N,10])):
  dic[(i,i)]+=1
for i in range(10,min([N,100])):
  dic[(i//10,i%10)]+=1
for i in range(100,min([N,1000])):
  dic[(i//100,i%10)]+=1
for i in range(1000,min([N,10000])):
  dic[(i//1000,i%10)]+=1
for i in range(10000,min([N,100000])):
  dic[(i//10000,i%10)]+=1
for i in range(100000,N):
  dic[(i//100000,i%10)]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    x=dic[(i,j)]
    y=dic[(j,i)]
    ans+=x*y
print(ans)


# Fixed code:
dic={}
for i in range(1,10):
  for j in range(0,10):
    dic[(i,j)]=0

N=int(input())
for i in range(1,min([N+1,10])):
  dic[(i,i)]+=1
for i in range(10,min([N+1,100])):
  dic[(i//10,i%10)]+=1
for i in range(100,min([N+1,1000])):
  dic[(i//100,i%10)]+=1
for i in range(1000,min([N+1,10000])):
  dic[(i//1000,i%10)]+=1
for i in range(10000,min([N+1,100000])):
  dic[(i//10000,i%10)]+=1
for i in range(100000,N+1):
  dic[(i//100000,i%10)]+=1
  
ans=0
for i in range(1,10):
  for j in range(1,10):
    x=dic[(i,j)]
    y=dic[(j,i)]
    ans+=x*y
print(ans)
# Buggy code:
n=int(input())
ans=-1
c=[[0]*10for i in range(10)]
for i in range(n):c[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
for i in range(10):
 for j in range(10):ans+=c[i][j]*c[j][i]
print(ans)

# Fixed code:
n=int(input())
ans=-1
c=[[0]*10for i in range(11)]
for i in range(n+1):c[int(str(i)[0])][int(str(i)[-1])]+=1
for i in range(10):
 for j in range(10):ans+=c[i][j]*c[j][i]
print(ans)
# Buggy code:
N = int(input())

import numpy as np

X = np.arange(N+1)
A = X.copy()

for i in [1,10,100,1000,10000]:
    A[i:i*10] = X[i:i*10] // i
B = X % 10
C = np.zeros((10,10), dtype=int)

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

for i in range(10):
    for j in range(10):
        count += C[i][j] * C[j][i]
print(count)

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

import numpy as np

X = np.arange(N+1)
A = X.copy()

for i in [1,10,100,1000,10000,100000]:
    A[i:i*10] = X[i:i*10] // i
B = X % 10

C = np.zeros((10,10), dtype=int)

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

for i in range(10):
    for j in range(10):
        count += C[i][j] * C[j][i]

print(count)
# Buggy code:
import math
a=int(input())
ans=0
c=[[0 for i in range(10)] for j in range(10)]
for i in range(1,a):
  aa=str(i)
  c[int(aa[0])][int(aa[-1])]+=1
for i in range(10):
  for j in range(10):
    ans+=c[i][j]*c[j][i]
    
print(ans)

# Fixed code:
import math
a=int(input())
ans=0
c=[[0 for i in range(10)] for j in range(10)]
for i in range(1,a+1):
  aa=str(i)
  c[int(aa[0])][int(aa[-1])]+=1
for i in range(10):
  for j in range(10):
    ans+=c[i][j]*c[j][i]
print(ans)
# Buggy code:
N = int(input())
Cij = [[0 for _ in range(N)] for _ in range(N)]
for i in range(1,N+1):
  a, b = int(str(i)[0]), int(str(i)[-1])
  Cij[a][b] += 1
print(sum(Cij[i][j]*Cij[j][i] for i in range(N) for j in range(N)))

# Fixed code:
N = int(input())
Cij = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,N+1):
  a, b = int(str(i)[0]), int(str(i)[-1])
  Cij[a][b] += 1
print(sum(Cij[i][j]*Cij[j][i] for i in range(10) for j in range(10)))
# Buggy code:
N = int(input())

ans = 0
C = [ [0 for i in range(10)] for i in range(10)]

for i in range(1,N):
  first_num = int(str(i)[0])
  last_num = int(str(i)[-1])
  C[first_num][last_num] += 1

for first_num in range(10):
  for last_num in range(10):
    ans += C[first_num][last_num] * C[last_num][first_num]

print(ans)


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

ans = 0
C = [ [0 for i in range(10)] for i in range(10)]

for i in range(1,N+1):
  first_num = int(str(i)[0])
  last_num = int(str(i)[-1])
  C[first_num][last_num] += 1

for first_num in range(1,10):
  for last_num in range(1,10):
    ans += C[first_num][last_num] * C[last_num][first_num]

print(ans)
# Buggy code:
n=int(input())
D=[[0 for _ in range(9)] for _ in range(9)]
for i in range(n):
    s=str(n)
    D[s[0]][s[-1]]+=1
a=0
for i in range(1,10):
    for j in range(1,10):
        a+=D[i][j]*D[j][i]
print(a)

# Fixed code:
n=int(input())
D=[[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
    s=str(i)
    D[int(s[0])][int(s[-1])]+=1
a=0
for i in range(10):
    for j in range(10):
        a+=D[i][j]*D[j][i]
print(a)
# Buggy code:
[[0 for _ in range(9)] for _ in range(9)]

for i in range(1,n+1):
  x=int(str(i)[0])
  y=int(str(i)[-1])
  if x!=0 and y!=0:
    a[x-1][y-1]+=1
  
ans=0
  
for i in range(9):
  for j in range(9):
    if i!=j:
      
      ans+=a[i][j]*a[j][i]
      
    else:
      ans+=(a[i][i]*a[i][i])
      
print(ans)

# Fixed code:
n=int(input())
a=[[0 for _ in range(9)] for _ in range(9)]

for i in range(1,n+1):
  x=int(str(i)[0])
  y=int(str(i)[-1])
  if x!=0 and y!=0:
    a[x-1][y-1]+=1
  
ans=0
  
for i in range(9):
  for j in range(9):
    if i!=j:
      
      ans+=a[i][j]*a[j][i]
      
    else:
      ans+=(a[i][i]*a[i][i])
      
print(ans)
# Buggy code:
N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)


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

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, N+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)
# Buggy code:
N = int(input())
ans = 0
for n in range(1,N+1):
    if n%10==0:continue
    s = str(n)
    if s[0]==s[-1]:
        if int(s[0])<=N:ans+=1
    for i in range(10):
        a = int(s[-1]+"9"*i+s[0])
        b = int(s[-1]+"0"*i+s[0])
        if a<=N:ans+=pow(10,i)
        else:
            if b<=N:ans+=(N-a)//10+1
            break
print(ans)

# Fixed code:
N = int(input())
ans = 0
for n in range(1,N+1):
    if n%10==0:continue
    s = str(n)
    if s[0]==s[-1]:ans+=1
    for i in range(10):
        a = int(s[-1]+"9"*i+s[0])
        b = int(s[-1]+"0"*i+s[0])
        if a<=N:ans+=pow(10,i)
        elif b<=N:
            ans+=(N-b)//10+1
        else:
            break
print(ans)
# Buggy code:
n=int(input())
cnt=[[0 for i in range(10)] for j in range(n)]

for i in range(1,n+1):
  s=str(i)
  head=int(s[0])
  tail=int(s[-1])
  cnt[head][tail]+=1

ans=0
for h in range(0,10):
  for t in range(0,10):
    ans+=cnt[h][t]*cnt[t][h]
print(ans)

# Fixed code:
n=int(input())
cnt=[[0 for i in range(10)] for j in range(10)]

for i in range(1,n+1):
  s=str(i)
  head=int(s[0])
  tail=int(s[-1])
  cnt[head][tail]+=1

ans=0
for h in range(0,10):
  for t in range(0,10):
    ans+=cnt[h][t]*cnt[t][h]
print(ans)
# Buggy code:
n = int(input())
cnt = [[0] * 10 for i in range(10)]
for i in range(1,n+1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1

print(cnt)
    
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

# Fixed code:
n = int(input())
cnt = [[0] * 10 for i in range(10)]
for i in range(1,n+1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1
    
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)
# Buggy code:
n=int(input())
ans=0
dp=[]
for i in range(10):
  dp.append(i)
l=len(str(n))
for i in range(11,n+1):
  num1=int(str(i)[0])
  num2=int(str(i)[-1])
  if num2==0:
    dp.append(dp[-1])
    pass
  else: 
    num=dp[-1]
    nums=0
    l=len(str(i))
    for j in range(2,l):
      nums+=10**(j-2)     
    if num2>num1:
      num4=0
    elif num1>num2:
      num4=10**(l-2)
    else:
      num4=(i-(num2*10**(l-1)+num1))//10
    nums+=num4
    #print(nums)
    num+=nums*2
    if num1==num2:
      num+=3
    dp.append(num)
print(dp[-1])
#print(dp)

# Fixed code:
n=int(input())
ans=0
dp=[]
for i in range(10):
  dp.append(i)
l=len(str(n))
for i in range(10,n+1):
  num1=int(str(i)[0])
  num2=int(str(i)[-1])
  if num2==0:
    dp.append(dp[-1])
    pass
  else: 
    num=dp[-1]
    nums=0
    l=len(str(i))
    for j in range(2,l):
      nums+=10**(j-2)     
    if num2>num1:
      num4=0
    elif num1>num2:
      num4=10**(l-2)
    else:
      num4=(i-(num2*10**(l-1)+num1))//10
    nums+=num4
    #print(nums)
    num+=nums*2
    if num1==num2:
      num+=3
    dp.append(num)
print(dp[n])
# Buggy code:
N = int(input())


c = []
for i in range(10):
    c.append([0] * 10)

for i in range(1,N):
    s = str(i)
    i1 = int(s[0])
    i2 = int(s[-1])
    c[i1][i2] += 1
    
total = 0
for i in range(10):
    for j in range(10):
        total += c[i][j] * c[j][i]
        
print(total)

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

c = []
for i in range(10):
    c.append([0] * 10)

for i in range(N):
    s = str(i+1)
    i1 = int(s[0])
    i2 = int(s[-1])
    c[i1][i2] += 1
    
total = 0
for i in range(10):
    for j in range(10):
        total += c[i][j] * c[j][i]
        
print(total)
# Buggy code:
N = int(input())

ans_list = [[0 for i in range(10)] for i in range(10)]

for i in range(N):
    s = str(i)
    ans_list[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += ans_list[i][j]*ans_list[j][i]

print(ans)

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

ans_list = [[0 for i in range(10)] for j in range(10)]

for i in range(1,N):
    s = str(i)
    ans_list[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(0,10):
    for j in range(0,10):
        ans += ans_list[i][j]*ans_list[j][i]

print(ans)
# Buggy code:

n = int(input())

number = [[0]*10 for _ in range(10)]

for _ in range(1, n+1):

    s=str(i)
    i=int(s[0])
    j=int(s[-1])

    number[i][j] += 1

count = 0
for i in range(10):

    for j in range(10):
        count += number[i][j]*number[j][i]

print(count)

# Fixed code:

n = int(input())

number = [[0]*10 for _ in range(10)]

for _ in range(1, n+1):

    s=str(_)
    i=int(s[0])
    j=int(s[-1])

    number[i][j] += 1

count = 0
for i in range(10):

    for j in range(10):
        count += number[i][j]*number[j][i]

print(count)
# Buggy code:
x = int(input())

for i in range(x, 10**5):
    flag = True
    for j in range(2, i):
        if (i % j == 0):
            flag = False
            continue
    if flag:
        print(i)
        break
    else:
        continue
            

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

for i in range(x, 10**5 + 4):
    flag = True
    for j in range(2, i):
        if (i % j == 0):
            flag = False
            continue
    if flag:
        print(i)
        break
    else:
        continue
# Buggy code:
x = int(input())

ans = 0

def prime(x):
    y = x//2+1
    cnt = 0
    for i in range(2,y+1):
        if x%i==0:
            cnt += 1
            
    if cnt == 0:
        return x
    else:
        return 0
        
while ans == 0:
    ans = prime(x)
    x += 1
    
print(ans)

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

ans = 0

def prime(x):
    y = x//2+1
    cnt = 0
    for i in range(2,y+1):
        if x%i==0:
            cnt += 1
            
    if x==2:
        return 2
    else:
        if cnt==0:
            return x
        else:
            return 0
            
while ans == 0:
    ans = prime(x)
    x += 1
    

print(ans)
# Buggy code:
import math

N = int(input())

def sosuu(num):
  numsq = int(math.sqrt(num))
  judge = True
  for i in range(numsq):
    if (num % (i + 2) == 0):
      judge = False
      break
  return (judge)

while True:
  if (sosuu(N) == False):
    N+=1
  else:
    break;

print(N)

# Fixed code:
import math

N = int(input())

def sosuu(num):
  if num == 2:
    return (True)
  else:
    numsq = int(math.sqrt(num))
    judge = True
    for i in range(numsq):
      if (num % (i + 2) == 0):
        judge = False
        break
    return (judge)

while True:
  if (sosuu(N) == False):
    N+=1
  else:
    break;

print(N)
# Buggy code:
n=int(input())
prime=0
tmp = n
while prime == 0:
  flag=True
  for i in range(2,int(n**0.5)+1):
  	flag=False
    break
  if frag:
    prime=tmp
  tmp+=1
print(prime)


# Fixed code:
n=int(input())
prime=0
tmp = n
while prime == 0:
  flag=True
  for i in range(2,int(tmp**0.5)+1):
    if tmp%i==0:
      flag=False
      break
  if flag:
    prime=tmp
  tmp+=1
print(prime)
# Buggy code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = int(input())
double = X*2+1
s = set()
for i in range(2, double):
    if i in s:
        continue
    if i>X:
        print(i)
        break
    cnt = 1
    while cnt*i<=double:
        s.add(i*cnt)
        cnt += 1

# Fixed code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = int(input())
double = X*10+1
s = set()
for i in range(2, double):
    if i in s:
        continue
    if i>=X:
        print(i)
        break
    cnt = 1
    while cnt*i<=double:
        s.add(i*cnt)
        cnt += 1
# Buggy code:
import sys

n = int(input())

while True:
    if n % 2 != 0:
        for i in range(3, int(n**0.5+1),2):
            if n % i == 0:
                break
        else:
            print(n)
            sys.exit()

    n = n + 1

# Fixed code:
import sys

n = int(input())

while True:
    for i in range(2, int(n**0.5+1)):
        if n % i == 0:
            break
    else:
        print(n)
        sys.exit()

    n = n + 1
# Buggy code:
def is_prime(n):
    for p in range(2,n):
        if n % p ==0:
            return True

N =int(input())
p=N
while cnt <10**7:
    if is_prime(p):
        p +=1
    else:
        print(p)
        break

# Fixed code:
def is_prime(n):
    for p in range(2,n):
        if n % p ==0:
            return True

N =int(input())
p=N
while p <10**7:
    if is_prime(p):
        p +=1
    else:
        print(p)
        break
# Buggy code:
X=int(input())

if X==2:
  print(2)
else:
  while 1:
    flag=0
    for i in range(2,X):
      if X%i==0:
        flag=1
        break

    if flag==0:
      break
    else:
      X=X+1

print(X)

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

if X==2:
  print(2)
else:
  while 1:
    flag=0
    for i in range(2,X):
      if X%i==0:
        flag=1
        break

    if flag==0:
      break
    else:
      X=X+1
  print(X)
# Buggy code:
import math
s=int(input())
if s!=2 and s%2==0:
    s+=1
def prime(x):
  if x==2:
    return True
  else:
    for i in range(3,int(math.sqrt(s))+1,2):
      if s%i==0:
        return False
      else:
        return True

while True:
  if prime(s):
    print(s)
    break
  s+=2

# Fixed code:
import math
s=int(input())
if s!=2:
  if s%2==0:
    s+=1
def prime(x):
  if x==2:
    return True
  else:
    for i in range(3,int(math.sqrt(s))+1,2):
      if s%i==0:
        return False
    return True

while True:
  if prime(s):
    print(s)
    break
  s+=2
# Buggy code:
import math
x = int(input())
i = 0
flag = True
while flag:
  for k in range(2, int(math.sqrt(x+i)) + 1):
    if (x+i) % k == 0:
      i += 1
      print(i)
      break
  else:
      flag = False
 
print(x+i)
 

# Fixed code:
import math
x = int(input())
i = 0
flag = True
while flag:
  for k in range(2, int(math.sqrt(x+i)) + 1):
    if (x+i) % k == 0:
      i += 1
      break
  else:
      flag = False

print(x+i)
# Buggy code:
from bisect import bisect_right

def eratosthenes(n):
    A = [i for i in range(2, n+1)]
    P = []
    i = 2
    while i**2 <= n:
        prime = min(A)
        P.append(prime)
        j = 0
        while j < len(A):
            if A[j] % prime == 0:
                A.pop(j)
                continue
            j += 1
        i += 1    
    for a in A:
        P.append(a)
    return P
    
x = int(input())
prime_table = eratosthenes(100003)
prime_set = set(prime_table)
if x in prime_set:
    print(x)
else:
    idx = bisect_left(prime_table, x)
    ans = prime_table[idx]
    print(ans)

# Fixed code:
from bisect import bisect_right

def eratosthenes(n):
    A = [i for i in range(2, n+1)]
    P = []
    i = 2
    while i**2 <= n:
        prime = min(A)
        P.append(prime)
        j = 0
        while j < len(A):
            if A[j] % prime == 0:
                A.pop(j)
                continue
            j += 1
        i += 1    
    for a in A:
        P.append(a)
    return P
    
x = int(input())
prime_table = eratosthenes(100003)
prime_set = set(prime_table)
if x in prime_set:
    print(x)
else:
    idx = bisect_right(prime_table, x)
    ans = prime_table[idx]
    print(ans)
# Buggy code:
li = []

def is_prime(n):
        return False
    for m in li:
        if m * m > n: 
            return True
        if n % m == 0:
            return False
    return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

while True:
  if is_prime(n):
    print(n)
    break
  n += 1

# Fixed code:
li = []

def is_prime(n):
  for m in li:
    if m * m > n: 
      return True
    if n % m == 0:
      return False
  return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

while True:
  if is_prime(n):
    print(n)
    break
  n += 1
# Buggy code:
from math import sqrt
n=int(input())
for i in range(n,n*10000):
    a=1
    if i%2!=0:
        a=0
        for j in range(3,round(sqrt(n))+1,2):
            if i%j==0:
                a+=1
                break
    if a==0:
        print(i)
        break


# Fixed code:
from math import sqrt
n=int(input())
for i in range(n,n*10000):
    a=1
    if i%2!=0:
        a=0
        for j in range(3,round(sqrt(n))+1,2):
            if i%j==0:
                a+=1
                break
    elif i==2:
        print(2)
        break
    if a==0:
        print(i)
        break
# Buggy code:
X = input()

while(1):
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
    if i == X-1:
      break

print(X)

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

while(1):
  if X == 2:
    break
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
  if i == X-1:
      break

print(X)
# Buggy code:
import math
x=int(input())

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma+1):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if is_prime(x):
        print(x)
        break
    x+=1

# Fixed code:
import math
x=int(input())

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    if is_prime(x):
        print(x)
        break
    x+=1
# Buggy code:
from math import sqrt
def judge(num):
    if num <= 2:
        return False
    elif num % 2 == 0:
        return False
    else:
        for i in range(3,int(sqrt(num))+1,2):
            if num % i == 0:
                return False
        return True
s = int(input()) 
while(1):
    if judge(s):
        print(s)
        break
    else:
        s += 1

# Fixed code:
from math import sqrt
def judge(num):
    if num < 2:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False
    else:
        for i in range(3,int(sqrt(num))+1,2):
            if num % i == 0:
                return False
        return True
s = int(input()) 
while(1):
    if judge(s):
        print(s)
        break
    else:
        s += 1
# Buggy code:
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


x = int(input())
flg = 0
  while flg == 0:
      #print("a")
      flg = com(x)
      if flg == 0:
          x+=1
print(x)

# Fixed code:
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


def main():
    x = int(input())
    flg = 0
    while flg == 0:
        #print("a")
        flg = com(x)
        if flg == 0:
            x+=1
    print(x)



if __name__ == "__main__":
    main()
# Buggy code:
def isPrime(n):
    for i in range(2,N):
        if N%i == 0:
            return False
    
def find_next_prime(n):
    return find_prime_in_range(n, 2*n)

def find_prime_in_range(a, b):
    for p in range(a, b):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None

N = int(input())
if(isPrime(N)):
    print(str(N))
else:
    print(str(find_next_prime(N+1)))


# Fixed code:
def isPrime(n):
    for i in range(2,N):
        if N%i == 0:
            return False
    return True
    
    
def find_next_prime(n):
    return find_prime_in_range(n, 2*n)

def find_prime_in_range(a, b):
    for p in range(a, b):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None

N = int(input())
if(isPrime(N)):
    print(str(N))
else:
    print(str(find_next_prime(N+1)))