# 已通过
n = int(input())
if n<6:
    print(0)
if n>=6:
    ans = 2**(n-6)
    print(ans%666666666)


# 6->1(6)
# 7->2(70,61)
# 8->4(80,71,62,611)
# 9->8(90,81,72,711,63,621,612,6111)


fac8a0aee1672af9e2ad84d366208f708fef10e1
<mask token>

<mask token>
if n < 6:
    print(0)
if n >= 6:
    ans = 2 ** (n - 6)
    print(ans % 666666666)

n = int(input())
if n < 6:
    print(0)
if n >= 6:
    ans = 2 ** (n - 6)
    print(ans % 666666666)

# 已通过
n = int(input())
if n<6:
    print(0)
if n>=6:
    ans = 2**(n-6)
    print(ans%666666666)


# 6->1(6)
# 7->2(70,61)
# 8->4(80,71,62,611)
# 9->8(90,81,72,711,63,621,612,6111)

