#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define SAFE_DELETE( x ) { if ( x ){ delete x ; x = NULL; } }

struct tCell{
	char x;
	tCell* prev;
	tCell* next;
};

class myInt{
public:
	myInt( int d = 0 ) : digit( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->x = tail->x = 0;
		head->prev = tail->next = NULL;
		head->next = tail;
		tail->prev = head;
		setFigure( d );
	}
	~myInt(){
		init();
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}
	void getNumber( string& s ){
		s = numStr;
		for( unsigned int i = 0; i < numStr.size(); ++i ){
			s[ i ] += '0';
		}
	}
	int getDigit(){
		return digit;
	}

	tCell operator[]( int d ){
		if ( d >= digit ){
			tCell* cell = NULL;
			return *cell;
		}
		tCell* cell = head->next;
		for ( int i = 0; i < d; ++i ){
			cell = cell->next;
		}
		return *cell;
	}
	void operator=( int d ){
		setFigure( d );
	}
	void operator=( myInt& mi ){
		init();
		for ( int i = 0; i < mi.getDigit(); ++i ){
			pushBack( mi[ i ].x );
		}
	}
	void operator+=( myInt& mi ){
		int max = ( digit < mi.getDigit() ? mi.getDigit() : digit ) + 1;
		secureDigit( max );
		mi.secureDigit( max );
		tCell* cell = head;
		for ( int i = 0; i < max-1; ++i ){
			cell = cell->next;
			cell->x += mi[ i ].x;
			if ( cell->x >= 10 ){
				cell->x %= 10;
				cell->next->x += 1;
			}
		}
		adjustDigit();
		rewrite();
		mi.adjustDigit();
	}
	void operator*=( int d ){
		myInt ee, result;
		ee = *this;
		int eeDigit = ee.getDigit();
		int dDigit = static_cast< int >( log10( static_cast< double >( d ) ) ) + 1;
		for ( int i = 0; i < dDigit; ++i ){
			init();
			secureDigit( eeDigit + 1 );
			tCell* cell = head;
			for ( int j = 0; j < eeDigit; ++j ){
				cell = cell->next;
				cell->x += ee[ j ].x * static_cast< char >( d % 10 );
				cell->next->x += ( cell->x / 10 );
				cell->x = ( cell->x % 10 );
			}
			for ( int j = 0; j < i; ++j ){
				pushFront( 0 );
			}
			result += *this;
			d /= 10;
		}
		*this = result;
	}

private:
	void init(){
		for ( int i = digit; i > 0; --i ){
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
		digit = 0;
		numStr = "";
	}
	void setFigure( int d ){
		init();
		while ( 1 ){
			if ( d < 10 ){
				pushBack( d );
				break;
			}
			pushBack( d%10 );
			d /= 10;
		}
	}
	void pushFront( int i ){
		++digit;
		tCell* cell = new tCell;
		cell->x = i;
		cell->prev = head;
		cell->next = head->next;
		cell->prev->next = cell;
		cell->next->prev = cell;
		numStr += static_cast< char >( i );
	}
	void pushBack( int i ){
		++digit;
		tCell* cell = new tCell;
		cell->x = i;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
		numStr = static_cast< char >( i ) + numStr;
	}
	tCell* eraseBack( tCell* cell ){
		tCell* temp = cell->prev;
		--digit;
		numStr.erase( 0, 1 );
		cell->prev->next = cell->next;
		cell->next->prev = cell->prev;
		SAFE_DELETE( cell );
		return temp;
	}
	void secureDigit( int d ){
		for ( int i = digit; i < d; ++i ){
			pushBack( 0 );
		}
	}
	void adjustDigit(){
		tCell* cell = tail->prev;
		while ( !cell->x ) {
			if ( digit <= 1 ) return;
			cell = eraseBack( cell );
		}
	}
	void rewrite(){
		numStr = "";
		tCell* cell = head;
		for ( int i = 0; i < digit; ++i ){
			cell = cell->next;
			numStr = static_cast< char >( cell->x ) + numStr;
		}
	}

	int digit;
	tCell* head;
	tCell* tail;
	string numStr;
};

ostream& operator<<( ostream& os, myInt& mi ){
	string s;
	mi.getNumber( s );
	return ( os << s.c_str() );
}

int main(){
	int n;
	myInt a( 1 );
	cin >> n;

	for ( int i = 0; i < n; i++ ){
		a *= ( i + 1 );
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 0