#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;

int dp[1000][1000];//??°??????????????\??°
int d[1000];
int c[1000];

int main(){
	int n, m;
	memset(dp, -1, sizeof(dp));
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", &d[i]);
	for (int i = 0; i < m; i++)
		scanf("%d", &c[i]);
	for (int i = 1; i <= n; i++){
		for (int j = i; j <= m; j++){
			if (!~dp[i][j - 1])dp[i][j] = dp[i - 1][j - 1] + d[i - 1] * c[j - 1];
			else dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + d[i - 1] * c[j - 1]);
		}
	}
	printf("%d\n", dp[n][m] + 1);
	return 0;
}