#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VII;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);

    int N, dummy;
    int min = 1e9;
    bool can = false;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> dummy;
        if(dummy == min){
            can = false;
        }else if(dummy < min){
            min = dummy;
            can = true;
        }
    }

    if(!can) cout << "Still Rozdil" << endl;
    else cout << min << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VII;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);

    int N, dummy;
    int min = 1e9;
    bool can = true;

    cin >> N;
    int anw = 0;
    for(int i = 0; i < N; i++){
        cin >> dummy;
        if(dummy == min){
            can = false;
        }else if(dummy < min){
            min = dummy;
            can = true;
            anw = i + 1;
        }
    }
    if(!can) cout << "Still Rozdil" << endl;
    else cout << anw << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VII;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);

    int N, dummy;
    int min = 1e9;
    bool can = false;

    cin >> N;
    int anw = N;
    for(int i = 0; i < N; i++){
        cin >> dummy;
        if(dummy == min){
            can = false;
            anw--;
        }else if(dummy < min){
            min = dummy;
            can = true;
        }
    }

    if(!can) cout << "Still Rozdil" << endl;
    else cout << anw << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VII;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);

    int N, dummy;
    int min = 1e9;
    bool can = false;

    cin >> N;
    int anw = 0;
    for(int i = 0; i < N; i++){
        cin >> dummy;
        if(dummy == min){
            can = false;
        }else if(dummy < min){
            min = dummy;
            can = true;
            anw = i + 1;
        }
    }

    if(!can) cout << "Still Rozdil" << endl;
    else cout << anw << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VII;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);

    int N;
    set<int> mset;
    cin >> N;
    int mini,pos;
    mini = 1e9;

    for(int i = 0; i < N; i++){
        int dummy;
        cin >> dummy;
        if(dummy < mini){
            mini = dummy;
            pos = i+1;
        }
        mset.insert(dummy);
    }

    if(mset.size() != N) cout << "Still Rozdil" << endl;
    else cout << pos << endl;

    return 0;
}


/*
 *
 * @Author  Ajudiya_13(Bhargav Girdharbhai Ajudiya)
 * Dhirubhai Ambani Institute of Information And Communication Technology
 *
 */

import java.util.*;
import java.io.*;
import java.lang.*;

public class Code1
{

	public static void main(String[] args)
	{
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		pw.flush();
		pw.close();
	}

	static class InputReader
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}

	public static long mod = 1000000007;
	public static int d;
	public static int p;
	public static int q;

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static HashSet<Integer> primeFactorization(int n)
	{
		HashSet<Integer> a =new HashSet<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static void extendedEuclid(int A,int B)
	{
		if(B==0)
		{
			d = A;
			p = 1 ;
			q = 0;
		}
		else
		{
			extendedEuclid(B, A%B);
			int temp = p;
			p = q;
			q = temp - (A/B)*q;
		}
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString()
		{
			return x+" "+y;
		}

		public boolean equals(Object o)
		{
			if (o instanceof pair)
		    {
				pair p = (pair)o;
				return p.x == x && p.y == y ;
			}
			return false;
		}

		public int hashCode()
		{
			return new Long(x).hashCode()*31 + new Long(y).hashCode();
		}
	}
}


/*
 *
 * @Author  Ajudiya_13(Bhargav Girdharbhai Ajudiya)
 * Dhirubhai Ambani Institute of Information And Communication Technology
 *
 */

import java.util.*;
import java.io.*;
import java.lang.*;

public class Code298
{

	public static void main(String[] args)
	{
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];

		for(int i=1;i<=n;i++)
			a[i] = in.nextInt();
		for(int i=1;i<=n;i++)
			b[i] = in.nextInt();

		int[] np = new int[n+1];
		int[] sp = new int[n+1];

		for(int i=1;i<=n;i++)
		{
			np[i] = a[i] + np[i-1];
			if(b[i]==0)
				sp[i] = sp[i-1];
			else
				sp[i] =a[i] + sp[i-1];
		}

		int ans = sp[n];
		for(int i=1;i<=n;i++)
		{
			int j = i+k-1;
			int temp = 0;
			if(j<=n)
			{
				temp = sp[i-1] + np[j] - np[i-1];
				if(j<n)
					temp += sp[n]-sp[j+1];
			}

			ans = Math.max(ans, temp);

		}
		pw.println(ans);
		pw.flush();
		pw.close();
	}

	static class InputReader
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}

	public static long mod = 1000000007;
	public static int d;
	public static int p;
	public static int q;

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static HashSet<Integer> primeFactorization(int n)
	{
		HashSet<Integer> a =new HashSet<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static void extendedEuclid(int A,int B)
	{
		if(B==0)
		{
			d = A;
			p = 1 ;
			q = 0;
		}
		else
		{
			extendedEuclid(B, A%B);
			int temp = p;
			p = q;
			q = temp - (A/B)*q;
		}
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString()
		{
			return x+" "+y;
		}

		public boolean equals(Object o)
		{
			if (o instanceof pair)
		    {
				pair p = (pair)o;
				return p.x == x && p.y == y ;
			}
			return false;
		}

		public int hashCode()
		{
			return new Long(x).hashCode()*31 + new Long(y).hashCode();
		}
	}
}


/*
 *
 * @Author  Ajudiya_13(Bhargav Girdharbhai Ajudiya)
 * Dhirubhai Ambani Institute of Information And Communication Technology
 *
 */

import java.util.*;
import java.io.*;
import java.lang.*;

public class Code298
{

	public static void main(String[] args)
	{
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];

		for(int i=1;i<=n;i++)
			a[i] = in.nextInt();
		for(int i=1;i<=n;i++)
			b[i] = in.nextInt();

		int[] np = new int[n+1];
		int[] sp = new int[n+1];

		for(int i=1;i<=n;i++)
		{
			np[i] = a[i] + np[i-1];
			if(b[i]==0)
				sp[i] = sp[i-1];
			else
				sp[i] =a[i] + sp[i-1];
		}

		int ans = sp[n];
		for(int i=1;i<=(n-k+1);i++)
		{
			int j = i+k-1;
			int temp = sp[i-1] + np[j] - np[i-1];
			if(j<n)
				temp += sp[n]-sp[j+1];

			ans = Math.max(ans, temp);

		}
		pw.println(ans);
		pw.flush();
		pw.close();
	}

	static class InputReader
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}

	public static long mod = 1000000007;
	public static int d;
	public static int p;
	public static int q;

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static HashSet<Integer> primeFactorization(int n)
	{
		HashSet<Integer> a =new HashSet<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static void extendedEuclid(int A,int B)
	{
		if(B==0)
		{
			d = A;
			p = 1 ;
			q = 0;
		}
		else
		{
			extendedEuclid(B, A%B);
			int temp = p;
			p = q;
			q = temp - (A/B)*q;
		}
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString()
		{
			return x+" "+y;
		}

		public boolean equals(Object o)
		{
			if (o instanceof pair)
		    {
				pair p = (pair)o;
				return p.x == x && p.y == y ;
			}
			return false;
		}

		public int hashCode()
		{
			return new Long(x).hashCode()*31 + new Long(y).hashCode();
		}
	}
}


/*
 *
 * @Author  Ajudiya_13(Bhargav Girdharbhai Ajudiya)
 * Dhirubhai Ambani Institute of Information And Communication Technology
 *
 */

import java.util.*;
import java.io.*;
import java.lang.*;

public class Code298
{

	public static void main(String[] args)
	{
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];

		for(int i=1;i<=n;i++)
			a[i] = in.nextInt();
		for(int i=1;i<=n;i++)
			b[i] = in.nextInt();

		int[] np = new int[n+1];
		int[] sp = new int[n+1];

		for(int i=1;i<=n;i++)
		{
			np[i] = a[i] + np[i-1];
			if(b[i]==0)
				sp[i] = sp[i-1];
			else
				sp[i] =a[i] + sp[i-1];
		}

		int ans = sp[n];
		for(int i=1;i<=n;i++)
		{
			int j = i+k-1;
			int temp = 0;
			if(j<=n)
			{
				temp = sp[i-1] + np[j] - np[i-1];
				if(j<n)
					temp += sp[n]-sp[j];
			}

			ans = Math.max(ans, temp);

		}
		pw.println(ans);
		pw.flush();
		pw.close();
	}

	static class InputReader
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}

	public static long mod = 1000000007;
	public static int d;
	public static int p;
	public static int q;

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static HashSet<Integer> primeFactorization(int n)
	{
		HashSet<Integer> a =new HashSet<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static void extendedEuclid(int A,int B)
	{
		if(B==0)
		{
			d = A;
			p = 1 ;
			q = 0;
		}
		else
		{
			extendedEuclid(B, A%B);
			int temp = p;
			p = q;
			q = temp - (A/B)*q;
		}
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString()
		{
			return x+" "+y;
		}

		public boolean equals(Object o)
		{
			if (o instanceof pair)
		    {
				pair p = (pair)o;
				return p.x == x && p.y == y ;
			}
			return false;
		}

		public int hashCode()
		{
			return new Long(x).hashCode()*31 + new Long(y).hashCode();
		}
	}
}


//package ACM;

import java.util.Scanner;

public class LectureSleep {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s1=0,max=0;
		int a[] = new int[n];
		int b[] = new int[n];
		for(int i = 0;i<n;i++)
		{
			a[i] = sc.nextInt();
		}
		for(int i = 0;i<n;i++)
		{
			b[i] = sc.nextInt();
			if(b[i]==0)
			{
				continue;
			}
			s1+=a[i];
			a[i]=0;
		}

		for(int i=k-1;i<n;i++)
		{
			int s2 =0;
			for(int j =i;j>=i-k+1;j--)
			{
				s2+=a[j];
			}
			max = Math.max(s2, max);
		}
		System.out.println(s1+max);
		sc.close();
	}

}


//package ACM;

import java.util.Scanner;

public class LectureSleep {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s1=0,max=0;
		int a[] = new int[n];
		int b[] = new int[n];
		for(int i = 0;i<n;i++)
		{
			a[i] = sc.nextInt();
		}
		for(int i = 0;i<n;i++)
		{
			b[i] = sc.nextInt();
			if(b[i]==0)
			{
				continue;
			}
			s1+=a[i];
			a[i]=0;
		}
		for(int i=0;i<=n-k;i++)
		{
			int s2 =0;
			for(int j=i;j<i+k;j++)
			{
				s2+=a[j];
			}
			max = Math.max(s2, max);
		}
		System.out.println(s1+max);
		sc.close();
	}

}


//package ACM;

import java.util.Scanner;

public class LectureSleep {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s1=0,max=0;
		int a[] = new int[n];
		int b[] = new int[n];
		for(int i = 0;i<n;i++)
		{
			a[i] = sc.nextInt();
		}
		for(int i = 0;i<n;i++)
		{
			b[i] = sc.nextInt();
			if(b[i]==0)
			{
				continue;
			}
			s1+=a[i];
			a[i]=0;
		}

		for(int i =0;i<k;i++)
		{
			if(b[i]==0)
			{
				max+=a[i];
			}
		}
		int s2 =max;
		for(int i =k;i<n;i++)
		{
			if(b[i]==0)
			{
				s2+=a[i];
			}
			if(b[i-k]==0)
			{
				s2-=a[i-k];
			}
			max = Math.max(max, s2);
		}
		System.out.println(s1+max);
		sc.close();
	}

}


import java.util.Scanner;

public class a
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),k=in.nextInt(),maxn=10000+10;
		int[] a=new int[maxn],b=new int[maxn];
		int[] sum1=new int[maxn],sum2=new int[maxn],sum3=new int[maxn];
		for(int i=1;i<=n;i++)a[i]=in.nextInt();
		for(int i=1;i<=n;i++)b[i]=in.nextInt();
		for(int i=1;i<=n;i++)
		{
			sum3[i]=sum3[i-1]+a[i];
			if(b[i]==1)sum2[i]=sum2[i-1]+a[i];
			else sum2[i]=sum2[i-1];
		}
		for(int i=n+1;i>=1;i--)
		{
			if(b[i]==1)sum1[i]=sum1[i+1]+a[i];
			else sum1[i]=sum1[i+1];
		}
		long maxx=0;
		for(int i=1;i+k-1<=n;i++)
		{
			long ans=0;
			ans=(sum3[i+k-1]-sum3[i-1]);
            ans+=sum2[i-1];
            ans+=sum1[i+k];
            maxx=Math.max(maxx,ans);
		}
		System.out.println(maxx);
	}
}


import java.util.Scanner;

public class a
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),k=in.nextInt(),maxn=20000+10;
		int[] a=new int[maxn],b=new int[maxn];
		int[] sum1=new int[maxn],sum2=new int[maxn],sum3=new int[maxn];
		for(int i=1;i<=n;i++)a[i]=in.nextInt();
		for(int i=1;i<=n;i++)b[i]=in.nextInt();
		for(int i=1;i<=n;i++)
		{
			sum3[i]=sum3[i-1]+a[i];
			if(b[i]==1)sum2[i]=sum2[i-1]+a[i];
			else sum2[i]=sum2[i-1];
		}
		for(int i=n+1;i>=1;i--)
		{
			if(b[i]==1)sum1[i]=sum1[i+1]+a[i];
			else sum1[i]=sum1[i+1];
		}
		long maxx=0;
		for(int i=1;i+k-1<=n;i++)
		{
			long ans=0;
			ans=(sum3[i+k-1]-sum3[i-1]);
            ans+=sum2[i-1];
            ans+=sum1[i+k];
            maxx=Math.max(maxx,ans);
		}
		System.out.println(maxx);
	}
}


import java.util.Scanner;

public class a
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),k=in.nextInt();
		final int maxn=200000+10;
		int[] a=new int[maxn],b=new int[maxn];
		int[] sum1=new int[maxn],sum2=new int[maxn],sum3=new int[maxn];
		for(int i=1;i<=n;i++)a[i]=in.nextInt();
		for(int i=1;i<=n;i++)b[i]=in.nextInt();
		for(int i=1;i<=n;i++)
		{
			sum3[i]=sum3[i-1]+a[i];
			if(b[i]==1)sum2[i]=sum2[i-1]+a[i];
			else sum2[i]=sum2[i-1];
		}
		for(int i=n+1;i>=1;i--)
		{
			if(b[i]==1)sum1[i]=sum1[i+1]+a[i];
			else sum1[i]=sum1[i+1];
		}
		long maxx=0;
		for(int i=1;i+k-1<=n;i++)
		{
			long ans=0;
			ans=(sum3[i+k-1]-sum3[i-1]);
            ans+=sum2[i-1];
            ans+=sum1[i+k];
            maxx=Math.max(maxx,ans);
		}
		System.out.println(maxx);
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Swatantra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];

            int i;
            for (i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            for (i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long tsum[] = new long[n];
            long tsum2[] = new long[n];

            tsum[0] = (b[0] == 0 ? 0 : a[0]);
            for (i = 1; i < n; i++) {

                if (b[i] == 0)
                    tsum[i] = 0;
                else
                    tsum[i] = tsum[i - 1] + a[i];
            }

            tsum2[n - 1] = (b[n - 1] == 0 ? 0 : a[n - 1]);
            for (i = n - 2; i >= 0; i--) {

                if (b[i] == 0)
                    tsum2[i] = 0;
                else
                    tsum2[i] = tsum[i + 1] + a[i];
            }

            int sum[] = new int[n];
            for (i = 0; i < k; i++) {
                //if(b[i]==1)
                sum[0] += a[i];
            }

            for (i = 1; i <= n - k; i++) {

                sum[i] = (sum[i - 1] - a[i - 1] + a[i + k - 1]);

            }
            int index = 0;
            long max = sum[0];

            for (i = 1; i <= n - k; i++) {

                long tot = (tsum[i - 1] + sum[i]);

                if (i + k < n) {
                    tot += tsum2[i + k];
                }

                if (max < tot) {
                    max = tot;
                    // index=i;
                }
            }
            out.println(max);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Swatantra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];

            int i;
            for (i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            for (i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long tsum[] = new long[n];
            long tsum2[] = new long[n];

            tsum[0] = (b[0] == 0 ? 0 : a[0]);
            for (i = 1; i < n; i++) {

                if (b[i] == 0)
                    tsum[i] = 0;
                else
                    tsum[i] = tsum[i - 1] + a[i];
            }

            tsum2[n - 1] = (b[n - 1] == 0 ? 0 : a[n - 1]);
            for (i = n - 2; i >= 0; i--) {

                if (b[i] == 0)
                    tsum2[i] = 0;
                else
                    tsum2[i] = tsum[i + 1] + a[i];
            }

            long sum[] = new long[n];
            for (i = 0; i < k; i++) {
                //if(b[i]==1)
                sum[0] += a[i];
            }

            for (i = 1; i <= n - k; i++) {

                sum[i] = (sum[i - 1] - a[i - 1] + a[i + k - 1]);

            }
            int index = 0;
            long max = sum[0];

            if (k < n) {
                max += tsum2[k];
            }

            for (i = 1; i <= n - k; i++) {

                long tot = (tsum[i - 1] + sum[i]);

                //out.println("i="+i);
                if (i + k < n) {
                    tot += tsum2[i + k];
                }

                if (max < tot) {
                    max = tot;
                    // index=i;
                }
            }
            out.println(max);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Swatantra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];

            int i;
            for (i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            for (i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long tsum[] = new long[n];
            long tsum2[] = new long[n];

            tsum[0] = (b[0] == 0 ? 0 : a[0]);
            for (i = 1; i < n; i++) {

                if (b[i] == 0)
                    tsum[i] = 0;
                else
                    tsum[i] = tsum[i - 1] + a[i];
            }

            tsum2[n - 1] = (b[n - 1] == 0 ? 0 : a[n - 1]);
            for (i = n - 2; i >= 0; i--) {

                if (b[i] == 0)
                    tsum2[i] = 0;
                else
                    tsum2[i] = tsum[i + 1] + a[i];
            }

            long sum[] = new long[n];
            for (i = 0; i < k; i++) {
                //if(b[i]==1)
                sum[0] += a[i];
            }

            for (i = 1; i <= n - k; i++) {

                sum[i] = (sum[i - 1] - a[i - 1] + a[i + k - 1]);

            }
            int index = 0;
            long max = sum[0];

            for (i = 1; i <= n - k; i++) {

                long tot = (tsum[i - 1] + sum[i]);

                if (i + k < n) {
                    tot += tsum2[i + k];
                }

                if (max < tot) {
                    max = tot;
                    // index=i;
                }
            }
            out.println(max);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Swatantra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];
            int chang[] = new int[n];
            int max = 0;
            int i;
            for (i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            //chang[0]=a[i];
            int ans = 0;
            for (i = 0; i < n; i++) {
                b[i] = in.nextInt();
                ans += (b[i] * a[i]);
                if (i > 0)
                    chang[i] = chang[i - 1] + (1 - b[i]) * a[i];
                else
                    chang[i] = (1 - b[i]) * a[i];

            }

            max = chang[k - 1];

            for (i = 1; i <= n - k; i++) {

                max = Math.max(max, chang[i + k - 1] - chang[i - 1]);
            }

            //out.println("Max="+max);
            out.println(max + ans);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Swatantra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];

            int i;
            for (i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            for (i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            int tsum[] = new int[n];
            int tsum2[] = new int[n];

            tsum[0] = (b[0] == 0 ? 0 : a[0]);
            for (i = 1; i < n; i++) {

                if (b[i] == 0)
                    tsum[i] = 0;
                else
                    tsum[i] = tsum[i - 1] + a[i];
            }

            tsum2[n - 1] = (b[n - 1] == 0 ? 0 : a[n - 1]);
            for (i = n - 2; i >= 0; i--) {

                if (b[i] == 0)
                    tsum2[i] = 0;
                else
                    tsum2[i] = tsum[i + 1] + a[i];
            }

            int sum[] = new int[n];
            for (i = 0; i < k; i++) {
                //if(b[i]==1)
                sum[0] += a[i];
            }

            for (i = 1; i <= n - k; i++) {

                sum[i] = (sum[i - 1] - a[i - 1] + a[i + k - 1]);

            }
            int index = 0;
            int max = sum[0];

            for (i = 1; i <= n - k; i++) {

                int tot = (tsum[i - 1] + sum[i]);

                if (i + k < n) {
                    tot += tsum2[i + k];
                }

                if (max < tot) {
                    max = tot;
                    // index=i;
                }
            }
            out.println(max);

        }

    }
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			long all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 1) all += a[i];
			}

			long maxzero = 0;
			int r = 0;
			int  l = k - 1;
			for(int i = 0; i < k; ++i) {
				if(t[i] == 0) maxzero += a[i];
			}
			long val = maxzero;
			for(int i = 1 ; i < n - k + 1  ;++i ) {
				val -= a[i - 1];
				if(t[i + k - 1] == 0) val += a[i + k - 1];

				if(val > maxzero) {
					maxzero = val;
					l = i;
					r = i + k - 1;
				}
			}
			for(int  i = l ; i  <= r ; ++i) {
				if(t[i] == 0) all += a[i];
			}
			out.println(all + maxzero);

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			int all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 0) all += a[i];
			}

			int maxzero = 0;
			int r = 0;
			int  l = k - 1;
			for(int i = 0; i < k; ++i) {
				if(t[i] == 1) ++maxzero;
			}
			int val = maxzero;
			for(int i = 1 ; i < n - k + 1  ;++i ) {
				if(t[i - 1] == 1) maxzero--;
				if(t[i + k - 1] == 1) ++maxzero;

				if(val > maxzero) {
					maxzero = val;
					l = i;
					r = i + k - 1;
				}
			}
			for(int  i = l ; i  <= r ; ++i) {
				if(t[i] == 1) all += a[i];
			}
			out.println(all);

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			int all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 0) all += a[i];
			}

			int max = 0;
			for(int i = 0; i < k; ++i) {
				max += a[i];
			}
			int val = max;
			for(int i = 1 ; i < n - k + 1  ;++i ) {
				val -= a[i - 1];
				val += a[i + k - 1 ];
				if(val > max) max = val;
			}

			out.println(Math.max(max, all));

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			long all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 1) all += a[i];
			}

			long maxzero = 0;
			int r = 0;
			int  l = k - 1;
			for(int i = 0; i < k; ++i) {
				if(t[i] == 0) maxzero += a[i];
			}
			long val = maxzero;
			for(int i = 1 ; i < n - k + 1  ;++i ) {
				if(t[i - 1] == 0) val -= a[i - 1];
				if(t[i + k - 1] == 0) val += a[i + k - 1];

				if(val > maxzero) {
					maxzero = val;
					l = i;
					r = i + k - 1;
				}
			}
			for(int  i = l ; i  <= r ; ++i) {
				if(t[i] == 0) all += a[i];
			}
			out.println(all);

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			int all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 1) all += a[i];
			}

			int maxzero = 0;
			int r = 0;
			int  l = k - 1;
			for(int i = 0; i < k; ++i) {
				if(t[i] == 0) maxzero += a[i];
			}
			int val = maxzero;
			for(int i = 1 ; i < n - k + 1  ;++i ) {
				if(t[i - 1] == 0) val -= a[i - 1];
				if(t[i + k - 1] == 0) val += a[i + k - 1];

				if(val > maxzero) {
					maxzero = val;
					l = i;
					r = i + k - 1;
				}
			}
			for(int  i = l ; i  <= r ; ++i) {
				if(t[i] == 0) all += a[i];
			}
			out.println(all);

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			long all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 1) all += a[i];
			}

			long maxzero = 0;
			for(int i = 0; i < k; ++i) {
				if(t[i] == 0) maxzero += a[i];
			}
			long val = maxzero;
			for(int i = 1 ; i < n - k + 1  ;++i ) {
				if(t[i - 1] == 0) val -= a[i - 1];
				if(t[i + k - 1] == 0) val += a[i + k - 1];

				if(val > maxzero) {
					maxzero = val;

				}
			}

			out.println(all + maxzero);

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;

import javax.swing.plaf.metal.MetalBorders.PaletteBorder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{

		 public static void main(String[] args) throws IOException {
			new Thread(null , new Main(),"Main", 1<<26).start();

		 }

		public void run(){
			try {
			PrintWriter out = new PrintWriter(System.out);
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = null;
			st = new StringTokenizer(br.readLine());
			int n = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int[] a = new int[n];
			int[] t = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i = 0 ; i < n ; ++i) {
				a[i] = parseInt(st.nextToken());

			}
			st = new StringTokenizer(br.readLine());
			for(int i = 0;  i < n ; ++i) {
				t[i] = parseInt(st.nextToken());
			}

			int all = 0;
			for(int i = 0; i < n ; ++i) {
				if(t[i] == 0) all += a[i];
			}

			int max = 0;
			for(int i = 0; i <= k; ++i) {
				max += a[i];
			}
			int val = max;
			for(int i = 1 ; i < n - k  ;++i ) {
				val -= a[i - 1];
				val += a[i + k ];
				if(val > max) max = val;
			}

			out.println(Math.max(max, all));

			out.close();
			}
			catch (Exception e) {
				e.printStackTrace();

			}

		}

}


import java.util.*;

public class Main{
    public static void main(String[] args){

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int[] a = new int[n];
		int[] t = new int[n];

		for(int i=0; i<n; i++)
			a[i] = s.nextInt();

		for(int i=0; i<n; i++)
			t[i] = s.nextInt();

		long currSum = 0;
		long maxSum = 0;
		for(int i=0; i<k; i++){
			if(t[i]==0)
				currSum+=a[i];
		}
		maxSum = currSum;
		for(int i=k; i<n; i++){
			int v1 = t[i], v2 = t[i-k];
			if(v1==0 && v2==1){
				currSum+=a[i];
			}else if(v1==1 && v2==0){
				currSum-=a[i-k];
			}else if(v1==0 && v2==0){
				currSum+=a[i]-a[i-k];
			}
			maxSum = Math.max(currSum, maxSum);
		}
		for(int i=0; i<n; i++)
			maxSum+=(t[i]==1)?a[i]:0;
		System.out.println(maxSum);

    }
}


import java.util.*;

public class Main{
    public static void main(String[] args){

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int[] a = new int[n];
		int[] t = new int[n];

		for(int i=0; i<n; i++)
			a[i] = s.nextInt();

		for(int i=0; i<n; i++)
			t[i] = s.nextInt();

		long currSum = 0;
		long maxSum = 0;
		for(int i=0; i<k; i++){
			if(t[i]==0)
				currSum+=a[i];
		}

		for(int i=k; i<n; i++){
			int v1 = t[i], v2 = t[i-k];
			if(v1==0 && v2==1){
				currSum+=a[i];
			}else if(v1==1 && v2==0){
				currSum-=a[i-k];
			}else if(v1==0 && v2==0){
				currSum+=a[i]-a[i-k];
			}
			maxSum = Math.max(currSum, maxSum);
		}
		for(int i=0; i<n; i++)
			maxSum+=(t[i]==1)?a[i]:0;
		System.out.println(maxSum);

    }
}


import java.util.*;

public class Main{
    public static void main(String[] args){

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int[] a = new int[n];
		int[] t = new int[n];

		for(int i=0; i<n; i++)
			a[i] = s.nextInt();

		for(int i=0; i<n; i++)
			t[i] = s.nextInt();

		long currSum = 0;
		long maxSum = 0;
		for(int i=0; i<k; i++){
			if(t[i]==0)
				currSum+=a[i];
		}
		maxSum = currSum
		for(int i=k; i<n; i++){
			int v1 = t[i], v2 = t[i-k];
			if(v1==0 && v2==1){
				currSum+=a[i];
			}else if(v1==1 && v2==0){
				currSum-=a[i-k];
			}else if(v1==0 && v2==0){
				currSum+=a[i]-a[i-k];
			}
			maxSum = Math.max(currSum, maxSum);
		}
		for(int i=0; i<n; i++)
			maxSum+=(t[i]==1)?a[i]:0;
		System.out.println(maxSum);

    }
}


import java.util.*;

public class Main{
    public static void main(String[] args){

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int[] a = new int[n];
		int[] t = new int[n];

		for(int i=0; i<n; i++)
			a[i] = s.nextInt();

		for(int i=0; i<n; i++)
			a[i] = s.nextInt();

		long currSum = 0;
		long maxSum = 0;
		for(int i=0; i<k; i++){
			if(t[i]==0)
				currSum+=a[i];
		}

		for(int i=k; i<n; i++){
			int v1 = t[i], v2 = t[i-k];
			if(v1==0 && v2==1){
				currSum+=a[i];
			}else if(v1==1 && v2==0){
				currSum-=a[i-k];
			}else if(v1==0 && v2==0){
				currSum+=a[i]-a[i-k];
			}
			maxSum = Math.max(currSum, maxSum);
		}
		for(int i=0; i<n; i++)
			maxSum+=(t[i]==1)?a[i]:0;
		System.out.println(maxSum);

    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
Scanner sc=new Scanner(System.in);

int n=sc.nextInt();
int k=sc.nextInt();

int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();

for(int i=0;i<n;i++)b[i]=sc.nextInt();

int sum=0;

for(int i=0;i<n;i++){
    if(b[i]==1)sum+=a[i];
}
int max=0;
for(int i=0;i<n;i++){
if(b[i]==0){int sum0=0;
for(int j=i;j<i+k && j<n;j++){
if(b[j]==0)
sum0+=a[j];
}
if(sum0>max)max=sum0;
}
}
System.out.println(sum+max);
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
Scanner sc=new Scanner(System.in);

int n=sc.nextInt();
int k=sc.nextInt();

int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();

for(int i=0;i<n;i++)b[i]=sc.nextInt();

int sum=0;

for(int i=0;i<n;i++){
    if(b[i]==1)sum+=a[i];
}
int curr_sum=0; int[] c=new int[n];
for(int i=0;i<n;i++){
if(b[i]==1)c[i]=0;
else c[i]=a[i];
}

for(int i=0;i<k;i++)curr_sum+=c[i];

int max_real=curr_sum;

for(int i=k;i<n;i++){
curr_sum+=c[i]-c[i-k];

max_real=Math.max(max_real,curr_sum);
}

System.out.println(sum+max_real);A
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
Scanner sc=new Scanner(System.in);

int n=sc.nextInt();
int k=sc.nextInt();

int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();

for(int i=0;i<n;i++)b[i]=sc.nextInt();

int sum=0;

for(int i=0;i<n;i++){
    if(b[i]==1)sum+=a[i];
}
int curr_sum=0; int[] c=new int[n];
for(int i=0;i<n;i++){
if(b[i]==1)c[i]=0;
else c[i]=a[i];
}

for(int i=0;i<k;i++)curr_sum+=c[i];

int max_real=curr_sum;

for(int i=k;i<n;i++){
curr_sum+=c[i]-c[i-k];

max_real=Math.max(max_real,curr_sum);
}

System.out.println(sum+max_real);
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
Scanner sc=new Scanner(System.in);

int n=sc.nextInt();
int k=sc.nextInt();

int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();

for(int i=0;i<n;i++)b[i]=sc.nextInt();

int sum=0;

for(int i=0;i<n;i++){
    if(b[i]==1)sum+=a[i];
}
int max=0; int[] c=new int[n];
for(int i=0;i<n;i++){
if(b[i]==1)c[i]=0;
else c[i]=a[i];
}

for(int i=0;i<k;i++)max+=c[i];

int max_real=0,max_unreal=0;

for(int i=1;i+k<n;i++){
max_unreal=max-c[i-1]+c[i+k-1];
if(max_unreal>max)max_real=max_unreal;
}

System.out.println(sum+max_real);
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
Scanner sc=new Scanner(System.in);

int n=sc.nextInt();
int k=sc.nextInt();

int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();

for(int i=0;i<n;i++)b[i]=sc.nextInt();

int sum=0;

for(int i=0;i<n;i++){
    if(b[i]==1)sum+=a[i];
}
int curr_sum=0; int[] c=new int[n];
for(int i=0;i<n;i++){
if(b[i]==1)c[i]=0;
else c[i]=a[i];
}

for(int i=0;i<k;i++)curr_sum+=c[i];

int max_real=curr_sum;

for(int i=1;i+k<n;i++){
curr_sum=curr_sum-c[i-1]+c[i+k-1];
if(curr_sum>max_real)max_real=curr_sum;
}

System.out.println(sum+max_real);
	}
}


import java.io.*;
import java.util.*;

public class Main {

    static final int INF = Integer.MAX_VALUE;

    static void mergeSort(int[] a, double[] b,  int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(int[] a, double[] b,  int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
       double[] L1 = new double[n1 + 1], R1 = new double[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }
     static void mergeSort(double[] a, int[] b,  int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(double[] a, int[] b,  int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        double[] L = new double[n1 + 1], R = new double[n2 + 1];
       int[] L1 = new int[n1 + 1], R1 = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }

    public static int[] sieve(int n) {
        int a[] = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            a[i] = 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (a[i] == 1) {
                for (int k = 2; i * k <= n; k++) {
                    a[i * k] = 0;
                }
            }
        }
        return a;
    }

    public static long sum(int a) {
        long su = 0;
        while (a > 0) {
            su += a % 10;
            a /= 10;
        }
        return su;
    }

    public static int divi(int b) {
        int n = 0;
        for (int i = 2; i <= Math.sqrt(b); i++) {
            if (b % i == 0) {
                n = i;
                break;
            }
        }
        if (n == 0) {
            return b;
        }
        return n;
    }

    public static boolean prime(int n) {

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static String reve(int a, int b, String s) {
        String q = "";
        for (int i = b; i >= a; i--) {
            q += s.charAt(i);
        }
        return q;
    }

    public static boolean isvowel(char c) {
        if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') {
            return true;
        } else {
            return false;
        }
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static int hole(int n) {
        int y = 0;
        if (n == 1) {
            return 0;
        }
        if (prime(n)) {
            return 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                if (prime(i)) {
                    y++;
                }
                if (prime(n / i) && i != (n / i)) {
                    y++;
                }
            }
        }
        return y;
    }

    static List<Integer> gd(int a,int b){
        int m=(int)gcd(a, b);
        List<Integer> q= new ArrayList();
       for(int i = 1; i * i <= m; ++i)
			if(m % i == 0)
			{
				q.add(i);
				if(i != m / i)
					q.add(m / i);
			}
        return q;
    }

    static boolean contain(int[] a) {
        for (int i = 1; i < a.length; i++) {
            if (a[i] == 0) {
                return true;
            }
        }
        return false;
    }

    static void decrease(int[] a) {
        for (int i = 1; i < a.length; i++) {
            a[i]--;
        }
    }

    static long power(StringBuilder s) {
        long c = 1, sum = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'C') {
                c *= 2;
            } else {
                sum += c;
            }
        }
        return sum;
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader(System.in);
        OutputWriter or = new OutputWriter(System.out);
        int n = in.nextInt(),k=in.nextInt(),m=n-k;
        int[]a=new int[n],t=new int[n];
        long sum=0,p=0;
        for(int i=0;i<n;i++)
            a[i]=in.nextInt();

        for(int i=0;i<n;i++){
             int y=in.nextInt();
            if (y==1) {
               sum+= (long)a[i];
            }
            else if(y==0&&i<=m)p+=(long)a[i];

            t[i]=y;
        }

        for (int i=1, q=m+1; q < n; q++) {
            //if(q>=n)break;
           p-=a[i-1];
            if (i++>m) {
                break;
            }
           // if (t[q]==0) {
               // System.out.println(p);
                p=Math.max(p, p+(long)a[q]);

            //}

        }
      or.print(sum+p);
        or.flush();

    }
}

class Pair implements Comparable<Pair> {

    int a;
    int b;
    int c;

    public Pair(int n, int p, int C) {
        a = n;
        b = p;
        c = C;
    }

    @Override
    public int compareTo(Pair o) {
        return b - o.b;
    }

}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}


import java.io.*;
import java.util.*;

public class Main {

    static final int INF = Integer.MAX_VALUE;

    static void mergeSort(int[] a, double[] b,  int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(int[] a, double[] b,  int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
       double[] L1 = new double[n1 + 1], R1 = new double[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }
     static void mergeSort(double[] a, int[] b,  int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(double[] a, int[] b,  int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        double[] L = new double[n1 + 1], R = new double[n2 + 1];
       int[] L1 = new int[n1 + 1], R1 = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }

    public static int[] sieve(int n) {
        int a[] = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            a[i] = 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (a[i] == 1) {
                for (int k = 2; i * k <= n; k++) {
                    a[i * k] = 0;
                }
            }
        }
        return a;
    }

    public static long sum(int a) {
        long su = 0;
        while (a > 0) {
            su += a % 10;
            a /= 10;
        }
        return su;
    }

    public static int divi(int b) {
        int n = 0;
        for (int i = 2; i <= Math.sqrt(b); i++) {
            if (b % i == 0) {
                n = i;
                break;
            }
        }
        if (n == 0) {
            return b;
        }
        return n;
    }

    public static boolean prime(int n) {

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static String reve(int a, int b, String s) {
        String q = "";
        for (int i = b; i >= a; i--) {
            q += s.charAt(i);
        }
        return q;
    }

    public static boolean isvowel(char c) {
        if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') {
            return true;
        } else {
            return false;
        }
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static int hole(int n) {
        int y = 0;
        if (n == 1) {
            return 0;
        }
        if (prime(n)) {
            return 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                if (prime(i)) {
                    y++;
                }
                if (prime(n / i) && i != (n / i)) {
                    y++;
                }
            }
        }
        return y;
    }

    static List<Integer> gd(int a,int b){
        int m=(int)gcd(a, b);
        List<Integer> q= new ArrayList();
       for(int i = 1; i * i <= m; ++i)
			if(m % i == 0)
			{
				q.add(i);
				if(i != m / i)
					q.add(m / i);
			}
        return q;
    }

    static boolean contain(int[] a) {
        for (int i = 1; i < a.length; i++) {
            if (a[i] == 0) {
                return true;
            }
        }
        return false;
    }

    static void decrease(int[] a) {
        for (int i = 1; i < a.length; i++) {
            a[i]--;
        }
    }

    static long power(StringBuilder s) {
        long c = 1, sum = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'C') {
                c *= 2;
            } else {
                sum += c;
            }
        }
        return sum;
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader(System.in);
        OutputWriter or = new OutputWriter(System.out);
        int n = in.nextInt(),k=in.nextInt(),m=n-k;
        int[]a=new int[n],t=new int[n];
        long sum=0,p=0;
        for(int i=0;i<n;i++)
            a[i]=in.nextInt();

        for(int i=0;i<n;i++){
             int y=in.nextInt();
            if (y==1) {
               sum+= (long)a[i];
            }
            else if(y==0&&i<=m)p+=(long)a[i];
            t[i]=y;
        }
        for (int i=1, q=m+1; q < n; q++) {
            //if(q>=n)break;
            p-=a[i-1];
            if (i++>m) {
                break;
            }
            if (t[q]==0) {
                p=Math.max(p, p+(long)a[q]);
            }

        }
      or.print(sum+p);
        or.flush();

    }
}

class Pair implements Comparable<Pair> {

    int a;
    int b;
    int c;

    public Pair(int n, int p, int C) {
        a = n;
        b = p;
        c = C;
    }

    @Override
    public int compareTo(Pair o) {
        return b - o.b;
    }

}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}


import java.io.*;
import java.util.*;

public class Main {

    static final int INF = Integer.MAX_VALUE;

    static void mergeSort(int[] a, double[] b,  int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(int[] a, double[] b,  int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
       double[] L1 = new double[n1 + 1], R1 = new double[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }
     static void mergeSort(double[] a, int[] b,  int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(double[] a, int[] b,  int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        double[] L = new double[n1 + 1], R = new double[n2 + 1];
       int[] L1 = new int[n1 + 1], R1 = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }

    public static int[] sieve(int n) {
        int a[] = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            a[i] = 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (a[i] == 1) {
                for (int k = 2; i * k <= n; k++) {
                    a[i * k] = 0;
                }
            }
        }
        return a;
    }

    public static long sum(int a) {
        long su = 0;
        while (a > 0) {
            su += a % 10;
            a /= 10;
        }
        return su;
    }

    public static int divi(int b) {
        int n = 0;
        for (int i = 2; i <= Math.sqrt(b); i++) {
            if (b % i == 0) {
                n = i;
                break;
            }
        }
        if (n == 0) {
            return b;
        }
        return n;
    }

    public static boolean prime(int n) {

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static String reve(int a, int b, String s) {
        String q = "";
        for (int i = b; i >= a; i--) {
            q += s.charAt(i);
        }
        return q;
    }

    public static boolean isvowel(char c) {
        if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') {
            return true;
        } else {
            return false;
        }
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static int hole(int n) {
        int y = 0;
        if (n == 1) {
            return 0;
        }
        if (prime(n)) {
            return 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                if (prime(i)) {
                    y++;
                }
                if (prime(n / i) && i != (n / i)) {
                    y++;
                }
            }
        }
        return y;
    }

    static List<Integer> gd(int a,int b){
        int m=(int)gcd(a, b);
        List<Integer> q= new ArrayList();
       for(int i = 1; i * i <= m; ++i)
			if(m % i == 0)
			{
				q.add(i);
				if(i != m / i)
					q.add(m / i);
			}
        return q;
    }

    static boolean contain(int[] a) {
        for (int i = 1; i < a.length; i++) {
            if (a[i] == 0) {
                return true;
            }
        }
        return false;
    }

    static void decrease(int[] a) {
        for (int i = 1; i < a.length; i++) {
            a[i]--;
        }
    }

    static long power(StringBuilder s) {
        long c = 1, sum = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'C') {
                c *= 2;
            } else {
                sum += c;
            }
        }
        return sum;
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader(System.in);
        OutputWriter or = new OutputWriter(System.out);
        int n = in.nextInt(),k=in.nextInt(),m=n-k;
        int[]a=new int[n],t=new int[n];
        long sum=0,p=0;
        for(int i=0;i<n;i++)
            a[i]=in.nextInt();

        for(int i=0;i<n;i++){
             int y=in.nextInt();
            if (y==1) {
               sum+= (long)a[i];
               a[i]=0;
            }

            t[i]=y;
        }
        for(int i=0;i<k;i++) p+=(long)a[i];
     long r=p;
        for (int i=0, q=m; q < n; q++) {
            //if(q>=n)break;
            if (i>m) {
                break;
            }
           p+=a[q]-a[i];
            r=Math.max(p, r);
           //if (t[q]==0) {

            //}
            i++;
        }
      or.print(sum+r);
        or.flush();

    }
}

class Pair implements Comparable<Pair> {

    int a;
    int b;
    int c;

    public Pair(int n, int p, int C) {
        a = n;
        b = p;
        c = C;
    }

    @Override
    public int compareTo(Pair o) {
        return b - o.b;
    }

}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}