#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

int d[1000], c[1000];
int n, m;

lli memo[1000][1000];

lli rec(int day, int now)
{
	if (now == n) return 0;

	if (memo[day][now] >= 0) return memo[day][now];

	lli res;

	if (m - day <= n - now) {
		res = rec(day + 1, now + 1) + d[now] * c[day];
	} else {
		res = min(rec(day + 1, now + 1) + d[now] * c[day], rec(day + 1, now));
	}

	return memo[day][now] = res;
}

int main()
{
	cin >> n >> m;
	
	for (int i = 0; i < n; ++i) cin >> d[i];

	for (int i = 0; i < m; ++i) cin >> c[i];

	memset(memo, -1, sizeof(memo));

	printf("%lld\n", rec(0, 0));
}