<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

123. The sum

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


The Fibonacci sequence of numbers is known: F1 = 1; F2 = 1; Fn+1 = Fn + Fn-1, for n>1. You have to find S - the sum of the first K Fibonacci numbers.


Input

First line contains natural number K (0<K<41).


Output

First line should contain number S.


Sample Input

5
Sample Output

12
Author	: Paul "Stingray" Komkoff, Victor G. Samoilov
Resource	: 5th Southern Subregional Contest. Saratov 2002
Date	: 2002-10-10

<|response|>
1. Abridged Problem Statement
Given an integer K (1 ≤ K ≤ 40), compute the sum S = F₁ + F₂ + … + F_K of the first K Fibonacci numbers, where
  • F₁ = 1
  • F₂ = 1
  • Fₙ = Fₙ₋₁ + Fₙ₋₂ for n > 2
Output the value of S.

2. Key Observations
- The Fibonacci numbers grow quickly but with K ≤ 40, all intermediate values and the sum fit comfortably in a 64-bit integer.
- A direct O(K) loop that builds each Fibonacci number and accumulates a running total is more than fast enough for K up to 40.
- There is a well-known closed-form identity:
    S = F₁ + F₂ + … + F_K = F_{K+2} − 1
  With that, you can compute F_{K+2} in O(K) and then subtract 1.

3. Full Solution Approach
Method A (Iterative Summation):
  1. Read integer K.
  2. Accumulate F₃..F_K in an O(K) loop starting from a = F₁ = 1, b = F₂ = 1.
  3. Finally add F₁ and F₂ (each equal to 1) whenever K reaches those indices (K ≥ 1 and K ≥ 2 respectively).
  4. Print S.

Method B (Using the Summation Identity):
  1. Read K.
  2. Compute F_{K+2} by the same O(K) loop.
  3. Output F_{K+2} − 1.

Because K is at most 40, both methods run in a few dozen operations.

4. C++ Implementation
```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n;

void read() { cin >> n; }

void solve() {
    // Sum of the first K Fibonacci numbers. We accumulate F3..FK iteratively
    // into sum and add F1 = F2 = 1 separately when K reaches those indices.
    // K < 41 so the result fits comfortably in a 64-bit integer.

    int64_t sum = 0;
    int64_t f1 = 1, f2 = 1;
    for(int i = 3; i <= n; i++) {
        int64_t fi = f1 + f2;
        sum += fi;
        f1 = f2;
        f2 = fi;
    }

    if(n >= 1) {
        sum += 1;
    }

    if(n >= 2) {
        sum += 1;
    }

    cout << sum << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```

5. Python Implementation with Detailed Comments
```python
import sys

def main():
    data = sys.stdin.read().strip().split()
    if not data:
        return
    k = int(data[0])

    # Handle small k directly
    if k == 1:
        print(1)
        return
    if k == 2:
        print(2)  # 1 + 1
        return

    # Initialize first two Fibonacci numbers
    a, b = 1, 1
    total = a + b  # sum of F1 and F2

    # Generate F3..Fk and accumulate their sum
    for _ in range(3, k + 1):
        c = a + b     # next Fibonacci number
        total += c    # add to running total
        a, b = b, c   # shift for next iteration

    print(total)

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