You are given an integer number $$$n$$$. The following algorithm is applied to it:  if $$$n = 0$$$, then end algorithm;  find the smallest prime divisor $$$d$$$ of $$$n$$$;  subtract $$$d$$$ from $$$n$$$ and go to step $$$1$$$. Determine the number of subtrations the algorithm will make.

The only line contains a single integer $$$n$$$ ($$$2 \le n \le 10^{10}$$$).

Print a single integer — the number of subtractions the algorithm will make.

NoteIn the first example $$$5$$$ is the smallest prime divisor, thus it gets subtracted right away to make a $$$0$$$.In the second example $$$2$$$ is the smallest prime divisor at both steps.

import sys
n = int(sys.stdin.readline().strip())

def find_min_prime(n):
    x = int(round(n**(0.5) + 1))
    for i in range(2, x):
        if n % i == 0:
            return i
    return n

if n % 2 == 0:
    s = n // 2
else:
    d = find_min_prime(n)
    n = n - d
    s = 1 + n // 2
print(s)

n=int(input())
i=2
while i*i<=n:
 if n%i==0:break
 i+=1
else:i=n
print(1+(n-i)//2)

def prime_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

def solve(n):
    if n < 2:
        return 0
    f = prime_factors(n)
    if f[0] == 2:
        return n // f[0]
    else:
        return 1 + solve(n-f[0])

def main():
    n = int(input())
    print(solve(n))

main()

n=int(input())
import math
def is_prime(n):
    count=0
    for i in range(2, int(math.sqrt(n)+1)):
        if n%i==0:
            count+=1
    if count==0:
        return True
    else:
        return False

def cf(n):
    if n%2==0:
        print(int(n/2))
    else:
        for i in range(2,int(math.sqrt(n)+1)):
            if n%i==0 and is_prime(i)==True:
                print (int(((n- i)/2)+1))
                break
        if is_prime(n)==True:
            print("1")

cf(n)

from math import ceil
a = int(input())
steps = 0

def minprime(x):
    for i in range(2, ceil(x**0.5)+1):
        if x % i == 0:
            return i
    return x
while a != 0:
    t = minprime(a)
    if t == 2:
        steps += a // t
        a = 0
    else:
        a -= t
        steps += 1
print(steps)

def crives(n):
    p = 2
    while p * p <= n :
        if n % p == 0:
            return p;
        p += 1
    return n

n = int(input())
cont = 0
if n % 2 != 0:
    n -= crives(n)
    cont += 1

resp = cont + int(n/2)

print(resp)

import math
n=int(input())
if(n%2==0):
    print(n//2)
else:
    c=0
    for i in range(3,int(math.sqrt(n))+1,2):
        if(n%i==0):
            c=1
            k=i
            break
    if(c==0):
        print(1)
    else:
        print(1+((n-k)//2))

import math as mt
#t=int(input())
t=1
def sp(n):
    if n%2==0:
        return 2
    i=3
    while i*i<=n:
        if n%i==0:
            return i
        i+=1
    return n
for _ in range(t):
    n=int(input())
    x=sp(n)
    if n%2==0:
        print(n//2)
    else:
        print((n-x)//2+1)

def isprime(n):
    if n%2==0:
        return 2
    else:
        for i in range(3,int(n**(0.5))+1,2):
            if n%i==0:
                return i
        else:
            return n
n=int(input())
n=n - isprime(n)
print(n//2 + 1)

n = input()
if n % 2 == 0: print n // 2
else:
    d = 1
    for i in xrange(1, int(n ** 0.5) + 1):
        if n % i == 0 and i != 1:
            d = i
            break
    if d == 1:
        print 1
    else:
        print 1 + (n - d) // 2

def minprime(n):
  if n %2==0:
      return 2
  if n%3==0:
      return 3
  max_t=10**5+10
  for k in range(6,max_t,6):
      if n%(k-1)==0:
          return k-1
      if n%(k+1)==0:
          return k+1
  return n

n=int(input())
print(1+(n-minprime(n))//2)

n=input()
a=-1
import math
if n==0:
	print 0
elif n%2==0:
	print n/2
else:
	for i in range(2,int(math.sqrt(n))+1):
		if(n%i==0):
			a=i
			break
	if(a==-1):
		print 1
	else:
		print 1+(n-a)/2

from math import sqrt
n=input()
p=1
for i in range(2,int(sqrt(n))+1):
    if n%i==0:
        p=i
        break
if p==1:
    print 1
else:
    print (n-p)//2+1

n = int(input())
from math import sqrt
4
if (n%2 == 0): print (int(n/2))
else:
    bank=0;
    for i in range (3,int(sqrt(n))+1):
        if n%i==0: bank = i; break
    if bank==0: bank=n
    print ((n-bank)//2 +1)

n = int( input() )
d = n
i = 2
while i * i <= n:
    div = n // i
    if i * div == n:
        d = i
        break
    i += 1

print( 1 + ( n - d ) // 2 )

n=input()
if n%2==0:
  print n/2
else:
  prime=True
  for i in xrange(2,int(n**0.5+1)):
    if n%i==0:
      prime=False
      break
  if prime:
    print 1
  else:
    b=n/i
    ans=1+0.5*(i*(b-1))
    print int(ans)

import math
n = int(input())
def smallest_prime_factor(n):
    for i in range(2, int(math.sqrt(n))+1, 1):
        if n%i == 0:
            return i
    return n
count = 0
if n%2!=0:
    n -= smallest_prime_factor(n)
    count += 1
print(count + n//2)

# Problem: B. Divisor Subtraction
# Contest: Codeforces - Educational Codeforces Round 54 (Rated for Div. 2)
# URL: https://codeforces.com/contest/1076/problem/B
# Memory Limit: 256 MB
# Time Limit: 2000 ms
#
# Powered by CP Editor (https://cpeditor.org)

def fun(n):
	for _ in range(2,int(pow(n,(1/2)))+1):
		if n%_==0:
			return _
	return n

n=int(input())

print((n-fun(n))//2+1)

n = int(raw_input())
i = 2
d = n
while i * i <= n:
	if n % i == 0:
		d = i
		break
	i += 1
if d % 2 == 0:
	print (n // d)
else:
	ans = 1
	n -= d
	if (n > 0):
		ans += n // 2
	print(ans)

def isPrime(n) :
    # Corner cases
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True

    # This is checked so that we can skip
    # middle five numbers in below loop
    if (n % 2 == 0 or n % 3 == 0) :
        return False

    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6

    return True

n=int(input())
c=0
while( n>0):
  if isPrime(n)==True:
    c=c+1
    break
  elif n%2==0:
    c=c+n/2
    break
  elif n%3==0:
    c=c+1+(n-3)/2
    break
  for i in range(2,int((n**(0.5)))+1):
    if n%i==0:
      if isPrime(i)==True:
        c+=1
        n-=i
        break

print c

import math
n = int(input())
if n%2 == 0:
    print(int(n/2))
    quit()
for i in range(2, int(math.sqrt(n))+1):
    if n%i == 0:
        print(int((n-i)/2)+1)
        quit()
print(1)

n = int(input())
j = int((n ** 0.5) + 1)
q = n
for i in range(2 , j):
    if(n % i == 0):
        #print(i)
        q = min(q , i)
        break
if(q == n):
    print(1)
if(q < n):
    print(1 + (n - q)//2)

n=int(input())
if n==0:
	print(0)
	exit()
k=0
while n%2!=0:
	flag=0
	for i in range(2,int(n**(0.5))+1):
		if n%i==0:
			flag=1
			break
	if flag==1:
		n= n-i
	else:
		n= 0
	k+=1

print(k+n//2)

n=int(input())
ans=0
i=2
while(i*i<=n):
	if n%i==0:
		ans+=1
		n-=i
		break
	i+=1
if n%2==0:
	print(ans+n//2)
else:
	print(1)

# print(max(ans,1))

import math
p=0
n=int(input())

for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
        p=i
        break
c=0
if(p):
    if p%2==1:

     print(1+(n-p)//2)
    else:
        print(n//2)
else:
    print(1)

n = int(input())

prost = 0

if n % 2 == 0:
    n //= 2

    print(n)

    exit(0)
else :
    f = int(1)
    i = int(3)

    while i * i <= n:
        if n % i == 0:
            prost = i
            f = 0

            break
        i += 1

    if f == 1:
        prost = n

    n -= prost
    n //= 2

    n += 1

    print(n)

from math import sqrt
n = int(input())
c = 0

if n % 2 == 0:
    c = (n // 2)
else:
    for i in range(3, int(sqrt(n)+1), 2):
        if n % i == 0:
            c = 1 + (n-i)//2
            break
    else:
        c = 1

print(c)

n = int(input())
i, ans = 2, n
while i * i <= n:
  if n % i == 0:
    ans = i
    break
  i += 1
print( (n-ans) // 2 + 1)

n = int(input())
done = 0

if n%2==0:
    print(int(n/2) )
else:
    for divisor in range(3,int(n**.5)+1 ):
        if n%divisor==0:
            print( int((n-divisor)/2 + 1 ))
            done = 1
            break
    if done==0:
        print(1)

n = int(input())
if n % 2 == 0:
    print(n//2)
else:
    fl = 1
    for u in range(2, int((n+1)**0.5)+2):
        if n%u == 0:
            print(1+(n-u)//2)
            fl = 0
            break
    if fl:
        print(1)

while True:
	try:
		prime = []
		mark = [0]*(10**6+2)

		def seive():
			prime.append(2)
			N = 10**6
			for i in range(3, N+1, 2):
				if not mark[i]:
					prime.append(i)
					if i*i <= N:
						j = i*i
						while j <= N:
							mark[j] = 1
							j +=(i*2)
		def solution(n):
			#seive()
			if n&1:
				d = n
				i = 3
				while i*i <= n:
					if n%i == 0:
						d = i
						break
					i += 1
				n -= d
				print(1+(n//2))
			else:print(n//2)

		if __name__ == "__main__":
			n = int(input())
			solution(n)
	except EOFError:
		break

n = int(input())

if not n % 2:
  print(n // 2)
else:
  def primes_sieve(limit):
    a = [True] * limit
    a[0] = a[1] = False

    for (i, isprime) in enumerate(a):
      if isprime:
        for n in range(i*i, limit, i):
          a[n] = False

    return a

  sieve = primes_sieve(1000100)

  for i in range(len(sieve)):
    if sieve[i]:
      if not n % i:
        print(((n - i) // 2) + 1)
        exit()

  print(1)

s = input()
n = 0
for c in s:
    ch = ord(c) - ord('0')
    n = 10 * n + ch
i = 2
while i * i <= n:
    if n % i == 0:
        break
    i += 1
if n % i != 0:
    print(1)
elif i == 2:
    print(n // 2)
else:
    n -= i
    print(n // 2 + 1)

import math
n = int(input())
t = 0
for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
        t = i
        break
if t == 0:
    c = 1
else:
    c = 1 + ((n - t) // 2)
print(c)

n=int(input())
sqrt=int(n**(1/2))+1
for i in range(2,sqrt):
    if n%i==0:
        print(1+(n-i)//2)
        exit()
print(1)

import sys
LI=lambda:list(map(int, sys.stdin.readline().split()))
MI=lambda:map(int, sys.stdin.readline().split())
SI=lambda:sys.stdin.readline().strip('\n')
II=lambda:int(sys.stdin.readline())

from math import sqrt
n=II()
isPrime=True
for i in range(2, int(sqrt(n))+1):
    if n%i==0:
        isPrime=False
        break
if isPrime:
    i=n
print(1+(n-i)//2)

n=int(input())
i=2
while i*i<n and n%i:i+=1
if i*i>n:i=n
print(1+(n-i)//2)

import math as m

n = int(input())

if n % 2 == 0:
    print(n // 2)
else:
    sq = int(m.sqrt(n))
    d = 3
    while d <= sq and n % d != 0:
        d += 1
    if d <= sq:
        print(1 + (n - d) // 2)
    else:
        print(1)

n = int(input())
subs = 0
while n!=0:
    if n%2 == 0:
        subs+=n//2
        break

    for i in range( 3, int(n**0.5)+1, 2):
        if n%i == 0:
            n = n-i
            subs=1
            break

    if n>0 and n%2 == 0:
        subs+=n//2
        break
    elif n>0:
        subs+=1
        break
print(subs)

import math

def divisors(n):
    divs = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divs.extend([i, n // i])
    return set(divs)

n = int(input())

if n % 2 == 0:
    print(n // 2)
else:
    divs = list(sorted(divisors(n)))
    if len(divs) == 0:
        print(1)
    else:
        for v in divs:
            tmpdivs = divisors(v)
            if len(tmpdivs) == 0:
                n -= v
                print(1 + (n // 2))
                exit(0)
        print(1)

import math

n = input()
s = int(math.sqrt(n))
f = 0
for i in xrange(2,s+1):
    if n%i == 0:
        f = 1
        n -= i
        break
if not f:
    print 1
else:
    print n/2 + 1

from __future__ import division
from sys import stdin, stdout

def sieveOfEratosthenes(n):
    """sieveOfEratosthenes(n): return the list of the primes < n."""
    # Code from: <dickinsm@gmail.com>, Nov 30 2006
    # http://groups.google.com/group/comp.lang.python/msg/f1f10ced88c68c2d
    if n <= 2:
        return []
    sieve = range(3, n, 2)
    top = len(sieve)
    for si in sieve:
        if si:
            bottom = (si*si - 3) // 2
            if bottom >= top:
                break
            sieve[bottom::si] = [0] * -((bottom - top) // si)
    return [2] + [el for el in sieve if el]

def write(x):
    stdout.write(str(x) + "\n")

primes = sieveOfEratosthenes(100011)
n = int(stdin.readline())
c= 0
while n != 0:
    for prime in primes:
        if n % prime == 0:
            if prime == 2:
                write(c + n // 2)
                exit()
            n -= prime
            c += 1
            break
        if prime ** 2 > n:
            write(c+1)
            exit()

write(c)

def factorize(n):  # o(sqr(n))
    c, ans = 1, []
    while (c * c < n):
        if n % c == 0:
            ans.extend([c, n // c])
        c += 1

    if c * c == n:
        ans.append(c)
    return sorted(ans)

def prime(n):
    if n in [2, 3]:
        return True
    if n < 2 or n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    while (i * i <= n):
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

n = int(input())
if n % 2 == 0:
    print(n // 2)
else:
    fac = factorize(n)
    for j in fac:
        if prime(j):
            print((n - j) // 2 + 1)
            break

import sys
from collections import defaultdict
import math
n=int(sys.stdin.readline())
def getfactors(num):
    ans=0
    if num%2==0:
        return num//2
    fac=-1
    for i in range(2,int(math.sqrt(num))+1):
        #print(num%i)
        #print('a')
        if num%i==0:
            #print(i,'i')
            fac=i
            break
    #print(fac)
    if fac!=-1:
        num-=fac
        ans=1
        ans+=num//2
        return ans
    return 1

ans=getfactors(n)
print(ans)

import time
import collections
import math

class Time_test:
    def __enter__(self):
        self.enter_time = time.time()
    def __exit__(self, exc_type, exc_val, exc_tb):
        print("Command was executed in", time.time()-self.enter_time)

n = int(input())
counter = 0
if n % 2 == 1:
    for i in range(3, math.floor(math.sqrt(n))+1):
        if n % i == 0:
            n -= i
            counter += 1
            break

for i in range(2, math.floor(math.sqrt(n))+1):
    if n % i == 0:
        counter += n // i
        n -= n // i * i
        break

if n != 0:
    counter += 1
print(counter)

n=int(input())
counter=0
d=0
for i in range(2,int((n**0.5)+1)):
    if n % i==0:
        counter=1
        d=i
        break
if counter:
    print(1+(n-d)//2)
else:
    print(1)

n = int(input())

count = 0
rep = 2

while n != 0:
  if n%2 == 0:
    count_temp = n / 2
    n-=(2 * count_temp)
    count += count_temp
    continue

  while n % rep != 0 and rep * rep <= n:
    rep+=1

  if n % rep == 0:
    n-=rep
    count+=1
  else:
    n=0
    count+=1

print(int(count))

n=int(input())
i=2
while i*i<=n:
 if n%i==0:break
 i+=1
else:i=n
print(1+(n-i)//2)

from math import *
n=int(input())
ans=0
g=int(sqrt(n)//1)+1
l=[0]*g
l[0]=1
l[1]=1
d=[]
for i in range(2,g):
    if l[i]==0:
        for j in range(i+i,g,i):
            l[j]=1
        d.append(i)
k=0

while n:
    flag=0
    if n%2==0:
        ans+=n//2
        n=0
        break
    for i in d:
        if n%i==0:
            n-=i
            ans+=1
            flag=1
            break
    if flag==0:
        break
if ans==0:
    ans=1
print(ans)

n=input()
i=2
while i*i<n and n%i:i+=1
print(1+(n-i)/2,1)[i*i>n]

n = int(input())
if n % 2 == 0:
    print(n//2)
else:
    ct = 1
    for i in range(2, int((n+1)**0.5) + 2):
        if n % i == 0:
            print(1 + (n-i)//2)
            ct = 0
            break
    if ct:
        print(1)

#!/usr/bin/env python3
import sys
import math

def rint():
    return map(int, sys.stdin.readline().split())
#lines = stdin.readlines()

n = int(input())

if n%2 == 0:
    cnt = n//2
else:
    for i in range(3, int(math.sqrt(n)+1)):
        if n % i == 0:
            cnt = 1 + (n-i)//2
            break
    else:
        cnt = 1

print(cnt)

n = int(input())
from math import sqrt
4
if (n%2 == 0): print (int(n/2))
else:
    bank=0;
    for i in range (3,int(sqrt(n))+1):
        if n%i==0: bank = i; break
    if bank==0: bank=n
    print ((n-bank)//2 +1)

n=int(input())
i=2
while i*i<n and n%i:i+=1
if i*i>n:i=n
print(1+(n-i)//2)

def fact(n):
    for i in range(2,int(n**.5)+1):
        if n%i==0:
            return i
    return n
n=int(input())
ans=0
k=fact(n)
if k!=2:
    print(((n-k)//2)+1)
else:
    print(n//k)

from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
sys.setrecursionlimit(10**5)
from queue import PriorityQueue
# def rl():
#     return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
# map(int,input().split())
# # l = list(map(int,input().split()))
# from itertools import permutations
import heapq
# input = lambda: sys.stdin.readline().rstrip()
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop

# n,k = map(int,input().split())
#
# l = list(map(int,input().split()))

def solve(n):

    for i in range(2,int(sqrt(n)) + 1):
        if n%i == 0:
            return True

    return False

primes = []

for i in range(2,10**5 + 1):
    if not solve(i):
        primes.append(i)

n = int(input())
ans = 0
while n!=0:

    if n%2 == 0:
        ans+=n//2
        break
    flag = 0
    for i in primes:
        if n%i == 0:
            n-=i
            ans+=1
            flag = 1
            break
    if not flag:
     if not solve(n):

        ans+=1
        break

print(ans)

n = int(input())
if n % 2 == 0:
    print(n // 2)
else:
    i = 2
    while i * i <= n:
        if n % i == 0:
            print((n - i) // 2 + 1)
            exit()
        i += 1
    print(1)

n = int(input())

def PrimeList(limit):
    Plist = []
    for i in range(2,limit+1):
        divcheck = False
        for j in Plist:
            if j*j > i:
                break
            if i%j == 0:
                divcheck = True
                break
        if divcheck == False:
            Plist.append(i)
    return Plist

L = PrimeList(10**5)
count = 0
primecheck = True
for p in L:
    if p*p > n:
        break
    if n%p == 0:
        smallest = p
        primecheck = False
        break
if primecheck == True:
    smallest = n
print(1+int((n-smallest)/2))

from math import sqrt; from itertools import count, islice
def isPrime(n):
    return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))
def primes_method4(n):
    out = list()
    out.append(2)
    for num in range(3, n+1, 2):
        if all(num % i != 0 for i in range(2, int(num**.5 ) + 1)):
            out.append(num)
    return out
def div(n,a):

    if n==0:
        return 0
    else:
        if n%2==0:
            return n//2
        else:
            if isPrime(n):
                return 1
            else:
                for i in a:
                    if n%i==0:
                        break
                return 1+ div(n-i,a)

if __name__=="__main__":
    n=int(input())
    arr=primes_method4(100000)
    anws=div(n,arr)
    print(anws)

n = int(input())
ans = 0
if n % 2 == 1:
    i = 2
    cnt = -1
    while i * i <= n:
        if n % i == 0:
            cnt = i
            break
        i += 1
    if cnt == -1:
        cnt = n
    n -= cnt
    ans += 1
print(ans + n//2)

import math
def prime(a):
	for i in range(2,int(math.sqrt(a))+1):
		if a%i==0:
			return 0
	return 1

n = int(input())

if prime(n)==1:
	print("1")

elif n%2==0:
	print(int(n/2))

else:
	for i in range(2,n):
		if n%i==0 and prime(i):
			d =i;
			break;
	print(1+((n-d)//2))

import math

def small_prime_div(n):
    for x in range(2,math.floor(math.sqrt(n))+1):
        if n%x==0:
            return x
    return n

n = int(input())
##num = 0
##while n!=0:
##    n-=small_prime_div(n)
##    num+=1
print(1+(n-small_prime_div(n))//2)

import math
a=int(input())
if (a%2 == 0) :
    print(a//2)
else:
    for i in range(3,int(math.sqrt(a)+1)):
        if(a%i==0):
            a-=i
            print(a//2+1)
            exit(0)
    print(1)

import math

n = int(input())
l = int(math.sqrt(n)) + 1
is_prime = [True] * l

is_prime[0] = is_prime[1] = False
primes = []
for i in range(2, l):
    if is_prime[i]:
        primes.append(i)
        for j in range(i * 2, l, i):
            is_prime[j] = False

c = 0
while n % 2 == 1:
    subtracted = False
    for p in primes:
        if n % p == 0:
            n -= p
            c += 1
            subtracted = True
            break
    if not subtracted:
        n = 0
        c += 1
print(c + (n // 2))

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

def find_divisor(n):
    if n % 2 == 0:
        return 2
    for i in range(3, isqrt(n) + 1, 2):
        if n % i == 0:
            return i
    return n

n = int(input())
print(1 + (n - find_divisor(n)) // 2)

#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    from math import gcd
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    def gcd(x, y):
        """gcd(x, y) -> int
        greatest common divisor of x and y
        """
        while y:
            x, y = y, x % y
        return x

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def memodict(f):
    """ Memoization decorator for a function taking a single argument. """
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret
    return memodict().__getitem__

def _try_composite(a, d, n, s):
    if pow(a, d, n) == 1:
        return False
    for i in range(s):
        if pow(a, 2**i * d, n) == n - 1:
            return False
    return True

def is_prime(n):
    """
    Deterministic variant of the Miller-Rabin primality test to determine
    whether a given number is prime.

    Parameters
    ----------
    n : int
        n >= 0, an integer to be tested for primality.

    Returns
    -------
    bool
        False if n is composite, otherwise True.
    """
    if n in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:
        return True

    if (any((n % p) == 0 for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])) or (n in [0, 1]):
        return False

    d, s = n - 1, 0
    while not d % 2:
        d, s = d >> 1, s + 1

    if n < 2047:
        return not _try_composite(2, d, n, s)
    if n < 1373653:
        return not any(_try_composite(a, d, n, s) for a in [2, 3])
    if n < 25326001:
        return not any(_try_composite(a, d, n, s) for a in [2, 3, 5])
    if n < 118670087467:
        if n == 3215031751:
            return False
        return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7])
    if n < 2152302898747:
        return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11])
    if n < 3474749660383:
        return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13])
    if n < 341550071728321:
        return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17])
    if n < 3825123056546413051:
        return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])
    return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])

def _factor(n):
    for i in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:
        if n % i == 0:
            return i

    y, c, m = random.randint(1, n - 1), random.randint(1, n - 1), random.randint(1, n - 1)
    g, r, q = 1, 1, 1

    while g == 1:
        x = y
        for i in range(r):
            y = ((y * y) % n + c) % n
        k = 0
        while (k < r) and (g == 1):
            ys = y
            for i in range(min(m, r - k)):
                y = ((y * y) % n + c) % n
                q = q * (abs(x - y)) % n
            g = gcd(q, n)
            k = k + m
        r = r * 2

    if g == n:
        while True:
            ys = ((ys * ys) % n + c) % n
            g = gcd(abs(x - ys), n)
            if g > 1:
                break

    return g

@memodict
def factors(n):
    """
    Integer factorization using Pollard's rho algorithm.

    Parameters
    ----------
    n : int
        n > 1, an integer to be factorized.

    Returns
    -------
    Counter
        Counter of the prime factors of n.
    """
    if is_prime(n):
        return Counter([n])
    else:
        f = _factor(n)
        if f == n:
            return factors(n)
        else:
            return factors(f) + factors(n//f)

def main():
    n = int(input())

    def div_sub(n):
        if n % 2 == 0:
            return n // 2
        f = factors(n)
        f.pop(1, None)
        smallest_factor = min(f.keys())
        return 1 + ((n - smallest_factor) // 2)

    print(div_sub(n))

if __name__ == '__main__':
    sync_with_stdio(False)

    if 'PyPy' in sys.version:
        from _continuation import continulet

        def bootstrap(c):
            callable, arg = c.switch()
            while True:
                to = continulet(lambda _, f, x: f(x), callable, arg)
                callable, arg = c.switch(to=to)

        c = continulet(bootstrap)
        c.switch()

        main()

    else:
        import threading

        sys.setrecursionlimit(2097152)
        threading.stack_size(134217728)

        main_thread = threading.Thread(target=main)
        main_thread.start()
        main_thread.join()

def isPrime(n) :
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True
    if (n % 2 == 0 or n % 3 == 0) :
        return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def f(n):
    l = []
    for i in range(2,n+1):
        if n%i==0:
            return(i)
n = int(input())
if (isPrime(n)):
    print(1)
else:
    s, tp = 0, 0
    while True:
        k = n-tp
        n = n-tp
        if n%2==0:
            s+=(n//2)
            break
        if k==0:
            break
        else:
            tp = f(k)
            s+=1
    print(s)

import math
arr = []
# A function to print all prime factors of
# a given number n
def primeFactors(n):

    # Print the number of two's that divide n
    while n % 2 == 0:
        arr.append(2)
        return
        n = n / 2

    # n must be odd at this point
    # so a skip of 2 ( i = i + 2) can be used
    for i in range(3,int(math.sqrt(n))+1,2):

        # while i divides n , print i ad divide n
        while n % i== 0:
            arr.append(i)
            n = n / i

    # Condition if n is a prime
    # number greater than 2
    if n > 2:
        arr.append(n)

# Driver Program to test above function

n = int(input())
primeFactors(n)

x = min(arr)

if n%2==0:
	print(int(n/2))
else:
	print(int((n-x)/2)+1)

n = input()

primes = {}
aux = [True] * 1000001
start = 2

while (start <= 1000000):
    if (aux[start]):
        primes[start] = True
        for i in range(start * start, 1000001, start):
            aux[i] = False
    start += 1

count = 1

def getMinimumPrimeDivisor(number):
    for prime in primes:
        if (number % prime == 0):
            return prime
    return -1

while (not n in primes):
    minimumDivisor = getMinimumPrimeDivisor(n)
    if (minimumDivisor == 2):
        count += n / 2 - 1
        n = 2
    elif (minimumDivisor < 0):
        n = 2
    else:
        count += 1
        n -= minimumDivisor

print(count)

from math import *
a=int(input())
for i in range(2,floor(sqrt(a))+1):
    if(a%i==0):
        print(int((a-i)/2)+1)
        exit()
print(1)

import math
def div(n):
    ans=0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            ans=i
            break
    if ans>0:
        return ans
    else:
        return n

n=int(input())
if n%2==0:
    print(n//2)
else:
    a=div(n)
    n=n-a
    print(1+n//2)

'''input
9

'''
from collections import defaultdict as df
from bisect import bisect_left as bl
import sys
#maxn=1000001
n=input()
sq=int(n**0.5)+1
pf=n
for i in range(2,sq+1):
    if n%i==0:
        pf=i
        break

if pf&1:
    print 1 + (n-pf)/2
else:
    print n/2

n = int(input())
for i in range(2, int(n**0.5)+1):
    if n % i == 0:
        print((n-i)//2+1)
        break
else: print(1)

n=int(input())
t=0
if n%2==0 :
    exit(print(n//2))
for i in range (2,int(pow(n,0.5))+1) :
    if n%i==0 :
        t=1
        break
if t!=1 :
    exit(print("1"))
else :
    print(1+(n-i)//2)

n = int(input())
if n % 2 == 0:
    ans = n // 2
else:
    i = 3
    while n % i != 0 and i <= n ** 0.5:
        i += 2
    if i > n ** 0.5:
        ans = 1
    else:
        ans = 1 + (n - i) // 2
print(ans)

n = int(input())
if n % 2 == 0:
    print(n // 2)
else:
    i = 3
    while i <= n // i:
        if n % i == 0:
            n -= i
            print(1 + (n // 2))
            exit()
        i += 1
    print(1)

n = int(input())
if n % 2 == 0:
    print(n//2)
else:
    fl = 1
    for u in range(2, int((n+1)**0.5)+2):
        if n%u == 0:
            print(1+(n-u)//2)
            fl = 0
            break
    if fl:
        print(1)

n=input()
if n%2==0:
  print n/2
else:
  prime=True
  for i in xrange(2,int(n**0.5+1)):
    if n%i==0:
      prime=False
      break
  if prime:
    print 1
  else:
    b=n/i
    ans=1+0.5*(i*(b-1))
    print int(ans)

def sol(x):
    if x%2==0:
        return 2
    else:
        n=3
        while n*n<=x:
            if x%n==0:
                return n
            else:
                n+=2
        return x
x=int(input())

j=x
ans=0
while x%2==1:
    x-=sol(x)
    ans+=1
print(ans+(x//2))

#!/usr/bin/env python
# coding: utf-8

# In[51]:

n=int(input())

# In[52]:

sub=0

def smallprime(x):
    for i in range(2,int(pow(x,1/2))+1):
        if x % i==0:
            return i
    return x

def dsub(x):
    global sub
    if x==0:
        print(int(sub))
        return
    if  x%2==0:
        sub=sub+x/2
        print(int(sub))
        return
    else:
        p=smallprime(x)
        sub=sub+1
        dsub(x-p)

# In[53]:

dsub(n)

# In[ ]:

#!/usr/bin/env python3
from typing import Dict, List, Tuple

def input_lst() -> List[int]:
    return [int(x) for x in input().split()]

def print_out(res: List[int]):
    print(' '.join([str(x) for x in res]))

# def eratosthenes(n):     # n - число, до которого хотим найти простые числа
#

def main():

    n,  = (int(x) for x in input().split())
    sieve = list(range(int(n**0.5) + 1))

    if n // 2 == n / 2:
        print(n//2)
        return

    sieve[1] = 0    # без этой строки итоговый список будет содержать единицу
    for i in sieve:
        if i > 1:
            if n/i == n//i:
                print((n - i)//2 + 1)
                return
            for j in range(i + i, len(sieve), i):
                sieve[j] = 0

    print(1)

if __name__ == '__main__':
    main()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 16 14:02:19 2018

@author: umang
"""

def find_smallest_div(n):
    for i in range(2, int(n**0.5) + 1):
        if n%i == 0:
            return i
    return n

def func(n):
    count = 0
    if n == 0:
        return count
    else:
        '''while(n != 0):
            d = find_smallest_div(n)
            n -= d
            count += 1
        return count'''
        d = find_smallest_div(n)
        return 1 + (n-d)//2

n = int(input())

print(func(n))

import math
x=int(input())
if x%2==0:print(x//2)
elif x%3==0:print(x//3)
else:
	for i in range(5,x+1,6):
		if x%i==0:exit(print(x//i))
		elif x%(i+2)==0:exit(print(x//(i+2)))

# Author : raj1307 - Raj Singh
# Date   : 10.05.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import log,sqrt,factorial
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1]
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def main():

    #for _ in range(ii()):

    n=ii()
    if n%2==0:
        print(n//2)
    else:

        for i in range(2,int(n**0.5)+1):

            if n%i==0 and isPrime(i):
                print(n//i)
                return

        print(1)

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

import math
N=int(input())
if N%2==0:
  print(N//2)
else:
  p=N
  for i in range(2,int(math.sqrt(N))):
    if N%i==0:
      p=i
  print((N-p)//2 + 1)

n=input()
#find smallest prime divisor of n
found = False
p=2
while (p*p<=n):
    if (n%p==0):
        found = True
        break
    p+=1
if found:
    print n/p
else:
    print 1

from math import floor, sqrt
try:
    long
except NameError:
    long = int

def fac(n):
    step = lambda x: 1 + (x<<2) - ((x>>1)<<1)
    maxq = long(floor(sqrt(n)))
    d = 1
    q = n % 2 == 0 and 2 or 3
    while q <= maxq and n % q != 0:
        q = step(d)
        d += 1
    return q <= maxq and [q] + fac(n//q) or [n]
n=int(input())
x=fac(n)[0]
print(n//x)

import math
def prime(a):
	for i in range(2,int(math.sqrt(a))):
		if a%i==0:
			return 0
	return 1

n = int(input());
if prime(n):
	print("1")
elif n%2==0:
	print(n//2)
else:
	for i in range(2,n):
		if n%i==0 and prime(i):
			d =i;
			break;
	print(1+((n-d)//2))

n = int(input())

for i in range(2,n+1):
    div = n/i
    if div%1==0:
        print(int(div))
        break

n = int(input())

if (n%2 == 0): print (int(n/2))
else:
    bank=0;
    for i in range (3,n):
        if n%i==0: bank = i; break
    print ((n-bank)//2 +1)

n = int(input())
import math
limit = math.sqrt(n)
limit = math.ceil(limit)
limit = int(limit)
for i in range(2, limit+2):
    if n%i == 0:
        if (n-i)%2 == 0:
            print(str(1+(n-i)//i))
        else:
            print(str(n//i))
        exit()

print(str(1))

import math

n = int(input())
print(int(n/2))

n = input()

isprime = [1 for i in range(int(n**0.5)+2)]
isprime[0] = isprime[1] = 0

def sieve():
    global isprime

    n = len(isprime)

    touched = [0 for i in range(n)]

    for i in range(2, int(n**0.5)+2):

        if not touched[i]:
            touched[i] = 1
            isprime[i] = 1

        for j in range(2*i, n, i):

            if not touched[j]:
                touched[j] = 1
                isprime[j] = 0

sieve()

def SPF(n):

    for i in range(2, int(n**0.5)+2):
        if n%i == 0 and isprime[i]:
            return i

    return n

print n/SPF(n)

N = int(input())
M = 10 ** 5 + 5
pr = [True] * M
pr[0], pr[1] = False, False
for i in range(2, M):
    if pr[i]:
        for j in range(i * 2, M, i):
            pr[j] = False

prime = list(filter(lambda x: pr[x], range(M)))

def calc(n, k):
    if n == 0:
        return k
    elif n % 2 == 0:
        return n // 2 + k
    else:
        for i in prime:
            if n % i == 0:
                n -= i
                return calc(n, k + 1)

print(calc(N, 0))

from math import sqrt
n = int(input())
answer = 0
d = {}
cur = n
for i in range(2, int(sqrt(n)) +  2):
    while cur % i == 0:
        cur //= i
        t = d.get(i, 0) + 1
        d[i] = t
if d == {}:
    print(1)
else:
    for k in d:
        answer += d[k]
    print(answer)

import math

temp=0
flag=0
n = int(input())

if n%2==0:
	print(int(n/2))
else:
	for i in range(2,int(math.sqrt(n)+1)+1):
		if n%i==0:
			temp = i;
			flag=1

	if flag==0:
		temp = n

	ans = (n-temp)/2
	ans = ans+1
	print(int(ans))

from math import sqrt
n = int(input())

for i in range(2, int(sqrt(n))+1):
    if n%i == 0:
        print(n//i)
        break
else:
    print(1)

n = int(input())

if n % 2 == 0:
    print(int(n / 2))
    raise SystemExit

if n % 3 == 0:
    print(int((n-3) / 2 + 1))
    raise SystemExit

if n % 5 == 0:
    print(int((n-5) / 2 + 1))
    raise   SystemExit

print(1)

n=int(input())
import math
def is_prime(n):
    count=0
    for i in range(2, int(math.sqrt(n)+1)):
        if n%i==0:
            count+=1
    if count==0:
        return True
    else:
        return False
def cf(n):
    if n%2==0:
        print(int(n/2))
    else:
        for i in range(2,int(math.sqrt(n)+1)):
            if n%i==0 and is_prime(i)==True:
                print (int(((n- i)/2)+1))
                break
            elif is_prime(n)==True:
                break
cf(n)

#!/usr/bin/env python3
from typing import Dict, List, Tuple

def input_lst() -> List[int]:
    return [int(x) for x in input().split()]

def print_out(res: List[int]):
    print(' '.join([str(x) for x in res]))

# def eratosthenes(n):     # n - число, до которого хотим найти простые числа
#

def main():

    n,  = (int(x) for x in input().split())
    sieve = list(range(int(n**0.5) + 1))

    sieve[1] = 0    # без этой строки итоговый список будет содержать единицу
    for i in sieve:
        if i > 1:
            if n/i == n//i:
                print(n//i)
                return
            for j in range(i + i, len(sieve), i):
                sieve[j] = 0

    print(1)

if __name__ == '__main__':
    main()

n = int(input())
t = n
for i in range(2,min(n,100000)):
	if n%i == 0:
		t=i
		break
print(n/t)

from math import *
a=int(input())
for i in range(2,floor(sqrt(a))+1):
    if(a%i==0):
        print(int(a/i))
        exit()
print(1)

def prime_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

def solve(n):
    ans = 0
    f = prime_factors(n)
    fs = set(f)
    for i in fs:
        ans += 2 ** (f.count(i) - 1)
    return ans

def main():
    n = int(input())
    print(solve(n))

main()

n = int(input())

for i in range(2, n + 1):
    if n % i == 0:
        print(n // i)
        exit()
    if i * i > n * 2:
        break

print(1 if n > 0 else 0)

n=int(input())
import math
def is_prime(n):
    count=0
    for i in range(2, int(math.sqrt(n)+1)):
        if n%i==0:
            count+=1
    if count==0:
        return True
    else:
        return False
def cf(n):
    if n%2==0:
        print(int(n/2))
    else:
        for i in range(2,int(math.sqrt(n)+1)):
            if n%i==0 and is_prime(i)==True:
                print (int(((n- i)/2)+1))
                break
            else:
                print("1")
cf(n)

pr=[1]*300001
pr[0],pr[1]=0,0
primes=[]
for i in range(2,300001):
    if(pr[i]==1):
        primes.append(i)
        for j in range(i*i,100001,i):
            pr[j]=0
def prime(n):
    for i in range(2,int(n**0.5)+2):
        if(n%i==0):
            return False
    return True
def dope(n):
    if(n<2 or n>1e10):
        return 1//0
    if(prime(n)):
        return 1
    for i in primes:
        if n%i==0:
  #          print(n,i)
            return n//i
    return 1//0
print(dope(int(input())))

import sys
LI=lambda:list(map(int, sys.stdin.readline().split()))
MI=lambda:map(int, sys.stdin.readline().split())
SI=lambda:sys.stdin.readline().strip('\n')
II=lambda:int(sys.stdin.readline())

n=II()
ok=[1]*(100001)
ans=0
for i in range(2, 100001):
    if ok[i]:
        for j in range(i+i, 100001, i):
            ok[j]=0
        while n%i==0:
            n//=i
            ans+=1
print(ans)

import math
x=int(input())
if x%2==0:print(x//2)
elif x%3==0:print(x//3)
else:
	for i in range(5,x+1,6):
		if x%i==0:exit(print(x//i))
		elif x%(i+2)==0:exit(print(x//(i+2)))

import sys
LI=lambda:list(map(int, sys.stdin.readline().split()))
MI=lambda:map(int, sys.stdin.readline().split())
SI=lambda:sys.stdin.readline().strip('\n')
II=lambda:int(sys.stdin.readline())

n=II()
ok=[1]*(100001)
for i in range(2, 100001):
    if ok[i]:
        for j in range(i+i, 100001, i):
            ok[j]=0
        if n%i==0:
            break
print(1+(n-i)//2)

n=int(input())
for i in range(2,int(n**0.5)+1):
    if n%i==0: # n=15, i=3
        print(1+((n-i)//2))
        print(i)
        exit()
print(1)

m = int(input())
n = int(m)

if(m%2 == 0):
    print(m//2)
else:
    i=2
    while (i*i<n):
        while (n%i==0):
            n /= i
        i += 1
    print( ((n-m) // 2) + 1)

n = int(input())
k = int(n ** 0.5) + 1
prime = [True] * (k + 1)
prime[0] = prime[1] = False
for i in range(2, k + 1):
    if prime[i]:
        if i * i <= k:
            for j in range(i * i, k + 1, i):
                prime[j] = False

f = False
for i in range(2, k + 1):
    if n % i == 0:
        f = True
        break
if not f:
    print(1)
    exit(0)
ans = 0
for i in range(2, k + 1):
    if n % i == 0 and prime[i]:
        ans = n // i
        break
print(ans)

n = int(input())
from math import sqrt

if (n%2 == 0): print (int(n/2))
else:
    bank=0;
    for i in range (3,int(sqrt(n))):
        if n%i==0: bank = i; break
    if bank==0: bank=n
    print ((n-bank)//2 +1)

n = int(input())
i = 2
while i * i <= n:
    if n % i == 0:
        print(n // i)
        exit(0)
    i += 1

print(1)

n = int(input())
subs = 0
while n!=0:
    if n%2 == 0:
        subs+=n//2
        break

    for i in range( 3, int(n**0.5), 2):
        if n%i == 0:
            n = n-i
            subs=1
            break

    if n>0 and n%2 == 0:
        subs+=n//2
        break
    elif n>0:
        subs+=1
        break
print(subs)

n = int(input())
d=1
#answer when smallest prime divides n
for i in range(2,n):
    if n%i == 0:
        d=i
        break

print((n/d))

from math import sqrt
n = int(input())

for i in range(2, int(sqrt(n))+1):
    if n%i == 0:
        print(n//i)
        break
else:
    print(1)

from sys import stdin

def main():
	n = int(input())
	if n % 2 == 0:
		d = 2
	else:
		d = 3
		while n % d != 0:
			d += 2

	print(n // d)

	return

if __name__ == '__main__':
	main()

#!/usr/bin/env python
# coding: utf-8

# In[51]:

n=int(input())

# In[52]:

sub=0

def smallprime(x):
    for i in range(2,x+1):
        if x % i==0:
            return i

def dsub(x):
    global sub
    if x==0:
        print(sub)
        return
    if  x%2==0:
        sub=sub+x/2
        print(sub)
        return
    else:
        p=smallprime(x)
        sub=sub+1
        dsub(x-p)

# In[53]:

dsub(n)

# In[ ]:

n = int(input())
for i in range(2,n+1):
	if n % i == 0:
		break

print(n//i)

import math
def prime(a):
	for i in range(2,int(math.sqrt(a))):
		if a%i==0:
			return 0
	return 1

n = int(input());
if prime(n):
	print("1")
elif n%2==0:
	print(n//2)
else:
	for i in range(2,n):
		if n%i==0 and prime(i):
			d =i;
			break;
	print(1+((n-d)//2))

import math
p=0
n=int(input())

for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
        p=i
c=0
if(p):
    if p%2==1:

     print(1+(n-p)//2)
    else:
        print(n//2)
else:
    print(1)

#E54_B

num = int(input())

ans = 1

for i in range(2, int(num ** 0.5) + 1):
    if num % i == 0:
        ans = i

if ans == 1:
    print(1)
else:
    if ans == 2:
        print(num // 2)
    else:
        print(1 + (num - ans) // 2)

n = int(input())
import math
limit = math.sqrt(n)
limit = int(limit)
for i in range(2, limit+1):
    if n%i == 0:
        print(str(n//i))
        exit()

print(str(1))

def eratosthenes(n):                      # n - число, до которого хотим найти простые числа
    sieve = list(range(n + 1))
    #print(sieve)
    sieve[1] = 0                          # без этой строки итоговый список будет содержать единицу
    prime = []
    for i in sieve:
        if i > 0:
            prime.append(i)
            for j in range(i * i, len(sieve), i):
                sieve[j] = 0
    #return sieve
    return prime

n = int(input())
s = 0
p = eratosthenes(1000000)

if len(p) == 0:
    print(1)
elif n % 2 == 0:
    print(n // 2)
else:
    for i in p:
        if n % i == 0:
            print(1 + (n - i) // 2)
            break

n=int(input())
ans=0
i=2
while(n>1):
	j=n
	while(i*i<=n):
		if n%i==0:
			ans+=n//i
			n=n%i
			# print("DD",n,i)
			break
		i+=1
	if j==n:
		break

print(max(ans,1))

def smallestDivisor(n):

    # if divisible by 2
    if (n % 2 == 0):
        return 2;

    # iterate from 3 to sqrt(n)
    i = 3;
    while(i * i <= n):
        if (n % i == 0):
            return i;
        i += 2;

    return n;

n=int(input())
k=n
print(int(n/smallestDivisor(k)))

n = int(input())

if not n % 2:
  print(n // 2)
else:
  def primes_sieve(limit):
    a = [True] * limit
    a[0] = a[1] = False

    for (i, isprime) in enumerate(a):
      if isprime:
        for n in range(i*i, limit, i):
          a[n] = False

    return a

  sieve = primes_sieve(1000100)

  for i in range(len(sieve)):
    if sieve[i]:
      if not n % i:
        print((n - i) // 2 + 1)
        exit()

import math

n = int(input())
d = n
for i in range(2, round(math.sqrt(n))+1):
    if n%i == 0:
        d = i
        break
if d == n:
    print(1)
else:
    print(int(n/d))

n = int(input())
from math import sqrt

if (n%2 == 0): print (int(n/2))
else:
    bank=0;
    for i in range (3,int(sqrt(n))):
        if n%i==0: bank = i; break
    if bank==0: bank=n
    print ((n-bank)//2 +1)

import math
n = int(input())

for i in range(2,int(math.sqrt(n)) + 1):
    if n%i == 0:
        print(i)
        print(int((n - i)/2 + 1))
        break

n = int(input())
i = 2
while i * i <= n:
    if n % i == 0:
        print(n // i)
        exit(0)
    i += 1

print(1)

n=int(input())

import math

def fac(n):
    xn=math.ceil(math.sqrt(n))

    for i in range(2,xn+2):
        if n%i==0:
            return n//i

    else:
        return 1

count=0
while n!=1:
    n=fac(n)
    count+=1

print(count)

n = int( input() )
d = n
for i in range( 2, 100001 ):
    div = n // i
    if i * div == n:
        d = i
        break

print( n // d )

def primes_method4(n):
    out = list()
    out.append(2)
    for num in range(3, n+1, 2):
        if all(num % i != 0 for i in range(2, int(num**.5 ) + 1)):
            out.append(num)
    return out
def div(n,a):

    if n==0:
        return 0
    else:
        if n%2==0:
            return n//2
        else:
            for i in a:
                if n%i==0:
                   break
            return 1+ div(n-i,a)

if __name__=="__main__":
    n=int(input())
    arr=primes_method4(100000)
    anws=div(n,arr)
    print(anws)

def factor(n):
    ans = []
    d = 2
    while d * d <= n:
        if n % d == 0:
            ans.append(d)
            n //= d
        else:
            d += 1
    if n > 1:
        ans.append(n)
    return ans

n = int(input())
print(len(factor(n)))

def first_factor(n):
    for num in range(2,int(n**0.5) + 1):
        if n % num == 0:
            return num
    return n

a = int(input())
b = first_factor(a)
print(a//b)

def eratosthenes(n):                      # n - число, до которого хотим найти простые числа
    sieve = list(range(n + 1))
    #print(sieve)
    sieve[1] = 0                          # без этой строки итоговый список будет содержать единицу
    prime = []
    for i in sieve:
        if i > 0:
            prime.append(i)
            for j in range(i * i, len(sieve), i):
                sieve[j] = 0
    #return sieve
    return prime

n = int(input())
s = 0
p = eratosthenes(100000)

if len(p) == 0:
    print(1)
elif n % 2 == 0:
    print(n // 2)
else:
    for i in p:
        if n % i == 0:
            print(1 + (n - i) // 2)
            break

n = int(input())
c=True
check=0
if n==0:
    c=False
while c:
    for i in range(2,int(n/2)+1):
        if n%i == 0:
            if i==2:
                c=False
                check += n/2
            else:
                n-=i
                check+=1
            break
    else:
        check+=1
        break

print(check)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 16 14:02:19 2018

@author: umang
"""
nums = [i for i in range(10**5+1)]
primes = []

def sieve(nums, primes):
    i = 2
    while i < 10**5+1:
        if nums[i] != -1:
            primes.append(i)
            n = 1
            temp = n*i
            while temp < 10**5+1:
                nums[temp] = -1
                n += 1
                temp = n*i
        i += 1
    return primes

primes = sieve(nums, primes)

def find_smallest_div(n, primes):
    for i in primes:
        if n%i == 0:
            return i

def func(n):
    count = 0
    if n == 0:
        return count
    else:
        '''while(n != 0):
            d = find_smallest_div(n)
            n -= d
            count += 1
        return count'''
        d = find_smallest_div(n, primes)
        return n//d

n = int(input())

print(func(n))

n = int(input())

if not n % 2:
  print(n // 2)
else:
  def primes_sieve(limit):
    a = [True] * limit
    a[0] = a[1] = False

    for (i, isprime) in enumerate(a):
      if isprime:
        for n in range(i*i, limit, i):
          a[n] = False

    return a

  sieve = primes_sieve(100000)

  for i in range(len(sieve)):
    if sieve[i]:
      if not n % i:
        print((n - i) // 2 + 1)

import sys
import math
n = int(input())
count = 0

if n % 2 is 0:
    print(n//2)
    sys.exit()

primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]

if n in primes:
    print(1)
    sys.exit()
tmp = True
for i in range(2, int(math.sqrt(n)) + 1):
    if n % i is 0:
        tmp = False
        break
if tmp:
    print(1)
    sys.exit()

while True:
    if n % 2 is 0:
        print(count + n//2)
        sys.exit()

    if n is 0:
        break
    #find prime
    temp = False
    for p in primes:
        if n % p is 0:
            count = count + 1
            n = n - p
            temp = True
            break
    if temp:
        continue

    for i in range(primes[-1] + 1, 100000 + 1):
        tt = True
        for j in range(2, int(math.sqrt(i)) + 1):
            if i % j is 0:
                tt = False
                break
        if tt:
            primes.append(i)
            if n % i is 0:
                count = count + 1
                n = n - i
                break
print(count)

def prime_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

def solve(n):
    f = prime_factors(n)
    return n // f[0]

def main():
    n = int(input())
    print(solve(n))

main()

n = int(input())

if n % 2 == 0:
    print(int(n / 2))
    raise SystemExit

if n % 3 == 0 or n % 5 == 0:
    print(int((n+1) / 2))
    raise SystemExit

print(1)

import math
n = int(input())
def smallest_prime_factor(n):
    for i in range(2, int(math.sqrt(n)), 1):
        if n%i == 0:
            return i
    return n
count = 0
if n%2!=0:
    n -= smallest_prime_factor(n)
    count += 1
print(count + n//2)

n = int(input())

# smallest prime divisor of an odd number is some odd number
# smallest prime divisor of an even number is 2, and it stays even when we subtract
# smallest divisor of a number must be prime
if n % 2 == 0: print(int(n/2))
else:
    d = n
    for i in range(3, int(n ** 1/2 + 1)):
        if n % i == 0: d = i
    print(int((n - d)/2))

#!/usr/bin/python3
from collections import Counter

def readint():
    return int(input())

def readline():
    return [int(c) for c in input().split()]

def divisors(n):
    i = 2
    res = Counter()
    while i * i <= n:
        if n % i == 0:
            while n % i == 0:
                n //= i
                res[i] += 1
        i += 1
    if n != 1:
        res[n] = 1

    return res

def main():
    n = int(input())
    d = divisors(n)
    _min = min(d.keys())
    prod = 1
    for k, v in d.items():
        if k == _min and v > 1:
            prod *= k * (v - 1)
        elif k != _min:
            prod *= k * v

    print(prod)

if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-
"""
@author: zzf
@file: main.py
@time: 2018/11/13
"""

n  = int(input())
res = 0

def isPrime(k):
    if k == 2:
        return True
    else:
        for i in range(2, k):
            if k%i == 0:
                return False
        return True

if n%2 == 0:
    res = n/2
else:
    for i in range(2, n+1):
        if n % i == 0:
            if isPrime(i):
                res = n/i
print(res)

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

print(len(prime_factors(int(input()))))

import math

def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while (i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6

    return True

n = int(input())

result = 0

def go(k):
    global result
    if k==0:
        return
    if k % 2 == 0:
        result = k // 2
        return
    else:
        if (isPrime(k)): result+=1; go(0)
        for i in range(3, int(math.sqrt(n))+1):
            if isPrime(i) and k%i==0:
                result+=1
                go(k-i)

go(n)
print(result)

n = int(input())
response = 0

while n % 2 != 0:
    x = n

    i = 2
    while i * i <= n:
        if n % i == 0:
            x = i
            break

        n -= x
        response += 1
        i += 1

response += n / 2
print(int(response))

n=input()
#find smallest prime divisor of n
found = False
p=2
while (p*p<=n):
    if (n%p==0):
        found = True
        break
    p+=1
if found:
    print n/p
else:
    print 1

import math
import bisect
import itertools
import sys
mod=10**9 +7
'''fact=[1]*1001
ifact=[1]*1001
for i in range(1,1001):
    fact[i]=((fact[i-1])*i)%mod
    ifact[i]=((ifact[i-1])*pow(i,mod-2,mod))%mod
def ncr(n,r):
    return (((fact[n]*ifact[n-r])%mod)*ifact[r])%mod
def npr(n,r):
    return (((fact[n]*ifact[n-r])%mod))
    '''

def mindiff(a):
    b=a[:]
    b.sort()
    m=10000000000
    for i in range(len(b)-1):
        if b[i+1]-b[i]<m:
            m=b[i+1]-b[i]
    return m

def lcm(a,b):
    return a*b//math.gcd(a,b)

def merge(a,b):
    i=0;j=0
    c=0
    ans=[]
    while i<len(a) and j<len(b):
        if a[i]<b[j]:
            ans.append(a[i])
            i+=1
        else:
            ans.append(b[j])
            c+=len(a)-i
            j+=1
    ans+=a[i:]
    ans+=b[j:]
    return ans,c
def mergesort(a):
    if len(a)==1:
        return a,0
    mid=len(a)//2
    left,left_inversion=mergesort(a[:mid])
    right,right_inversion=mergesort(a[mid:])
    m,c=merge(left,right)
    c+=(left_inversion+right_inversion)
    return m,c

def is_prime(num):
    if num == 2: return True
    if num == 3: return True
    if num%2 == 0: return False
    if num%3 == 0: return False
    t = 5
    a = 2
    while t <= int(math.sqrt(num)):
        if num%t == 0: return False
        t += a
        a = 6 - a
    return True

def ceil(a,b):
    if a%b==0:
        return a//b
    else:
        return (a//b + 1)

def binsearch(arr,b,low,high):
    if low==high:
        return low
    if arr[math.ceil((low+high)/2)]<b:
        return binsearch(arr,b,low,math.ceil((low+high)/2) -1 )
    else:
        return binsearch(arr,b,math.ceil((low+high)/2),high)
def ncr1(n,r):
    s=1
    for i in range(min(n-r,r)):
        s*=(n-i)
        s%=mod
        s*=pow(i+1,mod-2,mod)
        s%=mod
    return s

def calc(n,m,r):
    s=0
    for i in range(0,r+1,2):
        s+=ncr1(n,i)*ncr1(m,i)
        s%=mod
    return s

#/////////////////////////////////////////////////////////////////////////////////////////////////
n=int(input())
count=0
i=2
while(i<=int(n**0.5)):
    if n%i==0:
        exit(print(n//i))
    i+=1

print(1)

while True:
	try:
		prime = []
		mark = [0]*(10**6+2)

		def seive():
			prime.append(2)
			N = 10**6
			for i in range(3, N+1, 2):
				if not mark[i]:
					prime.append(i)
					if i*i <= N:
						j = i*i
						while j <= N:
							mark[j] = 1
							j +=(i*2)
		def solution(n):
			seive()
			step = 0
			t = 0
			if True:
				for i in range(len(prime)):
					if n%prime[i] == 0:
						t = prime[i]
						break
			step = n//t
			print(step)

		if __name__ == "__main__":
			n = int(input())
			solution(n)
	except EOFError:
		break

n=int(input())
arr=[]
cnt=0
if n%2==1:
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            cnt+=1
            n-=i
            break
print(cnt+n//2)

n=int(input())
ans=0
while n!=0 :
    t=0
    for i in range (2,int(pow(n,0.5))+1) :
        if n%i==0 :
            t=1
            n=n//i
            ans+=1
            break
    if t!=1 :
        ans+=1
        break
print(ans)

n = int(input())

def PrimeList(limit):
    Plist = []
    for i in range(2,limit+1):
        divcheck = False
        for j in Plist:
            if j*j > i:
                break
            if i%j == 0:
                divcheck = True
                break
        if divcheck == False:
            Plist.append(i)
    return Plist

L = PrimeList(10**5)
count = 0
primecheck = True
for p in L:
    if p*p > n:
        break
    if n%p == 0:
        smallest = p
        primecheck = False

if primecheck == True:
    print(1)
else:
    print(1+int((n-smallest)/2))

n = int(input())

for i in range(2,n+1):
    div = n/i
    if div%1==0:
        print(int(div))
        break

def mind(n):
    d = 2
    while d * d <= n:
        if n % d == 0:
            return d
        d += 1
    return n

n = int(input())

if n == 0:
    print(0)

else:
    print(n // mind(n))

def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True

n=int(raw_input())

if n%2==0:
    print(n/2)
elif is_prime(n):
    print(1)
else:
    x=1
    while x<=10:
        temp=n**(1.0/x)
        if is_prime(temp):
            print(n/(temp))
            break
        x+=1

n = int(input())
k = int(n ** 0.5) + 1
f = False
for i in range(2, k + 1):
    if n % i == 0:
        f = True
        break
if not f:
    print(1)
    exit(0)
ans = 0
for i in range(2, k + 1):
    if n % i == 0:
        ans = n // i
        break
print(ans)

# Author : raj1307 - Raj Singh
# Date   : 10.05.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import log,sqrt,factorial
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1]
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def main():

    #for _ in range(ii()):

    n=ii()
    if n%2==0:
        print(n//2)
    else:

        for i in range(2,int(n**0.5)+1):

            if n%i==0 and isPrime(i):
                print(n//i)
                return

        print(inf*inf*inf*inf)

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

import sys
# import heapq, collections

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def solve(n):
    if n == 0:
        return 0
    i = 2
    while (i * i) <= n:
        if n % i:
            i += 1
        else:
            return n//i
    return 1

def main():
    n = I()

    print(solve(n))

main()

import math

n=int(input())
k=0
if n%2!=0:
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            n-=i
            k+=1
    else:
        n=0
        k+=1
k+=n//2
print(k)

from math import ceil
n=int(input());r=0
for i in range(2,ceil(n**.5)+1):
    if n%i==0:
        r=i
        break
else:
    print(1)
    exit()
print(n//r)

import math

def smallestDividor(n):
  if(n%2 == 0):
    return 2
  for j in range(3,int(math.sqrt(n)),2):
    if(n%j == 0):
      return j
  return n

n = int(input())
compt = 0
while(n != 0):
  d = smallestDividor(n)
  if(d%2 != 0 ):
    n = n - d
  else:
    break
  compt+=1
compt+= n//2
print(compt)

n = int(input())
d=n

for i in range(2,n):
    if n%i == 0:
        d=i
        break

print(int((n/d)))

n = int(input())
ans = 0
if n % 2 == 1:
    i = 2
    cnt = -1
    while i * i <= n:
        if n % i == 0:
            cnt = i
            break
        i += 1
    if cnt == -1:
        cnt = i
    n -= cnt
    ans += 1
print(ans + n//2)


Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a letter, either 'A', or the letter 'B'. Then they began to remove the cards one by one from left to right, every time they removed a card with the letter 'A', Alice gave Bob all the fruits she had at that moment and took out of the bag as many apples and as many oranges as she had before. Thus the number of oranges and apples Alice had, did not change. If the card had written letter 'B', then Bob did the same, that is, he gave Alice all the fruit that he had, and took from the bag the same set of fruit. After the last card way removed, all the fruit in the bag were over.You know how many oranges and apples was in the bag at first. Your task is to find any sequence of cards that Alice and Bob could have played with.

The first line of the input contains two integers, x, y (1 ≤ x, y ≤ 1018, xy > 1) — the number of oranges and apples that were initially in the bag.

Print any sequence of cards that would meet the problem conditions as a compressed string of characters 'A' and 'B. That means that you need to replace the segments of identical consecutive characters by the number of repetitions of the characters and the actual character. For example, string AAABAABBB should be replaced by string 3A1B2A3B, but cannot be replaced by 2A1A1B2A3B or by 3AB2A3B. See the samples for clarifications of the output format. The string that you print should consist of at most 106 characters. It is guaranteed that if the answer exists, its compressed representation exists, consisting of at most 106 characters. If there are several possible answers, you are allowed to print any of them. If the sequence of cards that meet the problem statement does not not exist, print a single word Impossible.

NoteIn the first sample, if the row contained three cards with letter 'B', then Bob should give one apple to Alice three times. So, in the end of the game Alice has one orange and three apples, and Bob has one apple, in total it is one orange and four apples.In second sample, there is no answer since one card is not enough for game to finish, and two cards will produce at least three apples or three oranges.In the third sample, cards contain letters 'AB', so after removing the first card Bob has one orange and one apple, and after removal of second card Alice has two oranges and one apple. So, in total it is three oranges and two apples.

import fractions
def solve(x, y):
    if fractions.gcd(x, y) > 1: return 'Impossible'
    turn = x > y
    if not turn: x, y = y, x
    ans = []
    while x != 0 and y != 0:
        ans.append((x//y, 'A' if turn else 'B'))
        x, y = y, x%y
        turn = not turn
    ans[-1] = (ans[-1][0]-1, ans[-1][1])
    return ''.join(str(n) + l for n, l in ans)

x, y = [int(x) for x in input().split()]
print(solve(x, y))

def gcd(m, n):
    if m < n:
        m, n = n, m
    r = m % n
    while r:
        m, n = n, r
        r = m % n
    return n

def search(x, y):
    global ans
    while True:
        if x == 1:
            ans = ans + ("" if y == 1 else str(y - 1) + 'B')
            return
        if y == 1:
            ans = ans + ("" if x == 1 else str(x - 1) + 'A')
            return
        if x < y:
            ans = ans + str(y // x) + 'B'
            x, y = x, y % x
        else:
            ans = ans + str(x // y) + 'A'
            x, y = x % y, y

a, b = [ int(i) for i in input().split() ]

if gcd(a, b) != 1:
    print("Impossible")
else:
    ans = ""
    search(a, b)
    print(ans)

def gcd(m, n):
    if m < n:
        m, n = n, m
    r = m % n
    while r:
        m, n = n, r
        r = m % n
    return n

def search(x, y):
    while True:
        if x == 1:
            ans.extend( [] if y == 1 else (str(y - 1) + 'B') )
            return
        if y == 1:
            ans.extend( [] if x == 1 else (str(x - 1) + 'A') )
            return
        if x < y:
            ans.append(str(y // x) + 'B')
            x, y = x, y % x
        else:
            ans.append(str(x // y) + 'A')
            x, y = x % y, y

a, b = [ int(i) for i in input().split() ]

if gcd(a, b) != 1:
    print("Impossible")
else:
    ans = []
    search(a, b)

    i, length = 0, len(ans)
    print(''.join(ans))

def gcd(x , y):
    if(x > y):x , y = y , x
    if(x == 0):return y
    return gcd(y % x , x)
A , B = map(int , input().split())
def solve(X , Y):
    if(X > Y):
        if(Y == 1):
            print(str(X - 1) + "A" , end = "")
            return;
        else:
            print(str(X // Y) + "A" , end = "")
            solve(X % Y , Y)
    else:
        if(X == 1):
            print(str(Y - 1) + "B" , end = "")
            return;
        else:
            print(str(Y // X) + "B" , end = "")
            solve(X ,  Y % X)
if(gcd(A , B) == 1):
    solve(A , B)
else:
    print("Impossible")

def gcd(a,b):

    if b==0:

        return a

    else:

        return gcd(b, a%b)

def solve(x, y, a, b):

    ans=""

    while not x==1 or not y==1:

        if x < y:

            x,y,a,b=y,x,b,a

        ans+=str((x-1)//y)+a

        x = x - (x-1)//y * y

    print (ans)

x,y=map(int, input().split())

if gcd(x,y)>1:

    print ("Impossible")

else:

    solve(x,y, "A", "B")

# Made By Mostafa_Khaled

a = input().split()
target = (int(a[0]), int(a[1]))
x=(1, 0)
y=(0, 1)
toadd="A"
ans = ""
def less(a, b):
  return a[0]*b[1]<b[0]*a[1]
while True:
    z = (x[0]+y[0], x[1]+y[1])
    if z[0] > target[0] or z[1] > target[1]:
        print("Impossible")
        exit()
    if z==target:
        print(ans)
        exit()
    if less(z, target): # z replaces y
        low = 1
        high = int(1e18)
        while (high > low):
            guess = (low+high+1)//2
            if less((x[0]*guess+y[0], x[1]*guess+y[1]), target):
                low = guess
            else:
                high = guess - 1
        ans += str(low)
        ans += "A"
        y = (y[0] + low * x[0], y[1] + low * x[1])
    elif less(target, z):
        low = 1
        high = int(1e18)
        while (high > low):
            guess = (low+high+1)//2
            if less(target,(x[0]+guess*y[0], x[1]+guess*y[1])):
                low = guess
            else:
                high = guess - 1
        ans += str(low)
        ans += "B"
        x = (x[0] + low * y[0], x[1] + low * y[1])
    else:
        print("Impossible")
        exit()

import sys
read = lambda: list(map(int, sys.stdin.readline().split()))
x, y = read()

res = []
c = 'A'
while x * y > 1:
   k = min(x // y, x - 1)
   if k > 0:
      res.append('{}{}'.format(k, c))
   x, y = y, x - k*y
   c = 'A' if c == 'B' else 'B'

if x == 0 or y == 0:
   print('Impossible')
else:
   print(''.join(res))

#!/usr/bin/python

import sys

def vec(a, b):
	return a[0] * b[1] - a[1] * b[0]

x, y = map(int, raw_input().split())

a = [1, 0]
b = [0, 1]

v = [x, y]
ans = ""

while a[0] + b[0] <= x and a[1] + b[1] <= y:
	q = vec(a, v)
	w = abs(vec(b, v))
	if q < w:
		c = (w - 1) // q
		b = [b[0] + c * a[0], b[1] + c * a[1]]
		ans += str(c) + 'A'
	elif q > w:
		c = (q - 1) // w
		a = [a[0] + c * b[0], a[1] + c * b[1]]
		ans += str(c) + 'B'
	else:
		print ans if a[0] + b[0] == x and a[1] + b[1] == y else "Impossible"
		sys.exit(0)

print ans if a[0] + b[0] == x and a[1] + b[1] == y else "Impossible"

inp = map(int, raw_input().split())
x = inp[0]
y = inp[1]
#print x + y

aa = 1
ao = 0
ba = 0
bo = 1
res = ""

def Cross(x1, y1, x2, y2):
  return x1 * y2 - y1 * x2

MIL = 10
MIL = 1000000000000000000

def Iter():
  global aa
  global ba
  global ao
  global bo
  global res
  #print "xy",x,y
  ca = aa + ba
  co = ao + bo
  #print aa,ao,ba,bo
  if Cross(ca, co, x, y) <= 0:
    kl = 1
    kp = MIL
    faj = 1
    while kl <= kp:
      aktc = (kl + kp) / 2
      #print aktc
      ca = ba + aa * aktc
      co = bo + ao * aktc
      if Cross(ca, co, x, y) < 0:
        #print ca,co,x,y
        faj = aktc
        kl = aktc + 1
      else:
        kp = aktc - 1
    res += str(faj)
    res += 'A'
    ba += aa * faj
    bo += ao * faj
  else:
    kl = 1
    kp = MIL
    faj = 1
    while kl <= kp:
      aktc = (kl + kp) / 2
      #print aktc
      ca = aa + ba * aktc
      co = ao + bo * aktc
      if Cross(ca, co, x, y) > 0:
        faj = aktc
        kl = aktc + 1
      else:
        kp = aktc - 1
    res += str(faj)
    res += 'B'
    aa += ba * faj
    ao += bo * faj

while aa + ba < x or ao + bo < y:
  Iter()
  #print aa,ao,ba,bo,res

if aa + ba == x and ao + bo == y:
  print res
else:
  print "Impossible"

import fractions
import sys

a, b = map(int, raw_input().split())
result = ''
while True:
	if fractions.gcd(a, b) != 1:
		print 'Impossible'
		sys.exit(0)
	if (a, b) == (1, 1):
		break
	if a == 1:
		result += str(b - a) + 'B'
		break
	elif b == 1:
		result += str(a - b) + 'A'
		break

	c, d = a, b
	if a > b:
		r = a/b
		a, b = a - b*r, b
	else:
		r = b/a
		a, b = a, b - a*r
	result += str(r) + ('B' if c < d else 'A')

print result

def gcd(a, b):
    return gcd(b, a % b) if b else a

while 1:
    try:
        x, y = map(int, input().split())
    except:
        break

    if gcd(x, y) != 1:
        print('Impossible')
        continue

    res=''
    while x > 0 and y > 0:
        if x > y:
            cnt, give = x // y, 'A'
            x %= y
        else:
            cnt, give = y // x, 'B'
            y %= x
        if x == 0 or y == 0:
            cnt -= 1
        res += str(cnt) + give

    print(res)

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x
x, y = map(int, input().split())
if gcd(x, y) != 1:
    print ("Impossible")
    exit(0)
res = ""
while x > 0 and y > 0:
    if y > x:
        if x == 1:
            y -= 1
        res = res + str(y // x) + "B"
        y = y % x
    else:
        if y == 1:
            x -= 1
        res = res + str(x // y) + "A"
        x = x % y
print(res)

def egcd(a, b):
    Q = []
    while b:
        q, r = divmod(a, b)
        Q.append(q)
        a, b = b, r
    return a, Q

def cards(x, y):
    d, Q = egcd(x, y)
    # log(x, y, d, Q)
    if d != 1:
        return 'Impossible'
    Q[-1] -= 1
    b = False
    l = []
    for q in Q:
        if q:
            l.append(str(q))
            l.append('AB'[b])
        b = not b
    s = ''.join(l)
    # verify(x, y, s)
    return s

def verify(x, y, s):
    log(s)
    AB = [(1, 0), (0, 1)]
    for k, c in tokens(s):
        log(AB, k, c)
        c_ = not c
        AB[c_] = AB[c_][0] + k*AB[c][0], AB[c_][1] + k*AB[c][1]
    r = AB[0][0] + AB[1][0], AB[0][1] + AB[1][1]
    log(AB, r)
    assert r == (x, y)

def tokens(s):
    fa = s.find('A')
    fb = s.find('B')
    assert fa >= 0 or fb >= 0
    b = (fa < 0 or (fb >= 0 and fa > fb))
    i = 0
    while i < len(s):
        i_ = s.find('AB'[b], i)
        assert i_ >= 0
        yield (int(s[i:i_]), b)
        i = i_ + 1
        b = not b

def main():
    x, y = map(int, input().split())
    print(cards(x, y))

import sys
import time
import traceback
from contextlib import contextmanager
from io import StringIO

def log(*args, **kwargs):
    print(*args, **kwargs, file=sys.stderr)

@contextmanager
def patchio(i):
    try:
        sys.stdin = StringIO(i)
        sys.stdout = StringIO()
        yield sys.stdout
    finally:
        sys.stdin = sys.__stdin__
        sys.stdout = sys.__stdout__

def do_test(k, test):
    try:
        log(f"TEST {k}")
        i, o = test
        with patchio(i) as r:
            t0 = time.time()
            main()
            t1 = time.time()
        if r.getvalue() == o:
            log(f"OK ({int((t1-t0)*1000000)/1000:0.3f} ms)\n")
        else:
            log(f"Expected:\n{o}Got:\n{r.getvalue()}")
    except Exception:
        traceback.print_exc()
        log()

def test(ts):
    for k in ts or range(len(tests)):
        do_test(k, tests[k])

tests = [("""\
1 4
""", """\
3B
"""), ("""\
2 2
""", """\
Impossible
"""), ("""\
3 2
""", """\
1A1B
""")]

if __name__ == '__main__':
    from argparse import ArgumentParser
    parser = ArgumentParser()
    parser.add_argument('--test', '-t', type=int, nargs='*')
    args = parser.parse_args()
    main() if args.test is None else test(args.test)

from operator import gt, lt

x, y = (int(w) for w in input().split())

if x>y:
    ch = 'AB'
    op1, op2 = lt, gt
    ax, ay, bx, by = 1, 0, 0, 1
else:
    ch = 'BA'
    op1, op2 = gt, lt
    ax, ay, bx, by = 0, 1, 1, 0

ans = []

while(ax+ay+bx+by < x+y):
    n=0
    for sh in range(59,-1,-1):
        t = n + (1<<sh)
        if op1(y * (bx + t*ax), x * (by + t*ay)): n = t
    if not n:
        print('Impossible')
        exit(0)
    ans.append(n)
    ax, bx = bx + n*ax, ax # Increment and swap
    ay, by = by + n*ay, ay # Increment and swap
    op1, op2 = op2, op1

for i,a in enumerate(ans): print('%d%s' % (a, ch[i&1]), end='')
print()

x, y = (int(w) for w in input().split())

ax, ay = 1, 0
bx, by = 0, 1

anext = (x>y)
ch = 'AB' if x>y else 'BA'

ans = []

while(ax+ay+bx+by < x+y):
    if(anext):
        n=0
        for sh in range(59,-1,-1):
            t = n + (1<<sh)
            #print('Aiming for', x/y)
            if y * (bx + t*ax) < x * (by + t*ay):
                n = t
                #print('Include', sh)
        if not n:
            print('Impossible')
            exit(0)
        ans.append(n)
        bx = bx + n*ax
        by = by + n*ay
    else:
        n=0
        for sh in range(59,-1,-1):
            t = n + (1<<sh)
            #print('Beaming for', x/y)
            #print(y, ' * (', ax, ' + ', t, '*', bx, ') > ', x, ' * (', ay, ' * ', t, '*', by, ')')
            if y * (ax + t*bx) > x * (ay + t*by):
                #print(y * (ax + t*bx), '>', x * (ay * t*by))
                n = t
                #print('Include', sh)
        if not n:
            print('Impossible')
            exit(0)
        ans.append(n)
        ax = ax + n*bx
        ay = ay + n*by
    anext = not anext

for i,a in enumerate(ans):
    print('%d%s' % (a, ch[i&1]), end='')
print()

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

class fraction:
    n, m = 0, 0

    def __init__(self, n, m):
        d = int(gcd(n, m))
        self.n = int(n//d)
        self.m = int(m//d)
    def add(self, tmp):
        return fraction(self.n * tmp.m, self.m * tmp.n)

    def compareTo(self ,tmp):
        a = self.n * tmp.m
        b = self.m * tmp.n

        if a > b:
            return 1
        elif a < b:
            return -1

        return 0

    def sternBrocotAdd(self, tmp):
        return fraction(self.n + tmp.n, self.m + tmp.m);

def run(left, right, result):

    a = left.n
    b = left.m
    p = right.n
    q = right.m
    n = result.n
    m = result.m

    mid = left.sternBrocotAdd(right)
    if mid.compareTo(result) == 0:
        return
    ch = 'Z'
    x = 0
    if mid.compareTo(result) <= 0:
        x = int((b * n - a * m) // (p * m - q * n))
        left = fraction(a + p * x, b + q * x)
        ch = 'A'
        if left.compareTo(result) == 0:
           x -= 1
    else:
        x = int((p * m - q * n) // (b * n - a * m))
        right = fraction(a * x + p, b * x + q)
        ch = 'B'
        if right.compareTo(result) == 0:
           x -= 1

    s = str.format("%d%c"%(x, ch))
    print(s, end="")
    if left.compareTo(result) == 0 or right.compareTo(result) == 0:
        return
    run(left, right, result)

p, q = map(int, input().split())

d = gcd(p, q)
if d == 1:
    result = fraction(p, q)
    right = fraction(1, 0)
    left = fraction(0, 1)
    run(left, right, result)
else:
    print('Impossible')

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

x, y = map(int, raw_input().split())
ans = []
while x != y:
    if x < y:
        if y % x == 0:
            ans.append(str(y / x - 1) + "B")
            y = x
        else:
            ans.append(str(y / x) + "B")
            y %= x
    else:
        if x % y == 0:
            ans.append(str(x / y - 1) + "A")
            x = y
        else:
            ans.append(str(x / y) + "A")
            x %= y

if x != 1:
    print "Impossible"
else:
    print "".join(ans)

x, y = map(int, raw_input().split())

def gcd(x,y):
	if y > x:
		x = x^y; y = x^y; x = x^y
	if x%y == 0:
		return y
	return gcd(y, x%y)

ch = ['A', 'B']
s = []
b = 0
if x < y:
	b = 1
	x = x^y; y = x^y; x = x^y
if gcd(x,y) > 1:
	print 'Impossible'
else:
	while y!=0:
		l = x//y
		s.append(l)
		r = x%y
		x = y
		y = r
	s[-1]-=1
	st = ''
	for el in s:
		st += '{}{}'.format(el, ch[b])
		b = 1-b
	print st

def f(x,y):
    m=x
    n=y
    s=''
    while(m!=0 and n!=0):
        if(m>=n):
            r=m//n
            m=m%n
            c='A'
        else:
            r=n//m
            n=n%m
            c='B'
        if (m==0 or n==0):
            if(r>1):
                s=s+str(r-1)+c
        else:
            s=s+str(r)+c
    if(m+n>1):
        return 'Impossible'

    else:
        return s

inp=input()
[x,y]=[int(t) for t in inp.split(' ')]
print(f(x,y))

ans = []

def gcd(x, y):
    while(True):
        if x == y:
            if x == 1:
                return True;
            else:
                return False;
        elif x > y:
            t = (x-1) // y;
            ans.append(-t)
            x -= t * y
        else:
            t = (y-1) // x
            ans.append(t)
            y -= t * x

x, y = map(long, raw_input().split())
if gcd(x, y) == False:
    print 'Impossible'
else:
    s = ''
    for t in ans:
        if t < 0:
            s += str(-t) + 'A'
        else:
            s += str(t) + 'B'
    print s

def get_cnt(a1, a2, b1, b2, x, y, dd):
  ll = 1
  rr = 1000000000000000000000
  while ll < rr:
    mult = (ll + rr + 1) / 2
    c1 = a1+b1*mult
    c2 = a2+b2*mult
    if (c1 * y - x * c2) * dd > 0:
      ll = mult
    else:
      rr = mult - 1

  return ll

x, y = [int(x) for x in raw_input().split()]
a1 = 1
a2 = 0
b1 = 0
b2 = 1

res = ""
while a1+b1+a2+b2 < x+y:
  c1 = a1+b1
  c2 = a2+b2
  if c1 * y > x * c2:
    mult = get_cnt(a1, a2, b1, b2, x, y, 1)
    a1 = a1+b1*mult
    a2 = a2+b2*mult
    res = res + str(mult)
    res = res + 'B'
  else:
    mult = get_cnt(b1, b2, a1, a2, x, y, -1)
    b1 = b1+a1*mult
    b2 = b2+a2*mult
    res = res + str(mult)
    res = res + 'A'

if a1 + b1 == x and a2 + b2 == y:
  print res
else:
  print "Impossible"

from fractions import gcd
import sys

a, b = (int(x) for x in raw_input().split())

if gcd(a, b) > 1:
    print "Impossible"
    sys.exit(0)

# (a, b) goes to (a-b, b) or (a, b-a)
ret = []
while a > 1 or b > 1:
    assert a != b
    if a > b:
        if a%b == 0:
            ret.append((a/b-1, "A"))
        else:
            ret.append((a/b, "A"))
        a %= b
    else:
        if b%a == 0:
            ret.append((b/a-1, "B"))
        else:
            ret.append((b/a, "B"))
        b %= a
ans = ""
for x in ret:
    ans += "{}{}".format(x[0], x[1])
print ans

a,b=map(int,raw_input().split())
def ggcd(a,b):
	if b==0:
		return [1,0,a]
	else:
		x,y,d=ggcd(b,a%b)
		x,y=y,x-a/b*y
		return [x,y,d]
y,x,d=ggcd(a,b)
if d!=1:
	print "Impossible"
	exit()
ans=""
def gao(a,b,c,d):
	if a==1 and b==0 and c==0 and d==1: return
	global ans
	if a>c:
		t=b/d
		ans="%dB"%(t)+ans
		a-=c*t
		b-=d*t
		gao(a,b,c,d)
	else:
		t=c/a
		ans="%dA"%(t)+ans
		c-=a*t
		d-=b*t
		gao(a,b,c,d)
x+=a
t=(x-1)/a
x-=t*a
y+=t*b
assert 0<x and x<=a and 0<y and y<=b
gao(x,b-y,a-x,y)
print ans

def gcd(a,b):
	if b==0:
		return a
	if a//b!=0:
		l.append(a//b)
	return gcd(b,a%b)

l=[]
t=["A","B"]
x,y=map(int,input().split())
g=gcd(x,y)

l[-1]-=1
if g==1:
	if x>y:
		start=0
	else:
		start=1
	s=''
	for v in range(len(l)):
		s+=str(l[v])+t[(start+v)%2]
	print(s)

else:
	print('Impossible')

from math import gcd
def help():
	ans = []
	a,b = map(int,input().split(" "))
	if(gcd(a,b)>1):
		print("Impossible")
		return
	while a!=1 or b!=1:
		if(a==1):
			ans.append(str(b-1)+"B")
			break
		elif(b==1):
			ans.append(str(a-1)+"A")
			break
		elif(a>b):
			ans.append(str(a//b)+"A")
			a = a%b
		elif(b>a):
			ans.append(str(b//a)+"B")
			b = b%a
	print(*ans[::],sep="")
help()

x, y = map(int,input().split(" "))

res = []
c = 'A'
while x * y > 1:
   k = min(x // y, x - 1)
   if k > 0:
      res.append('{}{}'.format(k, c))
   x, y = y, x - k*y
   c = 'A' if c == 'B' else 'B'

if x == 0 or y == 0:
   print('Impossible')
else:
   print(''.join(res))

def solve(a, b):
  r = []
  while a and b and a+b > 2:
    q = min((a//b + b//a), max(a, b)-1)
    r.append(str(q))
    if a > b:
      r.append('A')
      a -= b*q
    else:
      r.append('B')
      b -= a*q
  if a != 1 or b != 1:
    return 'Impossible'
  return ''.join(r)

def main():
  a, b = map(int, input().split())
  print(solve(a, b))

main()

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)
x, y = map(int, input().split())
if gcd(x, y) != 1:
	print('Impossible')
	exit()
a = []
while y != 1:
	a += [x // y]
	x %= y
	x, y = y, x
a += [x-1]
s = 'A'
for x in a:
	if x > 0:
		print(x, end=s)
	s = 'AB'.replace(s, '')

def gcd(m, n):
    if m < n:
        m, n = n, m
    r = m % n
    while r:
        m, n = n, r
        r = m % n
    return n

def search(x, y):
    while True:
        if x == 1:
            ans.extend( [] if y == 1 else (str(y - 1) + 'B') )
            return
        if y == 1:
            ans.extend( [] if x == 1 else (str(x - 1) + 'B') )
            return
        if x < y:
            ans.append(str(y // x) + 'B')
            x, y = x, y % x
        else:
            ans.append(str(x // y) + 'A')
            x, y = x % y, y

a, b = [ int(i) for i in input().split() ]

if gcd(a, b) != 1:
    print("Impossible")
else:
    ans = []
    search(a, b)

    i, length = 0, len(ans)
    print(''.join(ans))

def gcd(x , y):
    if(x > y):x , y = y , x
    if(x == 0):return y
    return gcd(y % x , x)
A , B = map(int , input().split())
def solve(X , Y):
    if(X > Y):
        if(Y == 1):
            print(str(X - 1) + "A" , end = "")
            return;
        else:
            print(str(X // Y) + "A" , end = "")
            solve(X % Y , Y)
    else:
        if(X == 1):
            print(str(Y - 1) + "B" , end = "")
            return;
        else:
            print(str(Y // X) + "B" , end = "")
            solve(Y % X , X)
if(gcd(A , B) == 1):
    solve(A , B)
else:
    print("Impossible")

import fractions
import sys

a, b = map(int, raw_input().split())
result = ''
while True:
	if fractions.gcd(a, b) != 1:
		print 'Impossible'
		sys.exit(0)
	c, d = a, b
	if a > b:
		r = a/b
		a, b = a - b*r, b
	else:
		r = b/a
		a, b = a, b - a*r
	result += str(r) + ('B' if c < d else 'A')

	if (a, b) == (1, 1):
		break
	if a == 1:
		result += str(b - a) + 'B'
		break
	elif b == 1:
		result += str(a - b) + 'A'
		break

print result

import fractions

a, b = map(int, raw_input().split())

result = ''
while True:
	r = fractions.gcd(a, b)
	if a < b:
		result += str((b - r) / a) + 'B'
		b = r
	elif a > b:
		result += str((a - r) / b) + 'A'
		a = r
	else:
		print 'Impossible'
		break
	if (a, b) == (1, 1):
		break
print result

x, y = map(int, raw_input().split())

ch = ['A', 'B']
s = []
b = 0
if x < y:
	b = 1
	x = x^y; y = x^y; x = x^y
if y!=1 and x%y == 0:
	print 'Impossible'
else:
	while y!=0:
		l = x//y
		s.append(l)
		r = x%y
		x = y
		y = r
	s[-1]-=1
	st = ''
	for el in s:
		st += '{}{}'.format(el, ch[b])
		b = 1-b
	print st

from math import gcd
def help():
	ans = []
	a,b = map(int,input().split(" "))
	if(gcd(a,b)>1):
		print("Impossible")
		return
	while a!=1 or b!=1:
		if(a==1):
			ans.append(str(b-1)+"B")
			break
		elif(b==1):
			ans.append(str(a-1)+"A")
			break
		elif(a>b):
			ans.append(str(a//b)+"A")
			a = a%b
		elif(b>a):
			ans.append(str(b//a)+"B")
			b = b%a
	print(*ans[::-1],sep="")
help()