#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define CHUNKSIZE 1024         /* must be < 64k - 1 */

typedef struct digstr_s {
	uint8_t digits[CHUNKSIZE];
	struct digstr_s* next;
} digstr_t;

int NTHFIBO;
char col = 0;

void
die()
{
	fprintf(stderr, "Out of memory.\n");
	exit(1);
}

void
printdigits( digstr_t* p )
{
	static uint16_t wpos;
	static char skipping = 1;
	if( p->next ) printdigits(p->next);
	for( wpos = CHUNKSIZE - 1; wpos != ((1<<16) - 1); wpos-- ) {
		if( skipping ) {
			if( ! p->digits[wpos] ) continue;
			else skipping = 0;
		}
		putchar('0' + p->digits[wpos]);
		if( ++col == 80 ) {
			putchar('\n');
			col = 0;
		}
	}
}

int
main( int argc, char** argv )
{
	digstr_t* h1;
	digstr_t* h2;
	digstr_t* p1;
	digstr_t* p2;
	digstr_t* tmp;
	char carry;
	char nib;
	uint16_t wpos;
	uint32_t i;

	scanf(" %d ", &NTHFIBO);
	if( NTHFIBO < 1 ) {
		exit(1);
	}

	if( !(h1 = malloc(sizeof(digstr_t))) ) die();
	if( !(h2 = malloc(sizeof(digstr_t))) ) die();
	memset(h1->digits, 0, CHUNKSIZE * sizeof(uint8_t));
	h1->next = 0;
	memset(h2->digits, 0, CHUNKSIZE * sizeof(uint8_t));
	h2->next = 0;
	h2->digits[0] = 1;

	for( i = 2; i <= NTHFIBO; i++ ) {
		/* compute ith fibo num from (i-1)th (h2) and (i-2)th (h1) */
		p1 = h1;
		p2 = h2;
		carry = 0;
		
		while( p1 && p2 ) {
			/* compute this chunk of nth fibo num */
			for( wpos = 0; wpos < CHUNKSIZE; wpos++ ) {
				nib = p1->digits[wpos] +
					  p2->digits[wpos] + carry;
				if( nib > 9 ) {
					nib %= 10;
					carry = 1;
				} else carry = 0;
				p1->digits[wpos] = nib;
			}
			if( ! p1->next && carry ) {
				if( !(p1->next = malloc(sizeof(digstr_t))) ) die();
				if( !(p2->next = malloc(sizeof(digstr_t))) ) die();
				memset(p1->next->digits, 0, CHUNKSIZE * sizeof(uint8_t));
				p1->next->next = 0;
				memset(p2->next->digits, 0, CHUNKSIZE * sizeof(uint8_t));
				p2->next->next = 0;
				p1->next->digits[0] = carry;
				break;
			}
			p1 = p1->next;
			p2 = p2->next;
		}
		
		tmp = h1;
		h1 = h2;
		h2 = tmp;
	}

	printdigits(h2);
	if( col ) putchar('\n');
	
	return 0;
}
