Buggy python submission (verdict: Runtime Error):
N = int(input())
#N = 6
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

NN = factorization(N)

# N-1について
NN_1 = factorization(N-1)
#print(NN_1)
ans = 0
tmp = 1
for i in NN_1:
    tmp *= i[1]+1
ans += tmp - 1
#print(ans)

#
P = []
IKU = []
PP = []
for i in NN:
    P.append(i[0])
    j = i[1]
    tmp = []
    for k in range(j+1):
        tmp.append(k)
    PP.append(tmp)
    IKU.append(i[1])
L = len(P)
#print('aaa')
for i in itertools.product(*PP):
    tmp = 1
    for j in range(L):
        tmp *= P[j]**i[j]
    K = tmp
    tmp = 1

    if K != 1:
        #print('K',K)
        for j in range(1,41):
            tmp *= K
            if N<tmp:
                break
            #print(tmp)
            if (N-tmp)%(tmp*K)==0:
                ans += 1
                #print('YES',K)
                break
            
#print(NN_1)
#print(NN)
if N==2:
    print(1)
else:
    print(ans)

Fixed submission:
N = int(input())
import itertools
#N = 6
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

NN = factorization(N)

# N-1について
NN_1 = factorization(N-1)
#print(NN_1)
ans = 0
tmp = 1
for i in NN_1:
    tmp *= i[1]+1
ans += tmp - 1
#print(ans)

#
P = []
IKU = []
PP = []
for i in NN:
    P.append(i[0])
    j = i[1]
    tmp = []
    for k in range(j+1):
        tmp.append(k)
    PP.append(tmp)
    IKU.append(i[1])
L = len(P)
#print('aaa')
for i in itertools.product(*PP):
    tmp = 1
    for j in range(L):
        tmp *= P[j]**i[j]
    K = tmp
    tmp = 1

    if K != 1:
        #print('K',K)
        for j in range(1,41):
            tmp *= K
            if N<tmp:
                break
            #print(tmp)
            if (N-tmp)%(tmp*K)==0:
                ans += 1
                #print('YES',K)
                break
            
#print(NN_1)
#print(NN)
if N==2:
    print(1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
#N = 6
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

NN = factorization(N)

# N-1について
NN_1 = factorization(N-1)
#print(NN_1)
ans = 0
tmp = 1
for i in NN_1:
    tmp *= i[1]+1
ans += tmp - 1
#print(ans)

#
P = []
IKU = []
PP = []
for i in NN:
    P.append(i[0])
    j = i[1]
    tmp = []
    for k in range(j+1):
        tmp.append(k)
    PP.append(tmp)
    IKU.append(i[1])
L = len(P)
#print('aaa')
for i in itertools.product(*PP):
    tmp = 1
    for j in range(L):
        tmp *= P[j]**i[j]
    K = tmp
    tmp = 1

    if K != 1:
        #print('K',K)
        for j in range(1,41):
            tmp *= K
            if N<tmp:
                break
            #print(tmp)
            if (N-tmp)%(tmp*K)==0:
                ans += 1
                #print('YES',K)
                break
            
#print(NN_1)
#print(NN)
print(ans)


Fixed submission:
N = int(input())
import itertools
#N = 6
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

NN = factorization(N)

# N-1について
NN_1 = factorization(N-1)
#print(NN_1)
ans = 0
tmp = 1
for i in NN_1:
    tmp *= i[1]+1
ans += tmp - 1
#print(ans)

#
P = []
IKU = []
PP = []
for i in NN:
    P.append(i[0])
    j = i[1]
    tmp = []
    for k in range(j+1):
        tmp.append(k)
    PP.append(tmp)
    IKU.append(i[1])
L = len(P)
#print('aaa')
for i in itertools.product(*PP):
    tmp = 1
    for j in range(L):
        tmp *= P[j]**i[j]
    K = tmp
    tmp = 1

    if K != 1:
        #print('K',K)
        for j in range(1,41):
            tmp *= K
            if N<tmp:
                break
            #print(tmp)
            if (N-tmp)%(tmp*K)==0:
                ans += 1
                #print('YES',K)
                break
            
#print(NN_1)
#print(NN)
if N==2:
    print(1)
else:
    print(ans)