unittest
{
	assert( [ "5", "3", "2", "4", "3", "5" ].parse.expand.solve == 7 );
	assert( [ "10", "123", "123", "123", "123", "123" ].parse.expand.solve == 5 );
//	assert( [ "10000000007", "2", "3", "5", "7", "11" ].parse.expand.solve == 5000000008 );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto ts = new long[ 5 ];
	foreach( ref t; ts )
	{
		t = input.front.to!( long );
		input.popFront;
	}
	return tuple( n, ts );
}

auto solve( long n, long[] ts )
{
	auto ans = 0L;
	auto m = n;
	foreach( t; ts )
	{
		if( t < m )
		{
			auto d = m / t;
			ans += d * ( d + 1 ) / 2;
			m = t;
		}
		ans++;
	}
	return ans;
}
