#
# Each new term in the Fibonacci sequence is generated by adding the previous
# two terms. By starting with 1 and 2, the first 10 terms will be:
#
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequence whose values do not exceed
# four million, find the sum of the even-valued terms.
#

def fibo(n): # n = monesko fibonacin luku annetaan.
    a = 1
    b = 1
    for i in range(n):
        a, b = b, a + b
    return a

def main():
    totalSum = 0
    z = 1
    while(True):
        x = fibo(z)
        if(x > 4000_000):
            break
        if(x % 2 == 0):
            totalSum += x
        z += 1
    print(totalSum)


if(__name__ == "__main__"):
    main()
