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<=m;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();
    }

}


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;i<n;i++){
			if(k>=n){break;}
			p=p+a[k]-a[i];
			k++;
			r=Math.max(r, p);
		}
      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();
    }

}


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

public class Solution {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		Task task = new Task();
		int t = 1;
		for (int i = 1; i <= t; i++) task.solve(i, in, out);
		out.close();
	}

	static class Task {

		public void solve(int testNumber, InputReader in, OutputWriter out) throws IOException {
			int n = in.nextInt(), k = in.nextInt();
			int[] a = in.nextIntArray(n + 1, 1), t = in.nextIntArray(n + 1, 1);
			long ans = 0, max = Long.MIN_VALUE;
			for (int i = 1; i <= n; i++) {
				if (t[i] == 1) {
					ans += a[i];
					a[i] = 0;
				}
			}
			for (int i = k; i <= n; i++) {
				long sum = 0;
				for (int j = i - k + 1; j <= i; j++) sum += a[j];
				max = Math.max(max, sum);
			}
			ans += max;
			out.println(ans, "\n");
		}
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private void tokenize() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		public String next() {
			tokenize();
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public float nextFloat() {
			return Float.parseFloat(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int size, int a) {
			tokenize();
			int[] arr=new int[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Integer.parseInt(tokenizer.nextToken());
			}
			return arr;
		}

		public long[] nextLongArray(int size, int a) {
			tokenize();
			long[] arr=new long[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Long.parseLong(tokenizer.nextToken());
			}
			return arr;
		}

		public float[] nextFloatArray(int size, int a) {
			tokenize();
			float[] arr=new float[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Float.parseFloat(tokenizer.nextToken());
			}
			return arr;
		}

		public double[] nextDoubleArray(int size, int a) {
			tokenize();
			double[] arr=new double[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Double.parseDouble(tokenizer.nextToken());
			}
			return arr;
		}

		public String[] nextStringArray(int size, int a) throws IOException {
			String[] arr=new String[size];
			for(int i = a; i < size; i++)
				arr[i] = reader.readLine();
			return arr;
		}

		public char[] nextCharArray() throws IOException {
			return reader.readLine().toCharArray();
		}
	}

	static class OutputWriter {
		public PrintWriter pw;

		public OutputWriter(OutputStream stream) {
			pw = new PrintWriter(stream);
		}

		public void println(Object... obj) {
			if (obj.length == 0) pw.println();
			else {
				String delimiter = (String) obj[obj.length - 1];
				for (int i = 0 ; i < obj.length - 1; i++) pw.print(obj[i] + delimiter);
			}
		}

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

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

		public void printStringArray(String[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.println(arr[i]);
			pw.println();
		}

		public void printBooleanArray(boolean[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printIntArray(int[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printLongArray(long[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printCharArray(char[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printFloatArray(float[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printDoubleArray(double[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printIntArrayList(ArrayList<Integer> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}

		public void printLongArrayList(ArrayList<Long> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}

		public void printStringArrayList(ArrayList<String> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}
	}
}


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

public class Solution {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		Task task = new Task();
		int t = 1;
		for (int i = 1; i <= t; i++) task.solve(i, in, out);
		out.close();
	}

	static class Task {

		public void solve(int testNumber, InputReader in, OutputWriter out) throws IOException {
			int n = in.nextInt(), k = in.nextInt();
			int[] a = in.nextIntArray(n + 1, 1), t = in.nextIntArray(n + 1, 1);
			long ans = 0, max = Long.MIN_VALUE;
			for (int i = 1; i <= n; i++) {
				if (t[i] == 1) {
					ans += a[i];
					a[i] = 0;
				}
			}
			long sum = 0;
			for (int i = 1; i <= k; i++) sum += a[i];
			max = Math.max(max, sum);
			for (int i = k + 1; i <= n; i++) {
				sum += (a[i] - a[i - k]);
				max = Math.max(max, sum);
			}
			ans += max;
			out.println(ans, "\n");
		}
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private void tokenize() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		public String next() {
			tokenize();
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public float nextFloat() {
			return Float.parseFloat(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int size, int a) {
			tokenize();
			int[] arr=new int[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Integer.parseInt(tokenizer.nextToken());
			}
			return arr;
		}

		public long[] nextLongArray(int size, int a) {
			tokenize();
			long[] arr=new long[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Long.parseLong(tokenizer.nextToken());
			}
			return arr;
		}

		public float[] nextFloatArray(int size, int a) {
			tokenize();
			float[] arr=new float[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Float.parseFloat(tokenizer.nextToken());
			}
			return arr;
		}

		public double[] nextDoubleArray(int size, int a) {
			tokenize();
			double[] arr=new double[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Double.parseDouble(tokenizer.nextToken());
			}
			return arr;
		}

		public String[] nextStringArray(int size, int a) throws IOException {
			String[] arr=new String[size];
			for(int i = a; i < size; i++)
				arr[i] = reader.readLine();
			return arr;
		}

		public char[] nextCharArray() throws IOException {
			return reader.readLine().toCharArray();
		}
	}

	static class OutputWriter {
		public PrintWriter pw;

		public OutputWriter(OutputStream stream) {
			pw = new PrintWriter(stream);
		}

		public void println(Object... obj) {
			if (obj.length == 0) pw.println();
			else {
				String delimiter = (String) obj[obj.length - 1];
				for (int i = 0 ; i < obj.length - 1; i++) pw.print(obj[i] + delimiter);
			}
		}

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

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

		public void printStringArray(String[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.println(arr[i]);
			pw.println();
		}

		public void printBooleanArray(boolean[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printIntArray(int[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printLongArray(long[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printCharArray(char[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printFloatArray(float[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printDoubleArray(double[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printIntArrayList(ArrayList<Integer> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}

		public void printLongArrayList(ArrayList<Long> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}

		public void printStringArrayList(ArrayList<String> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}
	}
}


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

public class Solution {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		Task task = new Task();
		int t = 1;
		for (int i = 1; i <= t; i++) task.solve(i, in, out);
		out.close();
	}

	static class Task {

		public void solve(int testNumber, InputReader in, OutputWriter out) throws IOException {
			int n = in.nextInt(), k = in.nextInt();
			int[] a = in.nextIntArray(n, 0), t = in.nextIntArray(n, 0);
			int ans = 0, max = Integer.MIN_VALUE;
			for (int i = 0; i < n; i++) {
				if (t[i] == 1) {
					ans += a[i];
					a[i] = 0;
				}
			}
			for (int i = 1; i < k; i++) a[i] += a[i - 1];
			for (int i = k; i < n; i++) {
				a[i] += (a[i - 1] - a[i - k]);
				max = Math.max(max, a[i]);
			}
			ans += max;
			out.println(ans, "\n");
		}
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private void tokenize() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		public String next() {
			tokenize();
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public float nextFloat() {
			return Float.parseFloat(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int size, int a) {
			tokenize();
			int[] arr=new int[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Integer.parseInt(tokenizer.nextToken());
			}
			return arr;
		}

		public long[] nextLongArray(int size, int a) {
			tokenize();
			long[] arr=new long[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Long.parseLong(tokenizer.nextToken());
			}
			return arr;
		}

		public float[] nextFloatArray(int size, int a) {
			tokenize();
			float[] arr=new float[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Float.parseFloat(tokenizer.nextToken());
			}
			return arr;
		}

		public double[] nextDoubleArray(int size, int a) {
			tokenize();
			double[] arr=new double[size];
			for(int i = a; i < size; i++) {
				tokenize();
				arr[i] = Double.parseDouble(tokenizer.nextToken());
			}
			return arr;
		}

		public String[] nextStringArray(int size, int a) throws IOException {
			String[] arr=new String[size];
			for(int i = a; i < size; i++)
				arr[i] = reader.readLine();
			return arr;
		}

		public char[] nextCharArray() throws IOException {
			return reader.readLine().toCharArray();
		}
	}

	static class OutputWriter {
		public PrintWriter pw;

		public OutputWriter(OutputStream stream) {
			pw = new PrintWriter(stream);
		}

		public void println(Object... obj) {
			if (obj.length == 0) pw.println();
			else {
				String delimiter = (String) obj[obj.length - 1];
				for (int i = 0 ; i < obj.length - 1; i++) pw.print(obj[i] + delimiter);
			}
		}

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

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

		public void printStringArray(String[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.println(arr[i]);
			pw.println();
		}

		public void printBooleanArray(boolean[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printIntArray(int[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printLongArray(long[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printCharArray(char[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printFloatArray(float[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printDoubleArray(double[] arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr[i] + delimiter);
			pw.println();
		}

		public void printIntArrayList(ArrayList<Integer> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}

		public void printLongArrayList(ArrayList<Long> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}

		public void printStringArrayList(ArrayList<String> arr, int a, int b, String delimiter) {
			for(int i = a; i < b; i++)
				pw.print(arr.get(i) + delimiter);
			pw.println();
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class lectureSleep{

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader sc = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int arr[]=new int[n];
    int t[]=new int[n];
    int c[]=new int[n+1];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      t[i]=sc.nextInt();
    }
    long sum=0;
    for(int i=0;i<n;i++){
      if(t[i]==0){
        c[i+1]=c[i]+arr[i];
      }else{
              sum+=arr[i];
              c[i+1]=c[i];
      }
    }
    int max=0;
    for(int i=0;i<=n-k;i++){
      if(c[i+k]-c[i]>max){
        max=c[i+k]-c[i];
      }
    }
    sum+=max;
    System.out.println(sum);

  }

  static class InputReader {
      public BufferedReader reader;
      public StringTokenizer tokenizer;

      public InputReader(InputStream stream) {
          reader = new BufferedReader(new InputStreamReader(stream), 32768);
          tokenizer = null;
      }

      public String next() {
          while (tokenizer == null || !tokenizer.hasMoreTokens()) {
              try {
                  tokenizer = new StringTokenizer(reader.readLine());
              } catch (IOException e) {
                  throw new RuntimeException(e);
              }
          }
          return tokenizer.nextToken();
      }

      public int nextInt() {
          return Integer.parseInt(next());
      }

      public long nextLong()
      {
        return Long.parseLong(next());
      }

  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class lectureSleep{

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader sc = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int arr[]=new int[n];
    int t[]=new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      t[i]=sc.nextInt();
    }
    long max=0;
    long sum=0;
    int low=0,high=0;
    for(int i=0;i<n-k+1;i++){
      sum=0;
      if(t[i]==0){
        for(int j=i;j<i+k;j++){
              sum+=arr[j];
        }
        if(sum>=max){
          max=sum;
          low=i;
          high=i+1;
        }
      }
    }
    long sum2=0;
    for(int i=0;i<low;i++){
        if(t[i]==1){
          sum2+=arr[i];
        }
    }

    for(int i=high+1;i<n;i++){
          if(t[i]==1){
            sum2+=high;
          }
    }
    System.out.println(max+sum2);

  }

  static class InputReader {
      public BufferedReader reader;
      public StringTokenizer tokenizer;

      public InputReader(InputStream stream) {
          reader = new BufferedReader(new InputStreamReader(stream), 32768);
          tokenizer = null;
      }

      public String next() {
          while (tokenizer == null || !tokenizer.hasMoreTokens()) {
              try {
                  tokenizer = new StringTokenizer(reader.readLine());
              } catch (IOException e) {
                  throw new RuntimeException(e);
              }
          }
          return tokenizer.nextToken();
      }

      public int nextInt() {
          return Integer.parseInt(next());
      }

      public long nextLong()
      {
        return Long.parseLong(next());
      }

  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class lectureSleep{

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader sc = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int arr[]=new int[n];
    int t[]=new int[n];
    int c[]=new int[n+1];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      t[i]=sc.nextInt();
    }
    long sum=0;
    for(int i=0;i<n;i++){
      if(t[i]==0){
        c[i+1]=c[i]+arr[i];
      }else{
              sum+=arr[i];
              c[i+1]=c[i];
      }
    }
    int max=0;
    for(int i=0;i<=n-k;i++){
      if(c[i+k]-c[i]>max){
        max=c[i+k]-c[i];
      }
    }
    sum+=max;
    System.out.println(max);

  }

  static class InputReader {
      public BufferedReader reader;
      public StringTokenizer tokenizer;

      public InputReader(InputStream stream) {
          reader = new BufferedReader(new InputStreamReader(stream), 32768);
          tokenizer = null;
      }

      public String next() {
          while (tokenizer == null || !tokenizer.hasMoreTokens()) {
              try {
                  tokenizer = new StringTokenizer(reader.readLine());
              } catch (IOException e) {
                  throw new RuntimeException(e);
              }
          }
          return tokenizer.nextToken();
      }

      public int nextInt() {
          return Integer.parseInt(next());
      }

      public long nextLong()
      {
        return Long.parseLong(next());
      }

  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class lectureSleep{

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader sc = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int arr[]=new int[n];
    int t[]=new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      t[i]=sc.nextInt();
    }
    long max=0;
    long sum=0;
    int low=0,high=0;
    for(int i=0;i<n-k+1;i++){
      sum=0;
      if(t[i]==0){
        for(int j=i;j<i+k;j++){
              sum+=arr[j];
        }
        if(sum>=max){
          max=sum;
          low=i;
          high=i+k-1;
        }
      }
    }
   // System.out.println("max: "+max+" low: "+low+" high: "+high);
    long sum2=0;
    for(int i=0;i<low;i++){
        if(t[i]==1){
          sum2+=arr[i];
        }
    }

    for(int i=high+1;i<n;i++){
          if(t[i]==1){
            sum2+=high;
          }
    }
    System.out.println(max+sum2);

  }

  static class InputReader {
      public BufferedReader reader;
      public StringTokenizer tokenizer;

      public InputReader(InputStream stream) {
          reader = new BufferedReader(new InputStreamReader(stream), 32768);
          tokenizer = null;
      }

      public String next() {
          while (tokenizer == null || !tokenizer.hasMoreTokens()) {
              try {
                  tokenizer = new StringTokenizer(reader.readLine());
              } catch (IOException e) {
                  throw new RuntimeException(e);
              }
          }
          return tokenizer.nextToken();
      }

      public int nextInt() {
          return Integer.parseInt(next());
      }

      public long nextLong()
      {
        return Long.parseLong(next());
      }

  }

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class be41 {
    static PrintWriter out;
    static BufferedReader in;
    static StringTokenizer st;

    public static void main(String[] args) throws FileNotFoundException {
        out = new PrintWriter(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
        new be41().Run();
        out.close();
    }

    String ns() {
        try {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            return null;
        }
    }

    int nextint() {
        return Integer.valueOf(ns());
    }

    String nextline() {
        st = null;
        try {
            return in.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public void Run() {

        int n = nextint();
        int m = nextint();

        int [] arr = new int [n];
        int [] arr2 = new int [n];

        for(int i = 0; i < n; i++){
            arr[i] = nextint();
        }

        int res = 0;
        for(int i = 0; i < n; i++){
            arr2[i] = nextint();
            if (arr2[i] == 1) res+=arr[i];
        }

        long res2 = 0;

        int [] pSum = new int [n+1];

        for(int i = 0; i < n; i++){
            pSum[i+1] = pSum[i];
            if(arr2[i] == 0){
                pSum[i+1] += arr[i];
            }
        }

        for(int i = 0; i < Math.min(n - m + 1, m); i++) {
            res2 = Math.max(res2, pSum[i+m] - pSum[i]);
        }

        out.println(res2 + res);
    }

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class be41 {
    static PrintWriter out;
    static BufferedReader in;
    static StringTokenizer st;

    public static void main(String[] args) throws FileNotFoundException {
        out = new PrintWriter(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
        new be41().Run();
        out.close();
    }

    String ns() {
        try {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            return null;
        }
    }

    int nextint() {
        return Integer.valueOf(ns());
    }

    String nextline() {
        st = null;
        try {
            return in.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public void Run() {

        int n = nextint();
        int m = nextint();

        int [] arr = new int [n];
        int [] arr2 = new int [n];

        for(int i = 0; i < n; i++){
            arr[i] = nextint();
        }

        int res = 0;
        for(int i = 0; i < n; i++){
            arr2[i] = nextint();
            if (arr2[i] == 1) res+=arr[i];
        }

        int res2 = 0;

        for(int i = 0; i < Math.min(n - m, m); i++) {
            if (arr2[i] == 0) {
                int res3 = 0;
                for (int j = i; j < Math.min(i + m, n); j++) {
                    if (arr2[j] == 0) {
                        res3 += arr[j];
                    }
                }
                res2 = Math.max(res2, res3);
            }
        }

        out.println(res2 + res);
    }

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class be41 {
    static PrintWriter out;
    static BufferedReader in;
    static StringTokenizer st;

    public static void main(String[] args) throws FileNotFoundException {
        out = new PrintWriter(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
        new be41().Run();
        out.close();
    }

    String ns() {
        try {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            return null;
        }
    }

    int nextint() {
        return Integer.valueOf(ns());
    }

    String nextline() {
        st = null;
        try {
            return in.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public void Run() {

        int n = nextint();
        int m = nextint();

        int [] arr = new int [n];
        int [] arr2 = new int [n];

        for(int i = 0; i < n; i++){
            arr[i] = nextint();
        }

        int res = 0;
        for(int i = 0; i < n; i++){
            arr2[i] = nextint();
            if (arr2[i] == 1) res+=arr[i];
        }

        long res2 = 0;

        int [] pSum = new int [n+1];

        for(int i = 0; i < n; i++){
            pSum[i+1] = pSum[i];
            if(arr2[i] == 0){
                pSum[i+1] += arr[i];
            }
        }

        for(int i = 0; i < n - m + 1; i++) {
            res2 = Math.max(res2, pSum[i+m] - pSum[i]);
        }

        out.println(res2 + res);
    }

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class be41 {
    static PrintWriter out;
    static BufferedReader in;
    static StringTokenizer st;

    public static void main(String[] args) throws FileNotFoundException {
        out = new PrintWriter(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
        new be41().Run();
        out.close();
    }

    String ns() {
        try {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            return null;
        }
    }

    int nextint() {
        return Integer.valueOf(ns());
    }

    String nextline() {
        st = null;
        try {
            return in.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public void Run() {

        int n = nextint();
        int m = nextint();

        int [] arr = new int [n];
        int [] arr2 = new int [n];

        for(int i = 0; i < n; i++){
            arr[i] = nextint();
        }

        int res = 0;
        for(int i = 0; i < n; i++){
            arr2[i] = nextint();
            if (arr2[i] == 1) res+=arr[i];
        }

        int res2 = 0;

        for(int i = 0; i < n; i++) {
            if (arr2[i] == 0) {
                int res3 = 0;
                for (int j = i; j < Math.min(i + m, n); j++) {
                    if (arr2[j] == 0) {
                        res3 += arr[j];
                    }
                }
                res2 = Math.max(res2, res3);
            }
        }

        out.println(res2 + res);
    }

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class be41 {
    static PrintWriter out;
    static BufferedReader in;
    static StringTokenizer st;

    public static void main(String[] args) throws FileNotFoundException {
        out = new PrintWriter(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
        new be41().Run();
        out.close();
    }

    String ns() {
        try {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            return null;
        }
    }

    int nextint() {
        return Integer.valueOf(ns());
    }

    String nextline() {
        st = null;
        try {
            return in.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public void Run() {

        int n = nextint();
        int m = nextint();

        int [] arr = new int [n];
        int [] arr2 = new int [n];

        for(int i = 0; i < n; i++){
            arr[i] = nextint();
        }

        int res = 0;
        for(int i = 0; i < n; i++){
            arr2[i] = nextint();
            if (arr2[i] == 1) res+=arr[i];
        }

        int res2 = 0;

        for(int i = 0; i < Math.min(n - m + 1, m); i++) {
            if (arr2[i] == 0) {
                int res3 = 0;
                for (int j = i; j < Math.min(i + m, n); j++) {
                    if (arr2[j] == 0) {
                        res3 += arr[j];
                    }
                }
                res2 = Math.max(res2, res3);
            }
        }

        out.println(res2 + res);
    }

}


import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        long n,k, temp;
        long ris = 0;
        long ris2;
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextLong();
        k = scanner.nextLong();

        long[] vet = new long[(int)n];

        for (long i = 0; i < n; i++) {
            vet[(int)i] = scanner.nextLong();
        }
        for (long i = 0; i < n; i++) {
            temp = scanner.nextLong();
            if (temp == 1)
            {
                ris += vet[(int)i];
                vet[(int)i] = 0;
            }
        }

        long finestra = 0;

        for (long i = 0; i < k; i++){
            finestra += vet[(int)i];

        }

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

            ris2 = finestra - vet[(int)i] + vet [(int)i+(int)k];

            if (ris2 > finestra)
                finestra = ris2;

        }

        ris += finestra;

        System.out.println(ris);
    }
}


import java.util.Scanner;

public class ProblemF {

    public static void main (String[] strings){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] theo = new int[n];
        boolean[] awake = new boolean[n];

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

        int total = 0;

        for (int i = 0; i < n; i++) {
            awake[i] = scanner.nextInt() != 0;
            if (awake[i]) {
                total += theo[i];
            }
        }

        int curr = 0;

        for (int i = 0; i < k; i++ ){
            if (!awake[i]){
                curr += theo[i];
            }
        }

        int max = curr;

        for (int i = 0; i < n-k; i++) {
            if (!awake[i]) {
                curr -= theo[i];
            }

            if (!awake[i+k]){
                curr += theo[i+k];
            }
            if (max < curr) {
                max = curr;
            }

        }

        System.out.println((max + total));
    }
}


import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int n,k, temp;
        int ris = 0;
        int ris2;
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextInt();
        k = scanner.nextInt();

        int[] vet = new int[n];

        for (int i = 0; i < n; i++) {
            vet[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            temp = scanner.nextInt();
            if (temp == 1)
            {
                ris += vet[i];
                vet[i] = 0;
            }
        }

        int finestra = 0;

        for (int i = 0; i < k; i++){
            finestra += vet[i];

        }

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

            ris2 = finestra - vet[i] + vet [i+k];

            if (ris2 > finestra)
                finestra = ris2;

        }

        ris += finestra;

        System.out.println(ris);
    }
}


import java.util.*;

public class MyClass {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int gap=sc.nextInt();
      int arr[]=new int[n];
      int brr[]=new int[n];
      int sum=0;
      int preSum=0;
      int zsum[]=new int[n];
      for(int i=0;i<n;i++)
      {
          arr[i]=sc.nextInt();
      }
      for(int i=0;i<n;i++)
      {
          brr[i]=sc.nextInt();
          if(brr[i]==1)
          {
              sum+=arr[i];
              if(i!=0)
              {
                  zsum[i]=zsum[i-1];
              }
              else
              {
                  zsum[i]=0;
              }
          }
          else if(i!=0)
          {
              zsum[i]=arr[i]+preSum;
              preSum=zsum[i];
          }
          else
          {
              zsum[i]=arr[i];
              preSum=zsum[i];
          }
          //System.out.print(zsum[i]+"  ");
      }
      //System.out.println();
      int gapMax=0,gapSum=0;
      for(int i=0;i<=n-gap;i++)
      {
              gapSum=zsum[Math.max(0,i+gap-1)]-zsum[Math.max(0,i-1)];
              //System.out.println(gapSum);
              gapMax=Math.max(gapMax,gapSum);
      }
      System.out.println(sum+gapMax);
    }
}


import java.util.*;

public class MyClass {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int gap=sc.nextInt();
      int arr[]=new int[n];
      int brr[]=new int[n];
      int sum=0;
      int preSum=0;
      int zsum[]=new int[n];
      for(int i=0;i<n;i++)
      {
          arr[i]=sc.nextInt();
      }
      for(int i=0;i<n;i++)
      {
          brr[i]=sc.nextInt();
          if(brr[i]==1)
          {
              if(i!=0)
              {
                  sum+=arr[i];
                  arr[i]=0;
                  zsum[i]=zsum[i-1];
              }
              else
              {
                  sum+=arr[i];
                  arr[i]=0;
                  zsum[i]=0;
              }
          }
          else
          {
              if(i!=0)
              {
                  zsum[i]=zsum[i-1]+arr[i];
              }
              else
              {
                  zsum[i]=arr[i];
              }
          }
          //System.out.print(zsum[i]+"  ");
      }
      //System.out.println();
      int gapMax=0,gapSum=0;
      for(int i=0;i<=n-gap;i++)
      {
              gapSum=zsum[i+gap-1]-(i-1>=0?zsum[i-1]:0);
              //System.out.println(gapSum);
              gapMax=Math.max(gapMax,gapSum);
      }
      System.out.println(sum+gapMax);
    }
}


import java.util.*;

public class MyClass {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int gap=sc.nextInt();
      int arr[]=new int[n];
      int brr[]=new int[n];
      int sum=0;
      int preSum=0;
      int zsum[]=new int[n];
      for(int i=0;i<n;i++)
      {
          arr[i]=sc.nextInt();
      }
      for(int i=0;i<n;i++)
      {
          brr[i]=sc.nextInt();
          if(brr[i]==1)
          {
              sum+=arr[i];
              if(i!=0)
              {
                  zsum[i]=zsum[i-1];
              }
              else
              {
                  zsum[i]=0;
              }
          }
          else if(i!=0)
          {
              zsum[i]=arr[i]+preSum;
              preSum=zsum[i];
          }
          else
          {
              zsum[i]=arr[i];
              preSum=zsum[i];
          }
          //System.out.print(zsum[i]+"  ");
      }
      //System.out.println();
      int gapMax=0,gapSum=0;
      for(int i=0;i<=n-gap;i++)
      {
          if(brr[i]==0)
          {
              gapSum=zsum[Math.max(0,i+gap-1)]-zsum[Math.max(0,i-1)];
              gapMax=Math.max(gapMax,gapSum);
          }
      }
      System.out.println(sum+gapMax);
    }
}


import java.util.*;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = 0,max1=0,temp=0;
		int n = sc.nextInt();
		long tong[]=new long [n];
		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 j=0;j<n;j++) {
			b[j]=sc.nextInt();
			if(b[j]==1) {
				max=max+a[j];
			}
			if(b[j]==0&&j<(n-k+1)) {
				for(int z=j;z<=(j+k-1);z++) {
					max1=max1+a[z];
				}
			}
			tong[j]=max+max1;
			max1=0;
			temp=Math.max(temp, tong[j]);
		}
		System.out.println(temp);
		sc.close();
	}
}


import java.util.Scanner;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = 0,max1=0,temp=0;
		int n = sc.nextInt();
		int k = sc.nextInt();
		long tong[]=new long [n];
		long a[][]=new long [2][n];
		for(int i=0;i<2;i++) {
			for(int j=0;j<n;j++) {
				a[i][j]=sc.nextInt();
				if(a[1][j]==1) {
					max=max+a[0][j];
				}
			}
		}
		for(int z=0;z<(n-k+1);z++) {
			if(a[1][z]==0) {
				for(int x=z;x<=(z+k-1);x++) {
					if(a[1][x]==0) {
						max1=max1+a[0][x];
					}
				}
				tong[z]=max+max1;
				max1=0;
				if(z==0) {
			 		temp=tong[0];
				}
				if(temp<tong[z]) {
					temp=tong[z];
				}
			}
		}
		System.out.println(temp);

	}
}


import java.util.*;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = 0,max1=0,max_res=0;
		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();
			if(b[i]==1) {
				max=max+(long)a[i];
			}
		}
		for(int i=0;i<k;i++) {
			if(b[i]==0) {
				max1+=a[i];
			}
		}
		max_res=max1;
		for(int i=k, j=0;i<n;i++,j++) {
			if(b[i]==0) {
				max1+=a[i];
			}
			if(b[j]==0) {
				max1-=a[j];
			}
			max_res=Math.max(max_res, max1);

		}
		System.out.println(max+max_res);
		sc.close();
	}
}


import java.util.Scanner;

public class Lecture_Sleep {
	public static void main(String [] args) {
		Scanner sc=new Scanner(System.in);
		int max=0;
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[][]= new int [2][n];
		for(int i=0;i<2;i++) {
			for(int j=0;j<n;j++) {
				a[i][j]=sc.nextInt();
				if(a[1][j]==1) {
					max=max+a[0][j];
				}
			}
		}
		for(int z=0;z<(n-k+1);z++) {
			if(a[1][z]==0) {
				for(int x=z;x<=(z+k-1);x++) {
					if(a[1][x]==0) {
						max=max+a[0][x];
					}
				}
				break;
			}

		}
		System.out.println(max);
	}
}


import java.util.Scanner;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = 0,max1=0,temp=0;
		int n = sc.nextInt();
		int k = sc.nextInt();
		long tong[]=new long [n-k+1];
		long a[][]=new long [2][n];
		for(int i=0;i<2;i++) {
			for(int j=0;j<n;j++) {
				a[i][j]=sc.nextInt();
				if(a[1][j]==1) {
					max=max+a[0][j];
				}
			}
		}
		for(int z=0;z<(n-k+1);z++) {
			if(a[1][z]==0) {
				for(int x=z;x<=(z+k-1);x++) {
					if(a[1][x]==0) {
						max1=max1+a[0][x];
					}
				}
				tong[z]=max+max1;
				max1=0;
				if(z==0) {
					temp=tong[0];
				}
				if(temp<tong[z]) {
					temp=tong[z];
				}
			}
		}
		System.out.println(temp);

	}
}


import java.util.*;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = 0,max1=0,temp=0;
		int n = sc.nextInt();
		long tong[]=new long [n];
		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();
			if(b[i]==1) {
				max=max+a[i];
			}
		}
		for(int i=0;i<(n-k+1);i++) {
			if(b[i]==0) {
				for(int j=i;j<=(i+k-1);j++) {
					if(b[j]==0) max1=max1+a[j];
				}
			}
			temp=Math.max(temp, max+max1);
			max1=0;
		}
		System.out.println(temp);
		sc.close();
	}
}


import java.util.Scanner;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = 0,max1=0,temp=0;
		int n = sc.nextInt();
		int k = sc.nextInt();
		long tong[]=new long [n-k+1];
		int a[][]=new int [2][n];
		for(int i=0;i<2;i++) {
			for(int j=0;j<n;j++) {
				a[i][j]=sc.nextInt();
				if(a[1][j]==1) {
					max=max+a[0][j];
				}
			}
		}
		for(int z=0;z<(n-k+1);z++) {
			if(a[1][z]==0) {
				for(int x=z;x<=(z+k-1);x++) {
					if(a[1][x]==0) {
						max1=max1+a[0][x];
					}
				}
				tong[z]=max+max1;
				max1=0;
				if(z==0) {
					temp=tong[0];
				}
				if(temp<tong[z]) {
					temp=tong[z];
				}
			}
		}
		System.out.println(temp);

	}
}


import java.util.Scanner;

public class Lecture_Sleep {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = 0,max1=0,temp=0;
		int n = sc.nextInt();
		int k = sc.nextInt();
		int tong[]=new int [n-k+1];
		int a[][]=new int [2][n];
		for(int i=0;i<2;i++) {
			for(int j=0;j<n;j++) {
				a[i][j]=sc.nextInt();
				if(a[1][j]==1) {
					max=max+a[0][j];
				}
			}
		}
		for(int z=0;z<(n-k+1);z++) {
			if(a[1][z]==0) {
				for(int x=z;x<=(z+k-1);x++) {
					if(a[1][x]==0) {
						max1=max1+a[0][x];
					}
				}
				tong[z]=max+max1;
				max1=0;
				if(z==0) {
					temp=tong[0];
				}
				if(temp<tong[z]) {
					temp=tong[z];
				}
			}
		}
		System.out.println(temp);

	}
}


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

public class Main {
	public static void main (String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String st[] = br.readLine().split(" ");
    int n=Integer.parseInt(st[0]);
    int k=Integer.parseInt(st[1]);
    st=br.readLine().split(" ");
    int input[]=new int[n];
    for(int i=0;i<n;i++){
        input[i]=Integer.parseInt(st[i]);
    }
    st=br.readLine().split(" ");
    int awake[]=new int[n];
    for(int i=0;i<n;i++){
        awake[i]=Integer.parseInt(st[i]);
    }

    int ans=0;

    for(int i=0;i<n;i++){
        if(awake[i]==1){
            ans+=input[i];
        }
    }
    int profit=0;

    for(int i=n-1;i>=n-k;i--){
        if(awake[i]==0){
            profit+=input[i];
        }
    }
    int left=n-k;
    int right=n-1;
    int maxProfit=profit;
    while(left!=0){
        left--;
        if(awake[left]==0)
        profit+=input[left]-input[right];
        else
        profit+=-input[right];

        if(profit<0)
        profit=0;

        right--;
        maxProfit=Math.max(maxProfit,profit);
    }
    System.out.println(ans+maxProfit);

    }
}


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

public class Main {
	public static void main (String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String st[] = br.readLine().split(" ");
    int n=Integer.parseInt(st[0]);
    int k=Integer.parseInt(st[1]);
    st=br.readLine().split(" ");
    int input[]=new int[n];
    for(int i=0;i<n;i++){
        input[i]=Integer.parseInt(st[i]);
    }
    st=br.readLine().split(" ");
    int awake[]=new int[n];
    for(int i=0;i<n;i++){
        awake[i]=Integer.parseInt(st[i]);
    }

    int ans=0;

    for(int i=0;i<n;i++){
        if(awake[i]==1){
            ans+=input[i];
        }
    }
    int profit=0;

    for(int i=n-1;i>=n-k;i--){
        if(awake[i]==0){
            profit+=input[i];
        }
    }
    int left=n-k;
    int right=n-1;
    int maxProfit=profit;
    while(left!=0){
        left--;
        if(awake[left]==0)
        profit+=input[left]-input[right];
        else
        profit+=-input[right];

        right--;
        maxProfit=Math.max(maxProfit,profit);
    }
    System.out.println(ans+maxProfit);

    }
}


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

public class Main {
	public static void main (String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String st[] = br.readLine().split(" ");
    int n=Integer.parseInt(st[0]);
    int k=Integer.parseInt(st[1]);
    st=br.readLine().split(" ");
    int input[]=new int[n];
    for(int i=0;i<n;i++){
        input[i]=Integer.parseInt(st[i]);
    }
    st=br.readLine().split(" ");
    int awake[]=new int[n];
    for(int i=0;i<n;i++){
        awake[i]=Integer.parseInt(st[i]);
    }

    int ans=0;

    for(int i=0;i<n;i++){
        if(awake[i]==1){
            ans+=input[i];
        }
    }
    int profit=0;

    for(int i=n-1;i>=n-k;i--){
        if(awake[i]==0){
            profit+=input[i];
        }
    }
    int left=n-k;
    int right=n-1;
    int maxProfit=profit;
    while(left!=0){
        left--;
        if(awake[left]==0)
        profit+=input[left];

        if(awake[right]==0)
        profit+=-input[right];

        right--;
        maxProfit=Math.max(maxProfit,profit);
    }
    System.out.println(ans+maxProfit);

    }
}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];

		for (int i = 0; i < N; i++)
			lec[i] = scanner.nextInt();
		for (int i = 0; i < N; i++)
			sleep[i] = scanner.nextInt();

		long MAX = 0;
		long max = 0;

		for (int i = 0; i < N; i++) {
			max = 0;
			int ptr = i;
			while (true) {
				if (ptr < N && (sleep[ptr] == 1 || ptr <= (i + k))) {
					max += lec[ptr];
					ptr++;
				} else
					break;
			}
			if (max > MAX)
				MAX = max;
		}

		System.out.println(MAX);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];
		int SUM = 0;

		for (int i = 0; i < N; i++) {
			lec[i] = scanner.nextInt();
		}
		for (int i = 0; i < N; i++) {
			sleep[i] = scanner.nextInt();
			if (sleep[i] == 1)
				SUM += lec[i];
		}

		long MAX = 0;
		long max = 0;

		int i = 0;
		while (i < N) {
			max = 0;
			int ptr = i;
			while (ptr < N && (ptr < (i+k))) {
				if (sleep[ptr] == 0) {
					max += lec[ptr];
				}
				ptr++;
			}
			if (max > MAX)
				MAX = max;
			i++;
			while (i < N && sleep[i] == 1)
				i++;
		}

		System.out.println(MAX+SUM);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];

		for (int i = 0; i < N; i++)
			lec[i] = scanner.nextInt();
		for (int i = 0; i < N; i++)
			sleep[i] = scanner.nextInt();

		long MAX = 0;
		long max = 0;

		for (int i = 0; i < N; i++) {
			max = 0;
			int ptr = i;
			while (ptr < N) {
				if (sleep[ptr] == 1 || ptr <= (i + k)) {
					max += lec[ptr];
				}
				ptr++;
			}
			if (max > MAX)
				MAX = max;
		}

		System.out.println(MAX);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];

		for (int i = 0; i < N; i++)
			lec[i] = scanner.nextInt();
		for (int i = 0; i < N; i++)
			sleep[i] = scanner.nextInt();

		long MAX = 0;
		long max = 0;

		int i = 0;
		while (i < N) {
			max = 0;
			int ptr = 0;
			while (ptr < N) {
				if (sleep[ptr] == 1 || (ptr >=i && ptr < (i + k))) {
					max += lec[ptr];
				}
				ptr++;
			}
			if (max > MAX)
				MAX = max;
			i++;
			while (i < N && sleep[i] == 1)
				i++;
		}

		System.out.println(MAX);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];

		for (int i = 0; i < N; i++)
			lec[i] = scanner.nextInt();
		for (int i = 0; i < N; i++)
			sleep[i] = scanner.nextInt();

		int MAX = 0;
		int max = 0;

		for (int i = 0; i < N; i++) {
			max = 0;
			int ptr = i;
			while (true) {
				if (ptr < N && (sleep[ptr] == 1 || ptr <= (i + k))) {
					max += lec[ptr];
					ptr++;
				} else
					break;
			}
			if (max > MAX)
				MAX = max;
		}

		System.out.println(MAX);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];

		for (int i = 0; i < N; i++)
			lec[i] = scanner.nextInt();
		for (int i = 0; i < N; i++)
			sleep[i] = scanner.nextInt();

		long MAX = 0;
		long max = 0;

		for (int i = 0; i < N; i++) {
			max = 0;
			int ptr = 0;
			while (ptr < N) {
				if (sleep[ptr] == 1 || (ptr >=i && ptr < (i + k))) {
					max += lec[ptr];
				}
				ptr++;
			}
			if (max > MAX)
				MAX = max;
		}

		System.out.println(MAX);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];
		int SUM = 0;

		for (int i = 0; i < N; i++) {
			lec[i] = scanner.nextInt();
		}
		for (int i = 0; i < N; i++) {
			sleep[i] = scanner.nextInt();
			if (sleep[i] == 1)
				SUM += lec[i];
		}

		long MAX = 0;
		long max = 0;

		int head = 0;
		int tail = head+k-1;
		for (int i=head; i<=tail; i++) {
			if (sleep[i] == 0)
				max += lec[i];
		}
		MAX = max;

		while (tail < N) {
			if (sleep[head] == 0)
				max -= lec[head];
			head++;
			tail++;
			if (tail < N && sleep[tail] == 0)
				max += lec[tail];
			MAX = Math.max(MAX, max);
		}

		System.out.println(MAX+SUM);
		scanner.close();

	}

}


import java.util.Scanner;

public class CF2 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int k = scanner.nextInt();

		int lec[] = new int[N];
		int sleep[] = new int[N];
		int SUM = 0;

		for (int i = 0; i < N; i++) {
			lec[i] = scanner.nextInt();
		}
		for (int i = 0; i < N; i++) {
			sleep[i] = scanner.nextInt();
			if (sleep[i] == 1)
				SUM += lec[i];
		}

		long MAX = 0;
		long max = 0;

		int head = 0;
		int tail = head+k-1;
		for (int i=head; i<=tail; i++) {
			if (sleep[i] == 0)
				max += lec[i];
		}
		MAX = max;

		while (tail < N) {
			if (sleep[head] == 0)
				max -= lec[head];
			head++;
			tail++;
			if (tail < N && sleep[tail] == 0)
				max += lec[head];
			MAX = Math.max(MAX, max);
		}

		System.out.println(MAX+SUM);
		scanner.close();

	}

}


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

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	  BufferedReader reader =
                   new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(reader.readLine());
    int a=Integer.parseInt(st.nextToken());
    int k=Integer.parseInt(st.nextToken());
    st=new StringTokenizer(reader.readLine());
    int i=0;
    int l[]=new int[a];
    int s[]=new int[a];
    while(st.hasMoreTokens()){
        l[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
      st=new StringTokenizer(reader.readLine());
    while(st.hasMoreTokens()){
        s[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
    int max=0;
    int dp[]=new int[a];
    for (int p=0,j=k-1;j<a;p++,j++) {
        int newMax=0;
        if(s[p]!=0){
            if(p>0)
            dp[p]=(l[p]+dp[p-1]);
            else
            dp[p]+=l[p];
        }else{
            if(p>0)
            dp[p]=dp[p-1];
        }
        for (int m=p;m<=j;m++){
            newMax+=l[m];
        }
        if(p>0)
            newMax+=dp[p-1];
        if(newMax>max)
            max=newMax;
        else
        {
         if(s[j]!=0)
          max+=l[j];
        }

    }
  System.out.println(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 Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	  BufferedReader reader =
                   new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(reader.readLine());
    int a=Integer.parseInt(st.nextToken());
    int k=Integer.parseInt(st.nextToken());
    st=new StringTokenizer(reader.readLine());
    int i=0;
    int l[]=new int[a];
    int s[]=new int[a];
    while(st.hasMoreTokens()){
        l[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
      st=new StringTokenizer(reader.readLine());
    while(st.hasMoreTokens()){
        s[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
    int max=0;
    int dp[]=new int[a];
    for (int p=0;p<a;p++) {
        if(p>0)
        dp[p]+=dp[p-1];
       if(s[p]!=0){
           max+=l[p];

       }else{
           dp[p]+=l[p];
       }
    }
    int newMax=0;
             for (i=k-1;i<a;i++) {
              newMax = Math.max(newMax, dp[i] - (i >= k ? dp[i - k] : 0));
        	}
        	newMax+=max;
        	System.out.println(newMax);
}

}


/* 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 Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	  BufferedReader reader =
                   new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(reader.readLine());
    int a=Integer.parseInt(st.nextToken());
    int k=Integer.parseInt(st.nextToken());
    st=new StringTokenizer(reader.readLine());
    int i=0;
    int l[]=new int[a];
    int s[]=new int[a];
    while(st.hasMoreTokens()){
        l[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
      st=new StringTokenizer(reader.readLine());
    while(st.hasMoreTokens()){
        s[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
    int max=0;
    int dp[]=new int[a];
    for (int p=0;p<a;p++) {
       if(s[p]!=0){
           max+=l[p];
           l[p]=0;
       }
    }
    int newMax=0;
        for (int p=0,j=k-1;j<a;p++,j++) {

              if(p==0){
                 for (int m=p;m<=j;m++ ) {
                 newMax+=l[m];
                 }
                  }
         else{
             int checkMax=newMax;
              if(l[p-1]!=0)
              checkMax-=l[p-1];
              if(l[j]!=0)
             checkMax+=l[j];

             newMax=Math.max(newMax,checkMax);
             }

        }
        newMax+=max;
        System.out.println(newMax);
		// your code goes here
	}
}


/* 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 Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	  BufferedReader reader =
                   new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(reader.readLine());
    int a=Integer.parseInt(st.nextToken());
    int k=Integer.parseInt(st.nextToken());
    st=new StringTokenizer(reader.readLine());
    int i=0;
    int l[]=new int[a];
    int s[]=new int[a];
    while(st.hasMoreTokens()){
        l[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
      st=new StringTokenizer(reader.readLine());
    while(st.hasMoreTokens()){
        s[i]=Integer.parseInt(st.nextToken());
        i++;
    }
    i=0;
    int max=0;
    int dp[]=new int[a];
    for (int p=0;p<a;p++) {
       if(s[p]!=0){
           max+=l[p];
           l[p]=0;
       }
    }
    int newMax=0;
        for (int p=0,j=k-1;j<a;p++,j++) {

              if(p==0){
                 for (int m=p;m<=j;m++ ) {
                 newMax+=l[m];
                 }
                  }
         else{
             int checkMax=newMax;
              if(l[p-1]!=0)
              checkMax=Math.abs(checkMax-l[p-1]);
              if(l[j]!=0)
             checkMax+=l[j];
             newMax=Math.max(newMax,checkMax);
             }

        }
        newMax+=max;
        System.out.println(newMax);
		// your code goes here
	}
}


// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = sc.readArray(n);
		int t[] = sc.readArray(n);

		int prea[] = new int[n];
		prea[0] = a[0];
		int pret[] = new int[n];
		pret[0] = t[0]==0?0:a[0];
		for (int i = 1; i < n; i++) {
			prea[i] = prea[i - 1] + a[i];
			if (t[i] == 1) {
				pret[i] = pret[i - 1] + a[i];
			} else {
				pret[i] = pret[i - 1];
			}
		}

		int ans=Integer.MIN_VALUE;
		for(int i=k-1;i<n;i++) {

			int res=(i-k>0? pret[i-k]:0)+(prea[i]-prea[Math.max(0, i-k)])+pret[n-1]-pret[i];

			ans=Math.max(res, ans);
		}
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = sc.readArray(n);
		int t[] = sc.readArray(n);

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

		int prea[] = new int[n];
		prea[0] = a[0];

		for (int i = 1; i < n; i++) {
			prea[i] = prea[i - 1] + a[i];

		}

		int max=Integer.MIN_VALUE;
		for(int i=k-1;i<n;i++) {
			int temp=prea[i]-(i-k>=0? prea[i-k]:0);
			max=Math.max(temp, max);
		}
		System.out.println(ans+max);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = sc.readArray(n);
		int t[] = sc.readArray(n);

		int prea[] = new int[n];
		prea[0] = a[0];
		int pret[] = new int[n];
		pret[0] = t[0]==0?0:a[0];
		for (int i = 1; i < n; i++) {
			prea[i] = prea[i - 1] + a[i];
			if (t[i] == 1) {
				pret[i] = pret[i - 1] + a[i];
			} else {
				pret[i] = pret[i - 1];
			}
		}

		long ans=Long.MIN_VALUE;
		for(int i=k-1;i<n;i++) {

			long res=(i-k>0? pret[i-k]:0)+(prea[i]-prea[Math.max(0, i-k)])+pret[n-1]-pret[i];

			ans=Math.max(res, ans);
		}
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = sc.readArray(n);
		int t[] = sc.readArray(n);

		int prea[] = new int[n];
		prea[0] = a[0];
		int pret[] = new int[n];
		pret[0] = t[0]==0?0:a[0];
		for (int i = 1; i < n; i++) {
			prea[i] = prea[i - 1] + a[i];
			if (t[i] == 1) {
				pret[i] = pret[i - 1] + a[i];
			} else {
				pret[i] = pret[i - 1];
			}
		}

		long ans=Long.MIN_VALUE;
		for(int i=k-1;i<n;i++) {

			long res=(i-k>0? pret[i-k]:0)+(prea[i]-(i-k>0?prea[i-k-1]:0))+pret[n-1]-pret[i];

			ans=Math.max(res, ans);
		}
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = sc.readArray(n);
		int t[] = sc.readArray(n);

		int prea[] = new int[n];
		prea[0] = a[0];
		int pret[] = new int[n];
		pret[0] = a[0];
		for (int i = 1; i < n; i++) {
			prea[i] = prea[i - 1] + a[i];
			if (t[i] == 1) {
				pret[i] = pret[i - 1] + a[i];
			} else {
				pret[i] = pret[i - 1];
			}
		}

		int ans=Integer.MIN_VALUE;
		for(int i=k-1;i<n;i++) {

			int res=(i-k>0? pret[i-k]:0)+(prea[i]-prea[Math.max(0, i-k)])+pret[n-1]-pret[i];

			ans=Math.max(res, ans);
		}
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = sc.readArray(n);
		int t[] = sc.readArray(n);

		int prea[] = new int[n];
		prea[0] = a[0];
		int pret[] = new int[n];
		pret[0] = t[0]==0?0:a[0];
		for (int i = 1; i < n; i++) {
			prea[i] = prea[i - 1] + a[i];
			if (t[i] == 1) {
				pret[i] = pret[i - 1] + a[i];
			} else {
				pret[i] = pret[i - 1];
			}
		}

		long ans=Long.MIN_VALUE;
		for(int i=k-1;i<n;i++) {

			long res=(i-k>0? pret[i-k]:0)+(prea[i]-(i-k>0?prea[i-k]:0))+pret[n-1]-pret[i];

			ans=Math.max(res, ans);
		}
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


import java.io.*;

/**
 * Created by nikitos on 23.08.17.
 */

public class otrezok {

    public StreamTokenizer t;

    public int nextInt() throws IOException {
        t.nextToken();
        return (int) t.nval;
    }

    public String nextString() throws IOException {
        t.nextToken();
        return t.sval;
    }

    public void start() throws IOException {
        t = new StreamTokenizer( new BufferedReader(new InputStreamReader(System.in)));

        int n = nextInt();
        int k = nextInt();
        int[] teor = new int[n];
        int[] sleep = new int[n];

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

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

        int[] prefsum = new int[n + 1];
        prefsum[0] = 0;
        for (int i = 0; i < n; i++) {
            prefsum[i + 1] = prefsum[i];
            if (sleep[i] == 0) {
                prefsum[i + 1] += teor[i];
            }
        }

//        for (int i = 0; i < n + 1; i++) {
//            System.out.print(prefsum[i] + " ");
//        }
//        System.out.println();

        int max = 0;
        for (int i = k; i < n + 1; i++) {
//            if (sleep[i] == 0) {
                max = max < (prefsum[i] - prefsum[i - k])? prefsum[i] - prefsum[i - k]: max;
//                System.out.println(i + " " + (i - k));
//            }
        }

        for (int i = 0; i < n; i++) {
            if (sleep[i] != 0) {
                max += teor[i];
            }
        }

        System.out.println(max);
    }

    public static void main(String[] args) throws IOException {
        new otrezok().start();
    }

}


// package All_in_all;

import java.io.*;

/**
 * Created by nikitos on 23.08.17.
 */

public class otrezok {

    public StreamTokenizer t;

    public int nextInt() throws IOException {
        t.nextToken();
        return (int) t.nval;
    }

    public String nextString() throws IOException {
        t.nextToken();
        return t.sval;
    }

    public void start() throws IOException {
        t = new StreamTokenizer( new BufferedReader(new InputStreamReader(System.in)));

        int n = nextInt();
        int k = nextInt();
        int[] teor = new int[n];
        int[] sleep = new int[n];

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

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

        int[] prefsum = new int[n + 1];
        prefsum[0] = 0;
        for (int i = 0; i < n; i++) {
            prefsum[i + 1] = prefsum[i];
            if (sleep[i] == 0) {
                prefsum[i + 1] += teor[i];
            }
        }

//        for (int i = 0; i < n + 1; i++) {
//            System.out.print(prefsum[i] + " ");
//        }
//        System.out.println();

        int max = 0;
        for (int i = k; i < n; i++) {
            if (sleep[i] == 0) {
                max = max < (prefsum[i] - prefsum[i - k - 1])? prefsum[i] - prefsum[i - k - 1]: max;
            }
        }

        for (int i = 0; i < n; i++) {
            if (sleep[i] != 0) {
                max += teor[i];
            }
        }

        System.out.println(max);
    }

    public static void main(String[] args) throws IOException {
        new otrezok().start();
    }

}


// package All_in_all;

import java.io.*;

/**
 * Created by nikitos on 23.08.17.
 */

public class otrezok {

    public StreamTokenizer t;

    public int nextInt() throws IOException {
        t.nextToken();
        return (int) t.nval;
    }

    public String nextString() throws IOException {
        t.nextToken();
        return t.sval;
    }

    public void start() throws IOException {
        t = new StreamTokenizer( new BufferedReader(new InputStreamReader(System.in)));

        int n = nextInt();
        int k = nextInt();
        int[] teor = new int[n];
        int[] sleep = new int[n];

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

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

        int[] prefsum = new int[n];
        prefsum[0] = sleep[0] == 0? teor[0]: 0;
        for (int i = 1; i < n; i++) {
            prefsum[i] = prefsum[i - 1];
            if (sleep[i] == 0) {
                prefsum[i] += teor[i];
            }
        }

//        for (int i = 0; i < n; i++) {
//            System.out.print(prefsum[i] + " ");
//        }

        int max = 0;
        for (int i = k; i < n; i++) {
            if (sleep[i] == 0) {
                max = max < (prefsum[i] - prefsum[i - k])? prefsum[i] - prefsum[i - k]: max;
            }
        }

        for (int i = 0; i < n; i++) {
            if (sleep[i] != 0) {
                max += teor[i];
            }
        }

        System.out.println(max);
    }

    public static void main(String[] args) throws IOException {
        new otrezok().start();
    }

}


import java.util.*;

public class CHEGLOVE
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int arr[] = new int[n];
		int flag[] = new int[n];
		int sum[] = new int[n-k+1];
		int i,j,ans=0,add=0,big=0;
		for(i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		for(i=0;i<n;i++)
		{
			flag[i]=sc.nextInt();
		}
		for(i=0;i<n;i++)
		{
			if(flag[i]==1)
			{ans += arr[i];
			arr[i]=0;
			}
		}
		for(i=0;i<n;i++)
		{
			add += arr[i];
			if(i==k-1)
				big=add;
			else if(i>k-1)
			{
				add-= arr[i-k];
				big = Math.max(big,add);
			}
		}
		ans += big;
		System.out.println(ans);
	}
}


import java.util.*;

public class CHEGLOVE
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int arr[] = new int[n];
		int flag[] = new int[n];
		int sum[] = new int[n-k+1];
		int i,j,ans=0,max=-999999;
		for(i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		for(i=0;i<n;i++)
		{
			flag[i]=sc.nextInt();
		}
		for(i=0;i<n-k+1;i++)
		{
			if(flag[i]==0)
			{
				for(j=i;j<i+k;j++)
				{
					if(flag[j]==0)
						sum[i] += arr[j];
				}
			}
		}

		/*for(i=0;i<n-k+1;i++)
		{
			System.out.print(sum[i]+" ");
		}*/

		for(i=0;i<n;i++)
		{
			if(flag[i]==1)
				ans += arr[i];
		}
		for(i=0;i<n-k+1;i++)
		{
			if(max<sum[i])
				max=sum[i];
		}
		ans += max;
		System.out.println(ans);
	}
}


import java.util.*;

public class CHEGLOVE
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int arr[] = new int[n];
		int flag[] = new int[n];
		int sum[] = new int[n-k+1];
		int i,j,ans=0,max=-999999;
		for(i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		for(i=0;i<n;i++)
		{
			flag[i]=sc.nextInt();
		}
		for(i=0;i<n-k+1;i++)
		{
			for(j=i;j<i+k;j++)
			{
				if(flag[j]==0)
					sum[i] += arr[j];
			}
		}

		/*for(i=0;i<n-k+1;i++)
		{
			System.out.print(sum[i]+" ");
		}*/

		for(i=0;i<n;i++)
		{
			if(flag[i]==1)
				ans += arr[i];
		}
		for(i=0;i<n-k+1;i++)
		{
			if(max<sum[i])
				max=sum[i];
		}
		ans += max;
		System.out.println(ans);
	}
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();
		int k = console.nextInt();
		int[] mins = new int[n];
		int[] state = new int[n];
		for (int i = 0; i < n; i++) {
			mins[i] = console.nextInt();
		}
		for (int i = 0; i < n; i++) {
			state[i] = console.nextInt();
		}
		long res = 0;
		for (int i = 0; i < n; i++) {
			if (state[i] == 1) {
				res += mins[i];
				mins[i] = 0;
			}
		}
		int[] prefixsum = new int[n];
		prefixsum[0] = mins[0];
		for (int i = 1; i<n; i++) {
			prefixsum[i] = prefixsum[i-1]+mins[i];
		}
		if (n == k) {
			System.out.println(res+prefixsum[n-1]);
			return;
		}
		long maxtemp = prefixsum[0];
		for (int i = 0; i < n - k ; i++) {
			long temp = prefixsum[i+k]-prefixsum[i];
			maxtemp = Math.max(temp, maxtemp);
		}
		System.out.println(res + maxtemp);
	}
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();
		int k = console.nextInt();
		int[] mins = new int[n];
		int[] state = new int[n];
		for (int i = 0; i < n; i++) {
			mins[i] = console.nextInt();
		}
		for (int i = 0; i < n; i++) {
			state[i] = console.nextInt();
		}
		long res = 0;
		for (int i = 0; i < n; i++) {
			if (state[i] == 1) {
				res += mins[i];
				mins[i] = 0;
			}
		}
		int[] prefixsum = new int[n];
		prefixsum[0] = mins[0];
		for (int i = 1; i<n; i++) {
			prefixsum[i] = prefixsum[i-1]+mins[i];
		}
		if (n == k) {
			System.out.println(res+prefixsum[n-1]);
			return;
		}
		long maxtemp = Long.MIN_VALUE;
		for (int i = 0; i < n - k ; i++) {
			long temp = prefixsum[i+k]-prefixsum[i];
			maxtemp = Math.max(temp, maxtemp);
		}
		System.out.println(res + maxtemp);
	}
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();
		int k = console.nextInt();
		int[] mins = new int[n];
		int[] state = new int[n];
		for (int i = 0; i < n; i++) {
			mins[i] = console.nextInt();
		}
		for (int i = 0; i < n; i++) {
			state[i] = console.nextInt();
		}
		long res = 0;
		for (int i = 0; i < n; i++) {
			if (state[i] == 1) {
				res += mins[i];
				mins[i] = 0;
			}
		}
		int[] prefixsum = new int[n];
		prefixsum[0] = mins[0];
		for (int i = 1; i<n; i++) {
			prefixsum[i] = prefixsum[i-1]+mins[i];
		}
		if (n == k) {
			System.out.println(res+prefixsum[n-1]);
			return;
		}
		long maxtemp = prefixsum[k - 1];
		for (int i = 0; i < n - k ; i++) {
			long temp = prefixsum[i+k]-prefixsum[i];
			//System.out.println(temp);
			maxtemp = Math.max(temp, maxtemp);
		}
		System.out.println(res + maxtemp);
	}
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();
		int k = console.nextInt();
		int[] mins = new int[n];
		int[] state = new int[n];
		for (int i = 0; i<n; i++) {
			mins[i] = console.nextInt();
		}
		for (int i = 0; i<n; i++) {
			state[i] = console.nextInt();
		}
		long res = 0;
		for (int i = 0; i<n; i++) {
			if (state[i] == 1)
				res+=mins[i];
		}
		long maxtemp = 0;
		for (int i = 0; i<n-k+1; i++) {
			long temp = 0;
			for (int j = i; j<i+k; j++) {
				if (state[j] == 0) {
					temp+=mins[j];
				}
			}
			maxtemp = Math.max(temp, maxtemp);
		}
		System.out.println(res+maxtemp);
	}
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();
		int k = console.nextInt();
		int[] mins = new int[n];
		int[] state = new int[n];
		for (int i = 0; i < n; i++) {
			mins[i] = console.nextInt();
		}
		for (int i = 0; i < n; i++) {
			state[i] = console.nextInt();
		}
		long res = 0;
		for (int i = 0; i < n; i++) {
			if (state[i] == 1) {
				res += mins[i];
				mins[i] = 0;
			}
		}
		int[] prefixsum = new int[n];
		prefixsum[0] = mins[0];
		for (int i = 1; i<n; i++) {
			prefixsum[i] = prefixsum[i-1]+mins[i];
		}
		long maxtemp = 0;
		for (int i = 0; i < n - k; i++) {
			long temp = prefixsum[i+k]-prefixsum[i];
			maxtemp = Math.max(temp, maxtemp);
		}
		System.out.println(res + maxtemp);
	}
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();
		int k = console.nextInt();
		int[] mins = new int[n];
		int[] state = new int[n];
		for (int i = 0; i < n; i++) {
			mins[i] = console.nextInt();
		}
		for (int i = 0; i < n; i++) {
			state[i] = console.nextInt();
		}
		long res = 0;
		for (int i = 0; i < n; i++) {
			if (state[i] == 1) {
				res += mins[i];
				mins[i] = 0;
			}
		}
		int[] prefixsum = new int[n];
		prefixsum[0] = mins[0];
		for (int i = 1; i<n; i++) {
			prefixsum[i] = prefixsum[i-1]+mins[i];
		}
		if (n == k) {
			System.out.println(res+prefixsum[n-1]);
			return;
		}
		long maxtemp = Long.MIN_VALUE;
		for (int i = 0; i < n - k ; i++) {
			long temp = prefixsum[i+k]-prefixsum[i];
			System.out.println("Prefix sum from "+i+" to "+(i+k)+" is: "+temp);
			maxtemp = Math.max(temp, maxtemp);
		}
		System.out.println(res + maxtemp);
	}
}