//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! min {
	($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};
}
#[allow(unused_macros)] macro_rules! max {
	($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! v {
	([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};
	([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(n,k = rin.u());
	l!(a,d = rin.vl(n));
	let mut sol = (a[n-1] - d[n-1]).max(0);
	if k == 0 {
		let mut sum = 0;
		for i in (0..n).rev() {
			sum += a[i];
			max!(sol, sum - d[i]);
		}
	} else if k % 2 == 0 {
		let sum = a.iter().sum::<i64>();
		let min = *d[0..n-1].iter().min().unwrap();
		max!(sol, sum - min);
	} else {
		let sum1 = a[0..n-1].iter().sum::<i64>();
		let min1 = *d[0..n-1].iter().min().unwrap();
		max!(sol, sum1 - min1 + (a[n-1] - d[n-1]).max(0));
		let sum2 = a[1..n].iter().sum::<i64>();
		max!(sol, sum2 - d[1]);
	}
	writeln!(rout, "{}", sol).ok();
}


//---------- begin SegmentTree Point update Range query ----------
pub trait PURQ {
    type T: Clone;
    fn fold(l: &Self::T, r: &Self::T) -> Self::T;
    fn fold_option(l: &Option<Self::T>, r: &Option<Self::T>) -> Option<Self::T> {
        match (l.as_ref(), r.as_ref()) {
            (Some(l), Some(r)) => Some(Self::fold(l, r)),
            (Some(l), None) => Some(l.clone()),
            (None, Some(r)) => Some(r.clone()),
            _ => None,
        }
    }
}

struct SegmentTreePURQ<R: PURQ> {
    seg: Vec<Option<R::T>>,
    size: usize,
}

#[allow(dead_code)]
impl<R: PURQ> SegmentTreePURQ<R> {
    fn new(n: usize) -> SegmentTreePURQ<R> {
        let size = n.next_power_of_two();
        SegmentTreePURQ {
            seg: (0..(2 * size)).map(|_| None).collect(),
            size: size,
        }
    }
    fn update(&mut self, x: usize, v: Option<R::T>) {
        let mut x = x + self.size;
        let a = &mut self.seg;
        a[x] = v;
        x >>= 1;
        while x > 0 {
            a[x] = R::fold_option(&a[2 * x], &a[2 * x + 1]);
            x >>= 1;
        }
    }
    fn update_tmp(&mut self, x: usize, v: Option<R::T>) {
        self.seg[self.size + x] = v;
    }
    fn update_all(&mut self) {
        let a = &mut self.seg;
        for i in (1..self.size).rev() {
            a[i] = R::fold_option(&a[2 * i], &a[2 * i + 1]);
        }
    }
    fn find(&self, l: usize, r: usize) -> Option<R::T> {
        let mut x = None;
        let mut y = None;
        let mut l = l + self.size;
        let mut r = r + self.size;
        let a = &self.seg;
        while l < r {
            if l & 1 == 1 {
                x = R::fold_option(&x, &a[l]);
                l += 1;
            }
            if r & 1 == 1 {
                r -= 1;
                y = R::fold_option(&a[r], &y);
            }
            l >>= 1;
            r >>= 1;
        }
        R::fold_option(&x, &y)
    }
}
//---------- end SegmentTree Point update Range query ----------
// ---------- begin Matrix ----------
#[allow(dead_code)]
mod matrix {
    use std::ops::{Add, Mul};
    pub trait SemiRing: Add<Output = Self> + Mul<Output = Self> + Copy {
        fn zero() -> Self;
        fn one() -> Self;
    }
    pub const SIZE: usize = 2;
    #[derive(Clone)]
    pub struct SquareMatrix<T: SemiRing> {
        buf: [[T; SIZE]; SIZE],
    }
    impl<T: SemiRing> SquareMatrix<T> {
        pub fn zero() -> Self {
            let z = T::zero();
            SquareMatrix {
                buf: [[z; SIZE]; SIZE],
            }
        }
        pub fn identity() -> Self {
            let mut m = Self::zero();
            for i in 0..SIZE {
                m.buf[i][i] = T::one();
            }
            m
        }
        pub fn set_at(&mut self, i: usize, j: usize, v: T) {
            self.buf[i][j] = v;
        }
        pub fn get_at(&self, i: usize, j: usize) -> T {
            self.buf[i][j]
        }
        pub fn matmul(&self, rhs: &Self) -> Self {
            let mut res = Self::zero();
            for (x, a) in res.buf.iter_mut().zip(self.buf.iter()) {
                for (a, b) in a.iter().zip(rhs.buf.iter()) {
                    for (x, b) in x.iter_mut().zip(b.iter()) {
                        *x = *x + *a * *b;
                    }
                }
            }
            res
        }
        pub fn matadd(&self, rhs: &Self) -> Self {
            let mut c = Self::zero();
            for (c, (a, b)) in c.buf.iter_mut().zip(self.buf.iter().zip(rhs.buf.iter())) {
                for (c, (a, b)) in c.iter_mut().zip(a.iter().zip(b.iter())) {
                    *c = *a + *b;
                }
            }
            c
        }
        pub fn matpow(&self, mut n: usize) -> Self {
            let mut t = Self::identity();
            let mut s = self.clone();
            while n > 0 {
                if n & 1 == 1 {
                    t = t.matmul(&s);
                }
                s = s.matmul(&s);
                n >>= 1;
            }
            t
        }
    }
}
// ---------- end Matrix ----------
// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use matrix::*;
use std::ops::*;

#[derive(Clone, Copy)]
struct R(i64);
impl Add for R {
    type Output = Self;
    fn add(self, rhs: Self) -> Self::Output {
        R(std::cmp::max(self.0, rhs.0))
    }
}

impl Mul for R {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self::Output {
        R(std::cmp::max(std::i64::MIN / 10, self.0 + rhs.0))
    }
}

impl SemiRing for R {
    fn one() -> Self {
        R(0)
    }
    fn zero() -> Self {
        R(std::i64::MIN / 10)
    }
}

type M = SquareMatrix<R>;

struct DP;
impl PURQ for DP {
    type T = M;
    fn fold(l: &Self::T, r: &Self::T) -> Self::T {
        l.matmul(r)
    }
}

fn run() {
    input! {
        n: usize,
        k: usize,
        a: [i64; n],
        d: [i64; n],
    }
    let mut ans = 0;
    if k == 0 {
        let mut sum = 0;
        for (a, d) in a.iter().zip(d.iter()).rev() {
            sum += *a;
            ans.chmax(sum - *d);
        }
    } else if k == 1 {
        // 1回で何ができる？
        // ループ + パス
        // 1点+１つ飛ばしのパス
        // ループ+パスは累積和等で処理できる
        // 1点+パスはどうする？
        // セグ木の気合?
        {
            let mut sum = a[0];
            let mut min = d[0];
            let mut val = vec![];
            for (a, d) in a.iter().zip(d.iter()).take(n - 1).skip(1) {
                sum += *a;
                min.chmin(*d);
                val.push(sum - min);
            }
            let mut sum = 0;
            let mut max = 0;
            for i in (2..n).rev() {
                sum += a[i];
                max.chmax(sum - d[i]);
                ans.chmax(val[i - 2] + max);
            }
        }
        {
            let mut mat = vec![M::identity(); n];
            for i in 0..n {
                mat[i].set_at(0, 0, R(a[i]));
                mat[i].set_at(1, 0, R(a[i] - d[i]));
            }
            let mut seg = SegmentTreePURQ::<DP>::new(n);
            for i in 0..n {
                seg.update_tmp(i, Some(mat[i].clone()));
            }
            seg.update_all();
            let m = seg.find(1, n).unwrap();
            ans.chmax((m.get_at(1, 0) + m.get_at(1, 1)).0);
            for i in 0..(n - 2) {
                seg.update(i + 1, None);
                let m = seg.find(0, n).unwrap();
                let v = (m.get_at(1, 0) + m.get_at(1, 1)).0;
                ans.chmax(v + std::cmp::max(0, a[i + 1] - d[i + 1]));
                seg.update(i + 1, Some(mat[i + 1].clone()));
            }
        }
    } else {
        let sum = a.iter().sum::<i64>();
        for d in d.iter().rev().skip(1) {
            ans.chmax(sum - *d);
        }
        ans.chmax(a[n - 1] - d[n - 1]);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))
if K >= 2:
    print(max(0, sum(A) - min(*D[:-1])))
    exit(0)

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = max(A[N-1] - D[N-1], 0)
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])
    # print(i, suf_ans[i])

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = A[0]
pre_sum = 0
ans = suf_ans[0]
for i in range(N-1):
    pre_sum += A[i]
    ans = max(ans, pre_sum - D[i] + suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))
if K >= 2:
    print(max(0, sum(A) - min(*D[:-1])))
    exit(0)

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = max(A[N-1] - D[N-1], 0)
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])
    # print(i, suf_ans[i])

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = D[0]
pre_sum = 0
ans = 0
for i in range(N-1):
    pre_sum += A[i]
    pre_min = min(pre_min, D[i])
    ans = max(ans, pre_sum - pre_min + suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))
if K % 2 == 0 and K != 0:
    print(max(0, sum(A) - min(*D[:-1])))
    exit(0)

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = A[N-1] - D[N-1]
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])
    # print(i, suf_ans[i])

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = A[0]
pre_sum = 0
ans = suf_ans[0]
for i in range(N-1):
    pre_sum += A[i]
    ans = max(ans, pre_sum - D[i] + suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))

suf_min = [None]*N
suf_min[-1] = A[-1]
suf_sum = [None]*N
suf_sum[-1] = A[-1]
suf_ans = [None]*N
suf_ans[-1] = max(A[-1] - D[-1], 0)
for i in range(N-2, -1, -1):
    suf_min[i] = min(A[i], suf_min[i+1])
    suf_sum[i] = suf_sum[i+1] + A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum[i]-D[i])
    # print(i, suf_ans[i])

if K >= 2:
    print(max(0, sum(A) - min(*D[:-1]), suf_ans[0]))
    exit(0)

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = D[0]
pre_sum = 0
ans = 0
for i in range(N-1):
    pre_sum += A[i]
    pre_min = min(pre_min, D[i])
    ans = max(ans, pre_sum - pre_min + suf_ans[i+1], suf_sum[i] - suf_min[i] - D[i])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))
if K % 2 == 0 and K != 0:
    print(max(0, sum(A) - min(*D)))
    exit(0)

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = A[N-1] - D[N-1]
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])
    # print(i, suf_ans[i])

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = A[0]
pre_sum = 0
ans = suf_ans[0]
for i in range(N-1):
    pre_sum += A[i]
    ans = max(ans, pre_sum - D[i] + suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))

suf_min = [None]*N
suf_min[-1] = A[-1]
suf_sum = [None]*N
suf_sum[-1] = A[-1]
suf_ans = [None]*N
suf_ans[-1] = max(A[-1] - D[-1], 0)
for i in range(N-2, -1, -1):
    suf_min[i] = min(A[i], suf_min[i+1])
    suf_sum[i] = suf_sum[i+1] + A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum[i]-D[i])
    # print(i, suf_ans[i])

if K >= 2:
    print(max(0, sum(A) - min(*D[:-1]), suf_ans[0]))
    exit(0)

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = D[0]
pre_sum = 0
ans = max(0, sum(A) - D[0] - suf_min[0])
for i in range(N-1):
    pre_sum += A[i]
    pre_min = min(pre_min, D[i])
    ans = max(ans, pre_sum - pre_min + suf_ans[i+1], suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))
if K >= 2:
    print(max(0, sum(A) - min(*D[:-1])))
    exit(0)

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = max(A[N-1] - D[N-1], 0)
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])
    # print(i, suf_ans[i])

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = D[0]
pre_sum = 0
ans = suf_ans[0]
for i in range(N-1):
    pre_sum += A[i]
    pre_min = min(pre_min, D[i])
    ans = max(ans, pre_sum - pre_min + suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = max(A[N-1] - D[N-1], 0)
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])
    # print(i, suf_ans[i])

if K >= 2:
    print(max(0, sum(A) - min(*D[:-1]), suf_ans[0]))
    exit(0)

if K == 0:
    print(max(suf_ans[0], 0))
    exit(0)

pre_min = D[0]
pre_sum = 0
ans = 0
for i in range(N-1):
    pre_sum += A[i]
    pre_min = min(pre_min, D[i])
    ans = max(ans, pre_sum - pre_min + suf_ans[i+1])
print(max(0, ans))


N, K = map(int, input().split())
A = list(map(int, input().split()))
D = list(map(int, input().split()))
if K % 2 == 0:
    print(sum(A) - min(*D))
    exit(0)

suf_sum = A[N-1]
suf_ans = [None]*N
suf_ans[N-1] = A[N-1] - D[N-1]
for i in range(N-2, -1, -1):
    suf_sum += A[i]
    suf_ans[i] = max(suf_ans[i+1], suf_sum-D[i])

pre_min = A[0]
pre_sum = 0
ans = suf_ans[0]
for i in range(N-1):
    pre_sum += A[i]
    ans = max(ans, pre_sum - D[i] + suf_ans[i+1])
print(ans)


import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline()

# ------------------------------

def RL(): return map(int, sys.stdin.readline().split())
def RLL(): return list(map(int, sys.stdin.readline().split()))
def N(): return int(input())
def print_list(l):
    print(' '.join(map(str,l)))
# sys.setrecursionlimit(100000)
# from heapq import *
# from collections import deque as dq
# from math import ceil,floor,sqrt,pow,gcd,log
# import bisect as bs
# from collections import Counter
# from collections import defaultdict as dc
# from functools import reduce
# from functools import lru_cache

##################
## Ugly Problem ##
##################

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    o2 = sum(a) - min(a[1:]) - d[0]

    print(max((best,other,0, o2)))
else:
    print(max((sum(a) - min(d[:-1]),0,a[-1] - d[-1])))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, a[-1] - d[-1], 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    remain = sum(a)
    nolast = sum(a[: -1])
    ans = 0
    for i in range(n):
        remain -= a[i]
        ans = max(ans, remain - d[i], nolast - d[i])
    ans = max(ans, sum(a) - d[0] - min(a[1:]))
    print(ans)


import os
import sys
from io import BytesIO, IOBase

# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, a[-1] - d[-1], 0))
elif k == 0:
    rightans = [0] * n
    cursum = 0
    ans = 0
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        rightans[i] = max(cursum - d[i], 0)
    print(max(rightans))
else:
    leftd = int(1e9)
    leftsum = 0
    rightans = [0] * n
    cursum = 0
    ans = 0
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        rightans[i] = max(cursum - d[i], 0)
    for i in range(n - 1, 0, -1):
        rightans[i - 1] = max(rightans[i - 1], rightans[i])
    for i in range(n - 1):
        leftd = min(leftd, d[i])
        leftsum += a[i]
        curans = max(leftsum - leftd, 0) + rightans[i + 1]
        ans = max(ans, curans)

    cursum = 0
    rightmin = int(1e9)
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        ans = max(ans, cursum - rightmin - d[i])
        rightmin = min(rightmin, a[i])
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d)
    print(max(sum(a) - m, 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        ans = sum(a[j] for j in range(i, n)) - d[i]
    else:
        ans = 0
    m = min(d[: -1])
    ans = max(ans, sum(a[: -1]) - m, 0)
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(a)
    print(max(sum(a) - m, 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        ans = sum(a[j] for j in range(i, n)) - d[i]
    else:
        ans = 0
    m = min(a[: -1])
    ans = max(ans, sum(a[: -1]) - m, 0)
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, a[-1] - d[-1], 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    leftd = int(1e9)
    leftsum = 0
    rightans = [0] * n
    cursum = 0
    ans = 0
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        rightans[i] = max(cursum - d[i], 0)
    for i in range(n - 1, 0, -1):
        rightans[i - 1] = max(rightans[i - 1], rightans[i])
    for i in range(n - 1):
        leftd = min(leftd, d[i])
        leftsum += a[i]
        curans = max(leftsum - leftd, 0) + rightans[i + 1]
        ans = max(ans, curans)

    cursum = 0
    rightmin = int(1e9)
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        ans = max(ans, cursum - rightmin - d[i])
        rightmin = min(rightmin, a[i])
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        ans = sum(a[j] for j in range(i, n)) - d[i]
    else:
        ans = 0
    m = min(d[: -1])
    ans = max(ans, sum(a[: -1]) - m, 0)
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, a[-1] - d[-1], 0))
elif k == 0:
    rightans = [0] * n
    cursum = 0
    ans = 0
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        rightans[i] = max(cursum - d[i], 0)
    print(max(rightans))
else:
    leftd = int(1e9)
    leftsum = 0
    rightans = [0] * n
    cursum = 0
    ans = 0
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        rightans[i] = max(cursum - d[i], 0)
    for i in range(n - 1, 0, -1):
        rightans[i - 1] = max(rightans[i - 1], rightans[i])
    for i in range(n - 1):
        leftd = min(leftd, d[i])
        leftsum += a[i]
        curans = max(leftsum - leftd, 0) + rightans[i + 1]
        ans = max(ans, curans)

    cursum = 0
    rightmin = int(1e9)
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        ans = max(ans, cursum - rightmin - d[i])
        rightmin = min(rightmin, a[i])
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    remain = sum(a)
    nolast = sum(a[: -1])
    ans = 0
    for i in range(n):
        remain -= a[i]
        ans = max(ans, remain - d[i], nolast - d[i])
    ans = max(ans, sum(a) - d[0] - min(a[1:]))
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k >= 2:
    m = min(d[: -1])
    print(max(sum(a) - m, a[-1] - d[-1], 0))
elif k == 0:
    ans = False
    for i, (ai, di) in enumerate(zip(a, d)):
        if ai >= di:
            ans = True
            break
    if ans:
        print(sum(a[j] for j in range(i, n)) - d[i])
    else:
        print(0)
else:
    leftd = int(1e9)
    leftsum = 0
    rightans = [0] * n
    cursum = 0
    ans = 0
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        rightans[i] = (cursum - d[i])
    for i in range(n - 1, 0, -1):
        rightans[i - 1] = max(rightans[i - 1], rightans[i])
    for i in range(n - 1):
        leftd = min(leftd, d[i])
        leftsum += a[i]
        curans = max(leftsum - leftd, 0) + rightans[i + 1]
        ans = max(ans, curans)

    cursum = 0
    rightmin = int(1e9)
    for i in range(n - 1, -1, -1):
        cursum += a[i]
        ans = max(ans, cursum - rightmin - d[i])
        rightmin = min(rightmin, a[i])
    print(ans)


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))
pref=[0]
for i in range(n):
    pref.append(pref[-1]+a[i])
if k==0:
    ans=0
    for i in range(1,n):
        ans=max(ans,pref[-1]-pref[i-1]-d[i-1])
    print(ans)
elif k == 1:
    best = sum(a[:n-1]) - min(d[:n-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    o2 = sum(a) - min(a[1:]) - d[0]

    print(max((best,other,0, o2)))
else:
    print(max((sum(a) - min(d[:-1]),0,a[-1] - d[-1])))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))
pref=[0]
for i in range(n):
    pref.append(pref[-1]+a[i])
if k==0:
    ans=0
    for i in range(1,n+1):
        ans=max(ans,pref[-1]-pref[i-1]-d[i-1])
    print(ans)
elif k == 1:
    best = sum(a[:n-1]) - min(d[:n-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    o2 = sum(a) - min(a[1:]) - d[0]

    print(max((best,other,0, o2)))
else:
    print(max((sum(a) - min(d[:-1]),0,a[-1] - d[-1])))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a) - d[0] - a[-1]
    pref = 0
    dmin = 10**10
    for i in range(n - 1):
        pref += a[i]
        dmin = min(d[i], dmin)
        best = max(best, pref - dmin)
    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max(best,other))
else:
    print(sum(a) - min(d))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a) - d[0] - a[-1]
    pref = 0
    for i in range(n - 1):
        pref += a[i]
        best = max(best, pref - d[i])
    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max(best,other))
else:
    print(sum(a) - min(d))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a) - d[0] - a[-1]
    pref = 0
    for i in range(n - 1):
        pref += a[i]
        best = max(best, pref - d[i])
    print(best)
else:
    print(sum(a) - min(d))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max((best,other,0)))
else:
    print(max(sum(a) - min(d),0))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])
    best = max(best, sum(a[1:]) - min(d[1:]))

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max((best,other,0)))
else:
    print(max(sum(a) - min(d[:-1]),0))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    o2 = sum(a) - a[1] - d[0]

    print(max((best,other,0, o2)))
else:
    print(max((sum(a) - min(d[:-1]),0,a[-1] - d[-1])))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    assert(n == 6)
    best = sum(a) - d[0] - a[-1]
    pref = 0
    dmin = 10**10
    for i in range(n - 1):
        pref += a[i]
        dmin = min(d[i], dmin)
        best = max(best, pref - dmin)
    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max(best,other))
else:
    print(sum(a) - min(d))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    print(max((best,other,0)))
else:
    print(max((sum(a) - min(d[:-1]),0,a[-1] - d[-1])))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    o2 = sum(a) - min(a[1:]) - d[0]

    print(max((best,other,0, o2)))
else:
    print(max((sum(a) - min(d[:-1]),0,a[-1] - d[-1])))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max((best,other,0)))
else:
    print(max(sum(a) - min(d[:-1]),0))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]
    print(max(best,other))
else:
    print(sum(a) - min(d))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

        curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    print(max((best,other,0)))
else:
    print(max(sum(a) - min(d[:-1]),0))


n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))

if k == 0:
    best = 0
    curr = sum(a)
    for i in range(n):
        best = max(best, curr - d[i])
        curr -= a[i]
    print(best)
elif k == 1:
    best = sum(a[:-1]) - min(d[:-1])

    other = sum(a)
    other -= sorted(d)[0]
    other -= sorted(d)[1]

    curr = sum(a)
    for i in range(n):
        if i:
            best = max(best, curr - d[i])
        curr -= a[i]

    print(max((best,other,0)))
else:
    print(max(sum(a) - min(d[:-1]),0))


N,K = map(int,input().split())
A = list(map(int,input().split()))
D = list(map(int,input().split()))
if K >= 2:
    print(max(0,sum(A)-min(D[:N-1]),A[N-1]-D[N-1]))
if K == 0:
    S = 0
    ans = 0
    for i in range(N)[::-1]:
        S += A[i]
        ans = max(ans,S-D[i])
    print(ans)
if K == 1:
    ans = 0
    right = 0
    minD = [D[0]]
    csA = [A[0]]
    for i in range(1,N):
        minD.append(min(minD[-1],D[i]))
        csA.append(csA[-1]+A[i])
    z = 0
    for i in range(N)[::-1]:
        x = 0
        y = csA[i]-minD[i]
        if y >= 0:
            x += y
        x += z
        if i != N-1:
            ans = max(ans,x)
        right += A[i]
        z = max(z,right-D[i])
    print(ans)


N,K = map(int,input().split())
A = list(map(int,input().split()))
D = list(map(int,input().split()))
if K >= 2:
    print(max(0,sum(A)-min(D[:N-1]),A[N-1]-D[N-1]))
if K == 0:
    S = 0
    ans = 0
    for i in range(N)[::-1]:
        S += A[i]
        ans = max(ans,S-D[i])
    print(ans)
if K == 1:
    minD = [D[0]] #i番目までのDの最小値
    csA = [A[0]] #i番目までのAの累積和
    for i in range(1,N):
        minD.append(min(minD[-1],D[i]))
        csA.append(csA[-1]+A[i])
    csinvA = [A[N-1]] #i番目からのAの累積和
    for i in range(N-1)[::-1]:
        csinvA.append(csinvA[-1]+A[i])
    csinvA = csinvA[::-1]
    right = [] #i番目を操作したとき差し引き得られるエネルギー
    S = 0
    for i in range(N)[::-1]:
        S += A[i]
        right.append(S-D[i])
    right = right[::-1]
    rightM = [right[N-1]] #rightのi番目以降のmax
    for i in range(N-1)[::-1]:
        rightM.append(max(rightM[-1],right[i]))
    rightM = rightM[::-1]
    ans = 0
    z = 0
    for i in range(N)[::-1]: #1~N-2番目を0番目に結ぶパターン
        x = 0
        y = csA[i]-minD[i]
        if y >= 0:
            x += y
        x += z
        if i != N-1 and i != 0:
            ans = max(ans,x)
        z = max(z,right[i])
    for i in range(N-2): #i(0~N-3)番目をi+2番目に結ぶパターン
        ans = max(ans,right[i+1]) #i+1番目をつけるパターン
        ans = max(ans,rightM[0]-D[i+1]) #i+1番目ともう一つつけるパターン
        ans = max(ans,rightM[i+2]) #i+2番目以降を付けるパターン
        ans = max(ans,rightM[0]-A[i+1]) #i番目以前を付けるパターン
    print(ans)


N,K = map(int,input().split())
A = list(map(int,input().split()))
D = list(map(int,input().split()))
if K >= 2:
    print(max(0,sum(A)-min(D[:N-1]),A[N-1]-D[N-1]))
if K == 0:
    S = 0
    ans = 0
    for i in range(N)[::-1]:
        S += A[i]
        ans = max(ans,S-D[i])
    print(ans)
if K == 1:
    ans = 0
    right = 0
    minD = [D[0]]
    csA = [A[0]]
    for i in range(1,N):
        minD.append(min(minD[-1],D[i]))
        csA.append(csA[-1]+A[i])
    z = 0
    for i in range(N)[::-1]:
        x = 0
        y = csA[i]-minD[i]
        if y >= 0:
            x += y
        x += z
        if i != N-1 and i != 0:
            ans = max(ans,x)
        right += A[i]
        z = max(z,right-D[i])
    x = 0
    y = csA[N-1]-A[1]-D[0]
    z = A[1]-D[1]
    if y >= 0:
        x += y
    if z >= 0:
        x += z
    ans = max(ans,x)
    print(ans)


N,K = map(int,input().split())
A = list(map(int,input().split()))
D = list(map(int,input().split()))
if K >= 2:
    print(max(0,sum(A)-min(D[:N-1])))
if K == 0:
    S = 0
    ans = 0
    for i in range(N)[::-1]:
        S += A[i]
        ans = max(ans,S-D[i])
    print(ans)
if K == 1:
    ans = 0
    right = 0
    minD = [D[0]]
    csA = [A[0]]
    for i in range(1,N):
        minD.append(min(minD[-1],D[i]))
        csA.append(csA[-1]+A[i])
    z = 0
    for i in range(N)[::-1]:
        x = 0
        y = csA[i]-minD[i]
        if y >= 0:
            x += y
        x += z
        if i != N-1:
            ans = max(ans,x)
        right += A[i]
        z = max(z,right-D[i])
    print(ans)


N,K = map(int,input().split())
A = list(map(int,input().split()))
D = list(map(int,input().split()))
if K >= 2:
    print(max(0,sum(A)-min(D[:N-1]),A[N-1]-D[N-1]))
if K == 0:
    S = 0
    ans = 0
    for i in range(N)[::-1]:
        S += A[i]
        ans = max(ans,S-D[i])
    print(ans)
if K == 1:
    minD = [D[0]]
    csA = [A[0]]
    for i in range(1,N):
        minD.append(min(minD[-1],D[i]))
        csA.append(csA[-1]+A[i])
    csinvA = [A[N-1]]
    for i in range(N-1)[::-1]:
        csinvA.append(csinvA[-1]+A[i])
    csinvA = csinvA[::-1]
    right = []
    S = 0
    for i in range(N)[::-1]:
        S += A[i]
        right.append(S-D[i])
    right = right[::-1]
    rightM = [right[N-1]]
    for i in range(N-1)[::-1]:
        rightM.append(max(rightM[-1],right[i]))
    rightM = rightM[::-1]
    ans = 0
    z = 0
    for i in range(N)[::-1]:
        x = 0
        y = csA[i]-minD[i]
        if y >= 0:
            x += y
        x += z
        if i != N-1 and i != 0:
            ans = max(ans,x)
        z = max(z,right[i])
    for i in range(N-2):
        ans = max(ans,right[i+1])
        ans = max(ans,rightM[0]-D[i+1])
        ans = max(ans,rightM[i+2])
        ans = max(ans,rightM[0]-A[i+1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    m=float("inf")
    ans=0
    while (j < (n - 1)):
        m=min(m,b[j])
        if j<(n-2):
            ans = max(ans, max(0,pre[j + 1] - m) + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1],s-b[0]-a[j+1])
        else:
            ans = max(ans, pre[j + 1] - m + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1])

        j += 1
    j=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    ans=max(ans,a[-1]-b[-1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    m=float("inf")
    ans=0
    while (j < (n - 1)):
        m=min(m,b[j])
        ans = max(ans, pre[j + 1] - m + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1])

        j += 1
    j=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    ans=max(ans,a[-1]-b[-1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    ans=max(ans,a[-1]-b[-1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    m=float("inf")
    ans=0
    while (j < (n - 1)):
        m=min(m,b[j])
        if j<(n-2):
            ans = max(ans, pre[j + 1] - m + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1],s-b[0]-a[j+1]+max(0,a[j+1]-b[j+1]))
        else:
            ans = max(ans, pre[j + 1] - m + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1])

        j += 1
    j=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    ans=max(ans,a[-1]-b[-1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    ans=0
    while (j < (n - 1)):
        ans = max(ans, pre[j + 1] - b[j] + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1])

        j += 1
    j=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    ans=max(ans,a[-1]-b[-1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    ans=0
    while (j < (n - 1)):
        ans = max(ans, pre[j + 1] - b[j] + max(0, af1[j + 1]), s - pre[j] - b[j] - a[j + 1])

        j += 1
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    ans=max(ans,a[-1]-b[-1])
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    print(ans)


import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
pre=[0]
j=0
while(j<n):
    pre.append(a[j]+pre[-1])
    j+=1
ab=[]
af=[]
af1=[]
j=n-1
while(j>=0):
    heapq.heappush(af,-(s-pre[j]-b[j]))
    af1.append(-af[0])

    j+=-1
af1.reverse()
if k==0:
    j=0
    ans=0
    while(j<n):
        ans=max(ans,s-pre[j]-b[j])
        j+=1
    print(ans)

elif k==1:
    j=0
    while(j<(n-1)):
        ans=max(ans,s-a[-1]-b[j]+max(0,a[-1]-b[-1]))

        j+=1
    print(ans)
else:
    j=0
    ans=0
    while(j<(n-1)):
        ans=max(ans,s-b[j])

        j+=1
    print(ans)


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                long val[] = new long[n];
                val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                for(i=n-2;i>=0;i--){
                    val[i] = Math.max(val[i+1],suf[i]-d[i]);
                }
                for(i=0;i<n;i++){
                    max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                }
                long min[] = new long[n+1];
                min[n] = Integer.MAX_VALUE;
                min[n-1] = a[n-1];
                for(i=n-2;i>=0;i--){
                    min[i] = Math.min(min[i+1],a[i]);
                }
                // long sum = pref[n-1];
                for(i=0;i<n-1;i++){
                    max = Math.max(max,suf[i]-d[i]-min[i+1]);
                }
            }
            else{
                long sum = pref[n-1];
                max = Math.max(0,a[n-1] - d[n-1]);
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                // long val[] = new long[n];
                // val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                // for(i=n-2;i>=0;i--){
                //     val[i] = Math.max(val[i+1],suf[i]-d[i]);
                // }
                // for(i=0;i<n;i++){
                //     max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                // }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,pref[n-2]-d[i]+Math.max(a[n-1]-d[n-1],0));
                }
            }
            else{
                long sum = pref[n-1];
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                // long val[] = new long[n];
                // val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                // for(i=n-2;i>=0;i--){
                //     val[i] = Math.max(val[i+1],suf[i]-d[i]);
                // }
                // for(i=0;i<n;i++){
                //     max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                // }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,pref[n-2]-d[i]+Math.max(a[n-1]-d[n-1],0));
                }
            }
            else{
                long sum = pref[n-1];
                for(i=0;i<n;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                // long val[] = new long[n];
                // val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                // for(i=n-2;i>=0;i--){
                //     val[i] = Math.max(val[i+1],suf[i]-d[i]);
                // }
                // for(i=0;i<n;i++){
                //     max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                // }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,pref[n-2]-d[i]+Math.max(a[n-1]-d[n-1],0));
                }
            }
            else{
                long sum = pref[n-1];
                max = Math.max(0,a[n-1] - d[n-1]);
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                long val[] = new long[n];
                val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                for(i=n-2;i>=0;i--){
                    val[i] = Math.max(val[i+1],suf[i]-d[i]);
                }
                for(i=0;i<n;i++){
                    max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                }
                long min[] = new long[n+1];
                min[n] = Integer.MAX_VALUE;
                min[n-1] = a[n-1];
                for(i=n-2;i>=0;i--){
                    min[i] = Math.min(min[i+1],a[i]);
                }
                long sum = pref[n-1];
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[0]-min[i+1]);
                }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,(pref[n-2]-d[i]+Math.max(a[n-1]-d[n-1],0)));
                }
            }
            else{
                long sum = pref[n-1];
                max = Math.max(0,a[n-1] - d[n-1]);
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                // long val[] = new long[n];
                // val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                // for(i=n-2;i>=0;i--){
                //     val[i] = Math.max(val[i+1],suf[i]-d[i]);
                // }
                // for(i=0;i<n;i++){
                //     max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                // }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,pref[n-2]-d[i]+Math.max(a[n-1]-d[n-1],0));
                }
            }
            else{
                long sum = pref[n-1];
                max = a[n-1] - d[n-1];
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                long val[] = new long[n];
                val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                for(i=n-2;i>=0;i--){
                    val[i] = Math.max(val[i+1],suf[i]-d[i]);
                }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                }
                long min[] = new long[n+1];
                min[n] = Integer.MAX_VALUE;
                min[n-1] = a[n-1];
                for(i=n-2;i>=0;i--){
                    min[i] = Math.min(min[i+1],a[i]);
                }
                long sum = pref[n-1];
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[0]-min[i+1]);
                }
                for(i=0;i<n-1;i++){
                    max = Math.max(max,(pref[n-2]-d[i]+Math.max(a[n-1]-d[n-1],0)));
                }
            }
            else{
                long sum = pref[n-1];
                max = Math.max(0,a[n-1] - d[n-1]);
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[])
    {
        factors[1]=1;
        for(int p = 2; p*p <=n; p++)
        {
            if(factors[p] == 0)
            {
                factors[p]=p;
                for(int i = p*p; i <= n; i += p)
                    factors[i] = p;
            }
        }
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int a[] = new int[n];
            int d[] = new int[n];
            long pref[] = new long[n];
            for(i=0;i<n;i++)
                a[i] = sc.nextInt();
            for(i=0;i<n;i++)
                d[i] = sc.nextInt();
            pref[0] = a[0];
            for(i=1;i<n;i++){
                pref[i] = pref[i-1] + a[i];
            }
            long suf[] = new long[n];
            suf[n-1] = a[n-1];
            for(i=n-2;i>=0;i--){
                suf[i] = suf[i+1] + a[i];
            }
            long max = 0;
            if(k==0){
                for(i=0;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
            }
            else if(k==1){
                for(i=1;i<n;i++){
                    max = Math.max(max,suf[i]-d[i]);
                }
                long val[] = new long[n];
                val[n-1] = Math.max(0,suf[n-1] - d[n-1]);
                for(i=n-2;i>=0;i--){
                    val[i] = Math.max(val[i+1],suf[i]-d[i]);
                }
                for(i=0;i<n;i++){
                    max = Math.max(max,pref[i]-d[i]+(i<n-1?val[i+1]:0));
                }
                long min[] = new long[n+1];
                min[n] = Integer.MAX_VALUE;
                min[n-1] = a[n-1];
                for(i=n-2;i>=0;i--){
                    min[i] = Math.min(min[i+1],a[i]);
                }
                long sum = pref[n-1];
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]-min[i+1]);
                }
            }
            else{
                long sum = pref[n-1];
                max = Math.max(0,a[n-1] - d[n-1]);
                for(i=0;i<n-1;i++){
                    max = Math.max(max,sum-d[i]);
                }
            }
            pw.println(max);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        // int c;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

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

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

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