import java.io.*;
import java.math.*;
import java.util.*;
public class Equalize {

	public static void main(String[] args) {
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int ans = 0;
		char[] a = I.next().toCharArray();
		char[] b = I.next().toCharArray();
		for (int i = 0; i < N; i++) {
			if (i<N-1&&a[i]!=b[i]&&a[i+1]!=b[i+1]) {
				ans++;
				i++; //Swap optimization
			}else if (a[i]!=b[i]) ans++; //Just invert the current bit otherwise
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0)
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
	}
}


import java.io.*;
import java.math.*;
import java.util.*;
public class Equalize {

	public static void main(String[] args) {
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int ans = 0;
		char[] a = I.next().toCharArray();
		char[] b = I.next().toCharArray();
		for (int i = 0; i < N; i++) {
			if (i<N-1&&a[i]!=b[i]&&a[i+1]!=b[i+1]&&a[i]!=a[i+1]&&b[i]!=b[i+1]) {
				ans++;
				i++; //Swap optimization
			}else if (a[i]!=b[i]) ans++; //Just invert the current bit otherwise
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0)
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
	}
}


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

public class Main implements Runnable{

	public void run() {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Solve solver = new Solve();
        solver.solve(1, in, out);
        out.close();
	}

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

    static class Solve {
    	public void solve(int testNumber, InputReader in, OutputWriter out) {
    		int n1 = in.nextInt();
    		String s1 = in.next();
    		String s2 = in.next();
    		int cont = 0;
    		for(int i = 0;i<s1.length();i++) {
    			if(s1.charAt(i)!=s2.charAt(i)) {
    				cont++;
    				while(s1.charAt(i)!=s2.charAt(i)&i<s1.length()) {
    					i++;
    					if(i>=s1.length()) break;
    				}
    			}
    		}out.println(cont);
        }
    }

    static class OutputWriter {
	    private final PrintWriter writer;

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

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

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

	    public void println(String string) {
	        writer.println(string);
	    }

	    public void println(int number) {
	        writer.println(number);
	    }

	    public void println(long number) {
	        writer.println(number);
	    }

	    public void println(double number) {
	    	writer.println(number);
	    }

	    public void print(long number) {
	        writer.print(number);
	    }

	    public void print(int number) {
	        writer.print(number);
	    }

	    public void print(String string) {
	        writer.print(string);
	    }

	    public void print(double number) {
	    	writer.print(number);
	    }
	}

	static class InputReader {
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public String nextLine() {
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (b!=10) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


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

public class Main implements Runnable{

	public void run() {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Solve solver = new Solve();
        solver.solve(1, in, out);
        out.close();
	}

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

    static class Solve {
    	public void solve(int testNumber, InputReader in, OutputWriter out) {
    		int n1 = in.nextInt();
    		String s1 = in.next();
    		String s2 = in.next();
    		int cont = 0;
    		for(int i = 0;i<n1;i++) {
    			if(i<n1-1) {
    				if(s1.charAt(i)=='1'&s2.charAt(i)=='0'&s2.charAt(i+1)=='1'&s1.charAt(i+1)=='0') {
    					cont++;
    					i++;
    					continue;
    				} if(s1.charAt(i)=='0'&s2.charAt(i)=='1'&s2.charAt(i+1)=='0'&s1.charAt(i+1)=='1') {
    					cont++;
    					i++;
    					continue;
    				}
    			}
    			if(s1.charAt(i)!=s2.charAt(i)) cont++;
    		}
    		out.println(cont);
        }
    }

    static class OutputWriter {
	    private final PrintWriter writer;

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

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

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

	    public void println(String string) {
	        writer.println(string);
	    }

	    public void println(int number) {
	        writer.println(number);
	    }

	    public void println(long number) {
	        writer.println(number);
	    }

	    public void println(double number) {
	    	writer.println(number);
	    }

	    public void print(long number) {
	        writer.print(number);
	    }

	    public void print(int number) {
	        writer.print(number);
	    }

	    public void print(String string) {
	        writer.print(string);
	    }

	    public void print(double number) {
	    	writer.print(number);
	    }
	}

	static class InputReader {
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public String nextLine() {
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (b!=10) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


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

public class Main implements Runnable{

	public void run() {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Solve solver = new Solve();
        solver.solve(1, in, out);
        out.close();
	}

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

    static class Solve {
    	public void solve(int testNumber, InputReader in, OutputWriter out) {
    		int n1 = in.nextInt();
    		String s1 = in.next();
    		String s2 = in.next();
    		int cont = 0;
    		for(int i = 0;i<s1.length();i++) {
    			if(s1.charAt(i)!=s2.charAt(i)) {
    				int ini = i;
    				while(s1.charAt(i)!=s2.charAt(i)&i<s1.length()) {
    					i++;
    					if(i>=s1.length()) break;
    				}
    				if(ini==i-1) cont++;
    				cont+=i-ini-1;
    			}
    		}out.println(cont);
        }
    }

    static class OutputWriter {
	    private final PrintWriter writer;

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

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

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

	    public void println(String string) {
	        writer.println(string);
	    }

	    public void println(int number) {
	        writer.println(number);
	    }

	    public void println(long number) {
	        writer.println(number);
	    }

	    public void println(double number) {
	    	writer.println(number);
	    }

	    public void print(long number) {
	        writer.print(number);
	    }

	    public void print(int number) {
	        writer.print(number);
	    }

	    public void print(String string) {
	        writer.print(string);
	    }

	    public void print(double number) {
	    	writer.print(number);
	    }
	}

	static class InputReader {
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public String nextLine() {
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (b!=10) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Solution
{
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		char []arr = sc.nextLine().toCharArray();
		char arr2[] = sc.nextLine().toCharArray();
		int i = 0;
		int cost = 0;
		while(i < n) {
		    if(arr[i] != arr2[i]) {
		        if(i+1 < n && arr[i+1] != arr2[i+1]) {
		            if(arr[i] != arr[i+1]) {
		                cost++;
		            }else {
		                cost += 2;
		            }
		            i += 2;
		            continue;
		        }else {
		            cost++;
		        }
		    }
		    i++;

		}

		System.out.println(cost);

	}

static class Scanner {
    BufferedReader bufferedReader;
    StringTokenizer stringTokenizer;

    public Scanner() {
      bufferedReader = new BufferedReader(new InputStreamReader(System.in), 1 << 10);
    }

    String next() {
      while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
        try {
          stringTokenizer = new StringTokenizer(bufferedReader.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return stringTokenizer.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = bufferedReader.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

  }

}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Solution
{
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		char []arr = sc.nextLine().toCharArray();
		char arr2[] = sc.nextLine().toCharArray();
		int i = 0;
		int cost = 0;
		while(i < n) {
		    if(arr[i] != arr2[i]) {
		        if(i+1 < n && arr[i+1] != arr2[i+1]) {
		            if(arr[i] != arr[i+1]) {
		                cost++;
		                i+=2;
		                continue;
		            }
		            cost++;
		        }else {
		            cost++;
		        }
		    }
		    i++;

		}

		System.out.println(cost);

	}

static class Scanner {
    BufferedReader bufferedReader;
    StringTokenizer stringTokenizer;

    public Scanner() {
      bufferedReader = new BufferedReader(new InputStreamReader(System.in), 1 << 10);
    }

    String next() {
      while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
        try {
          stringTokenizer = new StringTokenizer(bufferedReader.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return stringTokenizer.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = bufferedReader.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

  }

}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Solution
{
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		char []arr1 = sc.nextLine().toCharArray();
		char arr2[] = sc.nextLine().toCharArray();
		int i = 0;
		int cost = 0;
		while(i < n) {
		    if(arr[i] != arr2[i]) {
		        if(i+1 < n && arr[i+1] != arr2[i+1]) {
		            if(arr[i] != arr[i+1]) {
		                cost++;
		            }else {
		                cost += 2;
		            }
		            i += 2;
		            continue;
		        }else {
		            cost++;
		        }
		    }
		    i++;

		}

		System.out.println(cost);

	}

static class Scanner {
    BufferedReader bufferedReader;
    StringTokenizer stringTokenizer;

    public Scanner() {
      bufferedReader = new BufferedReader(new InputStreamReader(System.in), 1 << 10);
    }

    String next() {
      while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
        try {
          stringTokenizer = new StringTokenizer(bufferedReader.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return stringTokenizer.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = bufferedReader.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

  }

}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int n = Integer.parseInt(br.readLine());
        String s1 = br.readLine(),s2=br.readLine();
        long ans=0;
        for(int i=0;i<n-1;i++){
            if(s1.charAt(i)==s2.charAt(i+1)&&s1.charAt(i+1)==s2.charAt(i)) {
                ans++;
                i++;
            }
            else if(s1.charAt(i)!=s2.charAt(i)) ans++;
        }
        if(s1.charAt(n-1)!=s2.charAt(n-1)) ans++;
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int n = Integer.parseInt(br.readLine());
        String s1 = br.readLine(),s2=br.readLine();
        boolean flag=false;
        long ans=0;
        for(int i=0;i<n-1;i++){
            if((s1.charAt(i)==s2.charAt(i+1)&&s1.charAt(i+1)==s2.charAt(i)) && s1.charAt(i)!=s2.charAt(i)) {
                ans++;
                i++;
                if(i==n-1) flag=true;
            }
            else if(s1.charAt(i)!=s2.charAt(i)) ans++;
        }
        if(!flag && s1.charAt(n-1)!=s2.charAt(n-1)) ans++;
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int n = Integer.parseInt(br.readLine());
        String s1 = br.readLine(),s2=br.readLine();
        boolean flag=false;
        long ans=0;
        for(int i=0;i<n-1;i++){
            if(s1.charAt(i)==s2.charAt(i+1)&&s1.charAt(i+1)==s2.charAt(i)) {
                ans++;
                i++;
                if(i==n-1) flag=true;
            }
            else if(s1.charAt(i)!=s2.charAt(i)) ans++;
        }
        if(!flag && s1.charAt(n-1)!=s2.charAt(n-1)) ans++;
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int n = Integer.parseInt(br.readLine());
        char[] s1 = br.readLine().toCharArray(),s2=br.readLine().toCharArray();
        long ans=0;
        for(int i=0;i<n-1;i++){
            if((s1[i]==s2[i+1] && s1[i+1]==s2[i]) && (s1[i]!=s2[i])) {
                ans++;
                s1[i]=s2[i+1];
                i++;
            }
            else if(s1[i]!=s2[i]) ans++;
        }
        if(s1[n-1]!=s2[n-1]) ans++;
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}


//package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    String a = sc.next();
	    String b = sc.next();
	    int count=0;
	    if(n==1){
	    	if(a.charAt(0)==b.charAt(0)){
	    		System.out.println(0);

			}
			else{
				System.out.println(1);
			}
			System.exit(0);
		}
	    for(int i=0;i<n-1;i++){
	        if(a.charAt(i)!=b.charAt(i)){
	            if(a.charAt(i)==b.charAt(i+1) && a.charAt(i+1)==b.charAt(i)){
	                count++;
                    i++;
                }
                else{
	                count++;
                }
            }
        }
        if(a.charAt(n-1)!=b.charAt(n-1)){
	        if(a.charAt(n-2)!=b.charAt(n-1) || a.charAt(n-1)!=b.charAt(n-2))
	            count++;
        }
        System.out.println(count);
    }

}


//package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    String a = sc.next();
	    String b = sc.next();
	    int count=0;
	    for(int i=0;i<n-1;i++){
	        if(a.charAt(i)!=b.charAt(i)){
	            if(a.charAt(i)==b.charAt(i+1) && a.charAt(i+1)==b.charAt(i)){
	                count++;
                    i++;
                }
                else{
	                count++;
                }
            }
        }
        if(a.charAt(n-1)!=b.charAt(n-1)){
	        if(a.charAt(n-2)!=b.charAt(n-1) || a.charAt(n-1)!=b.charAt(n-2))
	            count++;
        }
        System.out.println(count);
    }

}


//package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    String a = sc.next();
	    String b = sc.next();
	    int count=0;
	    int last_swp_i = -1;
	    if(n==1){
	    	if(a.charAt(0)==b.charAt(0)){
	    		System.out.println(0);

			}
			else{
				System.out.println(1);
			}
			System.exit(0);
		}
	    for(int i=0;i<n-1;i++){
	        if(a.charAt(i)!=b.charAt(i)){
	            if(a.charAt(i)==b.charAt(i+1) && a.charAt(i+1)==b.charAt(i)){
	                count++;
                    i++;
                    last_swp_i=i;
                }
                else{
	                count++;
                }
            }
        }
        if(a.charAt(n-1)!=b.charAt(n-1)){
	    	if(last_swp_i==n-2)
	    		count++;
	    	else if(a.charAt(n-2)!=b.charAt(n-1) || a.charAt(n-1)!=b.charAt(n-2))
	            count++;
        }
        System.out.println(count);
    }

}


import java.util.Scanner;

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

        // Codeforces C

        Scanner fs = new Scanner(System.in);
        int N = fs.nextInt();
        String a = fs.next();
        String b = fs.next();
        char A[] = a.toCharArray();
        char B[] = b.toCharArray();
        long ans = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] != B[i]) {
                if (i == 0) {
                    if (A[i + 1] != B[i + 1]) {
                        if (A[i] != A[i + 1]) {
                            char temp = A[i];
                            A[i] = A[i + 1];
                            A[i + 1] = temp;
                            ans++;
                        }
                    }
                    else {
                        ans++;
                    }
                } else if (i == N - 1) {
                    if (A[i - 1] != B[i - 1]) {
                        if (A[i] != A[i - 1]) {
                            char temp = A[i];
                            A[i] = A[i - 1];
                            A[i - 1] = temp;
                            ans++;
                        }
                    } else {
                        ans++;
                    }
                } else {
                    if (A[i + 1] != B[i + 1]) {
                        if (A[i] != A[i + 1]) {
                            char temp = A[i];
                            A[i] = A[i + 1];
                            A[i + 1] = temp;
                            ans++;
                        } else if (A[i - 1] != B[i - 1]) {
                            if (A[i] != A[i - 1]) {
                                char temp = A[i];
                                A[i] = A[i - 1];
                                A[i - 1] = temp;
                                ans++;
                            }
                        }
                    } else {
                        ans++;
                    }
                }

            }
        }

        System.out.println(ans);
    }
}


import java.util.Scanner;

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

        // Codeforces C

        Scanner fs = new Scanner(System.in);
        int N = fs.nextInt();
        String a = fs.next();
        String b = fs.next();
        char A[] = a.toCharArray();
        char B[] = b.toCharArray();
        long ans = 0;
        if(N==1){
            if(A[0]==B[0]){
                System.out.println("0");
            }else{
                System.out.println("1");
            }
        }else {
            for (int i = 0; i < N; i++) {

                if (A[i] != B[i]) {
                    if (i == 0) {
                        if (A[i + 1] != B[i + 1] && A[i] != A[i + 1]) {

                                char temp = A[i];
                                A[i] = A[i + 1];
                                A[i + 1] = temp;
                                ans++;

                        } else {
                            if (A[i] == '0') {
                                A[i] = '1';
                            } else {
                                A[i] = '0';
                            }
                            ans++;
                        }
                    } else if (i == N - 1) {
                        if (A[i - 1] != B[i - 1] && A[i]!=A[i-1]) {

                                char temp = A[i];
                                A[i] = A[i - 1];
                                A[i - 1] = temp;
                                ans++;

                        } else {
                            if (A[i] == '0') {
                                A[i] = '1';
                            } else {
                                A[i] = '0';
                            }
                            ans++;
                        }
                    } else {
                        if (A[i + 1] != B[i + 1] && A[i + 1] != A[i]) {
                            char temp = A[i];
                            A[i] = A[i + 1];
                            A[i + 1] = temp;
                            ans++;

                        } else if (A[i - 1] != B[i - 1] && A[i - 1] != A[i]) {
                            char temp = A[i];
                            A[i] = A[i - 1];
                            A[i - 1] = temp;
                            ans++;
                        } else {
                            if (A[i] == '0') {
                                A[i] = '1';
                            } else {
                                A[i] = '0';
                            }
                            ans++;
                        }

                    }
                }

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


import java.util.Scanner;

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

        // Codeforces C

        Scanner fs = new Scanner(System.in);
        int N = fs.nextInt();
        String a = fs.next();
        String b = fs.next();
        char A[] = a.toCharArray();
        char B[] = b.toCharArray();
        long ans = 0;
        if(N==1){
            if(A[0]==B[0]){
                System.out.println("0");
            }else{
                System.out.println("1");
            }
        }else {
            for (int i = 0; i < N; i++) {

                if (A[i] != B[i]) {
                    if (i == 0) {
                        if (A[i + 1] != B[i + 1]) {
                            if (A[i] != A[i + 1]) {
                                char temp = A[i];
                                A[i] = A[i + 1];
                                A[i + 1] = temp;
                                ans++;
                            }
                        } else {
                            if (A[i] == '0') {
                                A[i] = '1';
                            } else {
                                A[i] = '0';
                            }
                            ans++;
                        }
                    } else if (i == N - 1) {
                        if (A[i - 1] != B[i - 1]) {
                            if (A[i] != A[i - 1]) {
                                char temp = A[i];
                                A[i] = A[i - 1];
                                A[i - 1] = temp;
                                ans++;
                            }
                        } else {
                            if (A[i] == '0') {
                                A[i] = '1';
                            } else {
                                A[i] = '0';
                            }
                            ans++;
                        }
                    } else {
                        if (A[i + 1] != B[i + 1] && A[i + 1] != A[i]) {
                            char temp = A[i];
                            A[i] = A[i + 1];
                            A[i + 1] = temp;
                            ans++;

                        } else if (A[i - 1] != B[i - 1] && A[i - 1] != A[i]) {
                            char temp = A[i];
                            A[i] = A[i - 1];
                            A[i - 1] = temp;
                            ans++;
                        } else {
                            if (A[i] == '0') {
                                A[i] = '1';
                            } else {
                                A[i] = '0';
                            }
                            ans++;
                        }

                    }
                }

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


import java.util.Scanner;

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

        // Codeforces C

        Scanner fs = new Scanner(System.in);
        int N = fs.nextInt();
        String a = fs.next();
        String b = fs.next();
        char A[] = a.toCharArray();
        char B[] = b.toCharArray();
        long ans = 0;
        for (int i = 0; i < N; i++) {

            if (A[i] != B[i]) {
                if (i == 0) {
                    if (A[i + 1] != B[i + 1]) {
                        if (A[i] != A[i + 1]) {
                            char temp = A[i];
                            A[i] = A[i + 1];
                            A[i + 1] = temp;
                            ans++;
                        }
                    } else {
                        if (A[i] == '0') {
                            A[i] = '1';
                        } else {
                            A[i] = '0';
                        }
                        ans++;
                    }
                } else if (i == N - 1) {
                    if (A[i - 1] != B[i - 1]) {
                        if (A[i] != A[i - 1]) {
                            char temp = A[i];
                            A[i] = A[i - 1];
                            A[i - 1] = temp;
                            ans++;
                        }
                    } else {
                        if (A[i] == '0') {
                            A[i] = '1';
                        } else {
                            A[i] = '0';
                        }
                        ans++;
                    }
                } else {
                    if(A[i+1]!=B[i+1] && A[i+1]!=A[i]){
                        char temp = A[i];
                        A[i]=A[i+1];
                        A[i+1]= temp;
                        ans++;

                    }else if(A[i-1]!=B[i-1] && A[i-1]!=A[i]){
                        char temp = A[i];
                        A[i]=A[i-1];
                        A[i-1]= temp;
                        ans++;
                    }else{
                        if (A[i] == '0') {
                            A[i] = '1';
                        } else {
                            A[i] = '0';
                        }
                        ans++;
                    }

                }
            }

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


                           /* Rajkin Hossain */
import java.io.*;
import java.util.*;

public class B {

    //static FastInput k = new FastInput("/home/rajkin/Desktop/input.txt");
    static FastInput k = new FastInput(System.in);
    static FastOutput z = new FastOutput();
    static int n;
    static ArrayDeque<Integer> ones, zeros;
    static char [] a, b;

    static void swap(int i, int j){
    	char zz = a[i];
    	a[i] = a[j];
    	a[j] = zz;
    }

    static void startAlgorithm() {
    	int ans = 0;
		for(int i = 0; i<n; i++){
			if(a[i] != b[i]){
				if(a[i] == '1'){
					if(!zeros.isEmpty()){
						int diff = zeros.peekFirst() - i;
						if(diff == 1){
							swap(i, zeros.pollFirst());
						}
						ans++;
					}
					else {
						ans++;
					}
				}
				else{
					if(!ones.isEmpty()){
						int diff = ones.peekFirst() - i;
						if(diff == 1){
							swap(i, ones.pollFirst());
						}
						ans++;
					}
					else{
						ans++;
					}
				}
			}
		}

		z.println(ans);
    }

	public static void main(String [] args) throws FileNotFoundException {
		while(k.hasNext()) {
			n = k.nextInt();
			a = new char[n];
			b = new char[n];

			ones = new ArrayDeque<Integer>();
			zeros = new ArrayDeque<Integer>();

			a = k.next().toCharArray();
			b = k.next().toCharArray();

			for(int i = 0; i<n; i++){
				if(a[i] != b[i]){
					if(a[i] == '1'){
						ones.add(i);
					}
					else{
						zeros.add(i);
					}
				}
			}

			startAlgorithm();
        }

        z.flush();
        System.exit(0);
	}

    /* MARK: FastInput and FastOutput implementation */

    public static class FastInput {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public FastInput(InputStream stream){
        	reader = new BufferedReader(new InputStreamReader(stream));
        }

	    public FastInput(String path){
	        try {
	        	reader = new BufferedReader(new FileReader(path));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        tokenizer = null;
	    }

        public String next() {
            return nextToken();
        }

        public String nextLine() {
            try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

            return null;
        }

        public boolean hasNext(){
            try {
                return reader.ready();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }

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

        public Integer nextInt() {
            return Integer.parseInt(nextToken());
        }

        public Long nextLong() {
            return Long.valueOf(nextToken());
        }

    	public void inputIntegerList(ArrayList<Integer> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextInt());
    		}
    	}

    	public void inputLongList(ArrayList<Long> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextLong());
    		}
    	}

    	public void inputWordList(ArrayList<String> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(next());
    		}
    	}

    	public void inputLineList(ArrayList<String> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextLine());
    		}
    	}

    	public void inputIntegerArray(int [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextInt();
    		}
    	}

    	public void inputLongArray(long [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextLong();
    		}
    	}

    	public void inputWordArray(String [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = next();
    		}
    	}

    	public void inputLineArray(String [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextLine();
    		}
    	}
    }

    public static class FastOutput extends PrintWriter {
    	public FastOutput() {
            super(new BufferedOutputStream(System.out));
    	}

    	public void printSideBySideSet(Set<Object> set, int size) {
    		boolean isFirstElementPrinted = false;
    		for(Object element : set) {
    			if(!isFirstElementPrinted) {
    				print(element);
    				isFirstElementPrinted = true;

    				return;
    			}
    			print(" "+element);
    		}
    		println();
    	}

    	public void printLineByLineSet(Set<Object> set, int size) {
    		for(Object element : set) {
    			println(element);
    		}
    	}

    	public void printSideBySideList(ArrayList<Object> list, int size) {
    		print(list.get(0));
    		for(int i = 1; i<size; i++) {
    			print(" "+list.get(i));
    		}
    		println();
    	}

    	public void printLineByLineList(ArrayList<Object> list, int size) {
    		for(int i = 0; i<size; i++) {
    			println(list.get(i));
    		}
    	}

    	public void printSideBySideArray(Object [] array, int size) {
    		print(array[0]);
    		for(int i = 1; i<size; i++) {
    			print(" "+array[i]);
    		}
    		println();
    	}

    	public void printLineByLineArray(Object [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			println(array[i]);
    		}
    	}
    }
}


                           /* Rajkin Hossain */
import java.io.*;
import java.util.*;

public class C {

    //static FastInput k = new FastInput("/home/rajkin/Desktop/input.txt");
    static FastInput k = new FastInput(System.in);
    static FastOutput z = new FastOutput();
    static int n;
    static char [] a, b;

    static void swap(int i, int j){
    	char zz = a[i];
    	a[i] = a[j];
    	a[j] = zz;
    }

    static void startAlgorithm() {
    	int ans = 0;
		for(int i = 0; i<n; i++){
			if(a[i] != b[i]){
				if(i != n-1){
					if(a[i+1] != b[i+1] && a[i] != a[i+1]){
						swap(i, i+1);
						ans++;
					}
				}
				else{
					ans++;
				}
			}
		}

		z.println(ans);
    }

	public static void main(String [] args) throws FileNotFoundException {
		while(k.hasNext()) {
			n = k.nextInt();
			a = new char[n];
			b = new char[n];

			a = k.next().toCharArray();
			b = k.next().toCharArray();

			startAlgorithm();
        }

        z.flush();
        System.exit(0);
	}

    /* MARK: FastInput and FastOutput implementation */

    public static class FastInput {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public FastInput(InputStream stream){
        	reader = new BufferedReader(new InputStreamReader(stream));
        }

	    public FastInput(String path){
	        try {
	        	reader = new BufferedReader(new FileReader(path));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        tokenizer = null;
	    }

        public String next() {
            return nextToken();
        }

        public String nextLine() {
            try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

            return null;
        }

        public boolean hasNext(){
            try {
                return reader.ready();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }

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

        public Integer nextInt() {
            return Integer.parseInt(nextToken());
        }

        public Long nextLong() {
            return Long.valueOf(nextToken());
        }

    	public void inputIntegerList(ArrayList<Integer> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextInt());
    		}
    	}

    	public void inputLongList(ArrayList<Long> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextLong());
    		}
    	}

    	public void inputWordList(ArrayList<String> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(next());
    		}
    	}

    	public void inputLineList(ArrayList<String> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextLine());
    		}
    	}

    	public void inputIntegerArray(int [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextInt();
    		}
    	}

    	public void inputLongArray(long [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextLong();
    		}
    	}

    	public void inputWordArray(String [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = next();
    		}
    	}

    	public void inputLineArray(String [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextLine();
    		}
    	}
    }

    public static class FastOutput extends PrintWriter {
    	public FastOutput() {
            super(new BufferedOutputStream(System.out));
    	}

    	public void printSideBySideSet(Set<Object> set, int size) {
    		boolean isFirstElementPrinted = false;
    		for(Object element : set) {
    			if(!isFirstElementPrinted) {
    				print(element);
    				isFirstElementPrinted = true;

    				return;
    			}
    			print(" "+element);
    		}
    		println();
    	}

    	public void printLineByLineSet(Set<Object> set, int size) {
    		for(Object element : set) {
    			println(element);
    		}
    	}

    	public void printSideBySideList(ArrayList<Object> list, int size) {
    		print(list.get(0));
    		for(int i = 1; i<size; i++) {
    			print(" "+list.get(i));
    		}
    		println();
    	}

    	public void printLineByLineList(ArrayList<Object> list, int size) {
    		for(int i = 0; i<size; i++) {
    			println(list.get(i));
    		}
    	}

    	public void printSideBySideArray(Object [] array, int size) {
    		print(array[0]);
    		for(int i = 1; i<size; i++) {
    			print(" "+array[i]);
    		}
    		println();
    	}

    	public void printLineByLineArray(Object [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			println(array[i]);
    		}
    	}
    }
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k)
{
    int d=0;
    while(x!=1 && y!=1 && d<=k)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
    }

    if(d>k)
        return false;
    int z=0;
    if(x!=1)
        z=x;
    else
        z=y;
    while(z!=1 && d<=k)
    {
        d++;
        z/=2;
    }
    if(d>k)
        return false;

    return true;
}

int main()
{
        int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k)
{
    int d=0;
    while(x!=1 && y!=1 && d<=k)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
    }
    if(x!=y)
        d++;
    if(d<=k)
        return true;
    return false;
}

int main()
{
        int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k)
{
	int d=0;
	while(x!=1 && y!=1 && d<=k)
	{
		int mx=x%2;
		int my=y%2;
		if(mx!=my)
			d++;
		x/=2;
		y/=2;
	}

	if(d>k)
		return false;
	int z=0;
	if(x!=1)
		z=x;
	else if(y!=1)
		z=y;
	if(z % 2 != 1)
		d++;
	z/=2;
	while(z!=1 && d<=k)
	{
		d++;
		z/=2;
	}
	d++;
	if(d>k)
		return false;

	return true;
}

int main()
{
		int n,m,k;
		while(cin>>n>>m>>k)
		{
			int result=0;
			int* arr = new int[m+1];
			for(int i=0;i<=m;i++)
			{
				cin>>arr[i];
			}
			for(int i=0;i<m;i++)
			{
				if(testValidation(arr[i],arr[m],k))
					result++;
			}
			delete arr;
			cout<<result<<endl;
		}

	return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k)
{
    int d=0;
    while(x!=0 && y!=0 && d<=k)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
    }
    if(d>k)
        return false;
    int z;
    x!=0?z=x:z=y;
    while(z!=0 &&d<=k)
    {
        d++;
        z/=2;
    }
    if(d>k)
        return false;
    return true;
}

int main()
{
        int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k)
{
    int d=0;
    while(x!=1 && y!=1 && d<=k)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
    }

    if(d>k)
        return false;
    int z=0;
    if(x!=1)
        z=x;
    else
        z=y;
    if(z % 2 != 1)
        d++;
    while(z!=1 && d<=k)
    {
        d++;
        z/=2;
    }
    if(d>k)
        return false;

    return true;
}

int main()
{
        int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k,int n)
{
    int d=0;
    while( d<=k && n!=0)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
        n--;
    }
    if(d>k)
        return false;
    return true;
}

int main()
{
        long long int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k,n))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k,int n)
{
    int d=0;
    while(x!=0 && y!=0 && d<=k && n!=0)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
        n--;
    }
    if(d>k)
        return false;
    if(n==0)
        return true;
    int z;
    x!=0?z=x:z=y;
    while(z!=0 &&d<=k && n!=0)
    {
        d++;
        z/=2;
        n--;
    }
    if(d>k)
        return false;

    return true;
}

int main()
{
        long long int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k,n-1))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include<iostream>
#include<string>
using namespace std;

bool testValidation(int x,int y,int k)
{
    int d=0;
    while(x!=1 && y!=1 && d<=k)
    {
        int mx=x%2;
        int my=y%2;
        if(mx!=my)
            d++;
        x/=2;
        y/=2;
    }

    if(d>k)
        return false;
    int z=0;
    if(x!=1)
        z=x;
    else if(y!=1)
        z=y;
    if(z % 2 != 1)
        d++;
    while(z!=1 && d<=k)
    {
        d++;
        z/=2;
    }
    d++;
    if(d>k)
        return false;

    return true;
}

int main()
{
        int n,m,k;
        while(cin>>n>>m>>k)
        {
            int result=0;
            int* arr = new int[m+1];
            for(int i=0;i<=m;i++)
            {
                cin>>arr[i];
            }
            for(int i=0;i<m;i++)
            {
                if(testValidation(arr[i],arr[m],k))
                    result++;
            }
            delete arr;
            cout<<result<<endl;
        }

    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m,k, perem,otv = 0, j, v=0;
    vector<int> vec(m+1);
    cin >> n >> m >> k;
    for (int i = 0; i<m;i++)
    {
        cin >> vec[i];
    }
    cin >> vec[m +1];
    for (int i = 0; i<m;i++)
    {
        perem = vec[i]^vec[m+1];
        while (perem > 0)
        {
            j = perem % 2;
            perem /= 2;
            v = v + j;
        }
        if (v < k+1)
        {
            otv +=1;
        }

    }
    cout << otv;

}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m,k, perem,otv = 0, j, v=0;
    vector<int> vec(m+1);
    cin >> n >> m >> k;
    for (int i = 0; i<m-1;i++)
    {
        cin >> vec[i];
    }
    cin >> vec[m +1];
    for (int i = 0; i<m;i++)
    {
        int v;
        perem = vec[i]^vec[m+1];
        while (perem > 0)
        {
            j = perem % 2;
            perem /= 2;
            v = v + j;
        }
        if (v < k+1)
        {
            otv +=1;
        }

    }
    cout << otv;

}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m,k, perem,otv = 0, j, v=0;
    vector<int> vec(m+2);
    cin >> n >> m >> k;
    for (int i = 0; i<m;i++)
    {
        cin >> vec[i];
    }
    cin >> vec[m+1];
    for (int i = 0; i<m;i++)
    {
        int v = 0;
        perem = vec[i]^vec[m+1];
        while (perem > 0)
        {
            j = perem % 2;
            perem /= 2;
            v = v + j;
        }
        if (v < k+1)
        {
            otv +=1;
        }

    }
    cout << otv;

}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m,k, perem,otv = 0, j, v=0;
    vector<int> vec(m+1);
    cin >> n >> m >> k;
    for (int i = 0; i<m;i++)
    {
        cin >> vec[i];
    }
    cin >> vec[m +1];
    for (int i = 0; i<m;i++)
    {
        int v = 0;
        perem = vec[i]^vec[m+1];
        while (perem > 0)
        {
            j = perem % 2;
            perem /= 2;
            v = v + j;
        }
        if (v < k+1)
        {
            otv +=1;
        }

    }
    cout << otv;

}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int m, n, k, a;
    cin >> n;
    cin >> m;
    cin >> k;
    vector <int> vec(m + 1);
    for (int i = 0; i < vec.size(); i++)
    {
        cin >> vec[i];
    }
    for (int i = 0; i < m; i++)
    {
        n = 0;
        a = vec[m] ^ vec[i];
        while(a)
        {
            n+= a % 2;
            a = a / 2;
        }
        vec[i] = n;
    }
    a = 0;
    for (int i = 0; i < m; i++)
    {
        if (vec[i] <= k)
        {
            a++;
        }
    }
    cout << a;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m,k, perem,otv = 0, j, v=0;
    vector<int> vec(m+1);
    cin >> n >> m >> k;
    for (int i = 0; i<m-1;i++)
    {
        cin >> vec[i];
    }
    cin >> vec[m];
    for (int i = 0; i<m-1;i++)
    {
        int v = 0;
        perem = vec[i]^vec[m];
        while (perem > 0)
        {
            j = perem % 2;
            perem /= 2;
            v = v + j;
        }
        if (v < k+1)
        {
            otv +=1;
        }

    }
    cout << otv;

}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m,k, perem,otv = 0, j, v=0;
    vector<int> vec(m+1);
    cin >> n >> m >> k;
    for (int i = 0; i<m;i++)
    {
        cin >> vec[i];
    }
    cin >> vec[m];
    for (int i = 0; i<m-1;i++)
    {
        int v;
        perem = vec[i]^vec[m];
        while (perem > 0)
        {
            j = perem % 2;
            perem /= 2;
            v = v + j;
        }
        if (v < k+1)
        {
            otv +=1;
        }

    }
    cout << otv;

}


#include <bits/stdc++.h>

using namespace std;

int a[10000002];

int main() {
    ios::sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if((a[i] & (1 << j)) && (a[M] & (1 << j)))
                    cnt++;
        }
        if(N - cnt <= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[10000002];

int main() {
    ios::sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if(!((a[i] & (1 << j)) && (a[M] & (1 << j))))
                cnt++;
        }
        if(cnt <= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[1001];

int main() {
    ios::sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if((a[i] & (1 << j)) && (a[M] & (1 << j)))
                    cnt++;
        }
        if(N - cnt < K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[10000002];

int main() {
    ios::sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if(((a[i] & (1 << j)) ^ (a[M] & (1 << j))))
                cnt++;
        }
        if(cnt <= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[21];

int main() {
    ios::sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if((a[i] & (1 << j)) && (a[M] && (1 << j)))
                    cnt++;
        }
        if(N - cnt < K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[21];

int main() {
    ios::sync_with_stdio(false);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if((a[i] & (1 << j)) && (a[M] & (1 << j)))
                    cnt++;
        }
        if(N - cnt < K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[1001];

int main() {
    ios::sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i < M + 1; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if((a[i] & (1 << j)) && (a[M] & (1 << j)))
                    cnt++;
        }
        if(N - cnt <= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

string arr[1005];

string binary(unsigned x)
{
	string s;
    for (int i = sizeof(x) * CHAR_BIT; i--; )
    {
        s+='0' + ((x >> i) & 1);
    }
    return s;
}

int main() {

unsigned long long num;
int n,m,k,counter(0),ans(0);
string fedor,temp,str;
cin>>n>>m>>k;

for(int i=0; i<m+1; i++){
	cin>>num;
	str=binary(num);
	arr[i]=str;
	//cout<<str<<endl;
	}

// 1 2 4 8 16
	fedor=arr[m];
	for(int i=0; i<m; i++){
		temp=arr[i];
		counter=0;
		//cout<<temp[fedor.size()-1] <<" "<<temp[n]<<endl;
	 for(int j=fedor.size()-1; j>=n; j--){
		if(temp[j]!=fedor[j]) counter++;
		//cout<<temp[j]<<" "<<fedor[j]<<endl;
	}
	if(counter<=k) ans++;
	}
  cout<<ans;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

string arr[1005];

string binary(unsigned x)
{
	string s;
    for (int i = sizeof(x) * CHAR_BIT; i--; )
    {
        s+='0' + ((x >> i) & 1);
    }
    return s;
}

int main() {

unsigned long long num;
int n,m,k,counter(0),ans(0);
string fedor,temp,str;
cin>>n>>m>>k;

for(int i=0; i<m+1; i++){
	cin>>num;
	str=binary(num);
	arr[i]=str;
	cout<<str<<endl;
	}

// 1 2 4 8 16
	fedor=arr[m];
	for(int i=0; i<m; i++){
		temp=arr[i];
		counter=0;
	 for(int j=temp.size()-1; j>=n; j--){
		if(temp[j]!=fedor[j]) counter++;
		//cout<<temp[j]<<" "<<fedor[j]<<endl;
	}
	if(counter<=k) ans++;
	}
  cout<<ans;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

string arr[1005];

string binary(unsigned x)
{
	string s;
    for (int i = sizeof(x) * CHAR_BIT; i--; )
    {
        s+='0' + ((x >> i) & 1);
    }
    return s;
}

int main() {

unsigned num;
int n,m,k,counter(0),ans(0);
string fedor,str;
cin>>n>>m>>k;

for(int i=0; i<m+1; i++){
	cin>>num;
	str=binary(num);
	arr[i]=str;
	}

// 1 2 4 8 16
	fedor=arr[m];
	for(int i=0; i<m; i++){
		string temp=arr[i];
		counter=0;
	 for(int j=fedor.size()-1; j>=n; j--){
		if(temp[j]!=fedor[j]) counter++;
	}
	if(counter<=k) ans++;
	}
  cout<<ans;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

string arr[1005];

#include <string>

string binary(unsigned x)
{
	string s;
    for (int i = sizeof(x) * CHAR_BIT; i--; )
    {
        s+='0' + ((x >> i) & 1);
    }
    return s;
}

int main() {

unsigned long long num;
int n,m,k,counter(0),ans(0);
string fedor,temp,str;
cin>>n>>m>>k;

for(int i=0; i<m+1; i++){
	cin>>num;
	str=binary(num);
	arr[i]=str;
	}

// 1 2 4 8 16
	fedor=arr[m];
	for(int i=0; i<m; i++){
		temp=arr[i];
		counter=0;
	 for(int j=31; j>=n; j--){
		if(temp[j]!=fedor[j]) counter++;
		//cout<<temp[j]<<" "<<fedor[j]<<endl;
	}
	if(counter<=k) ans++;
	}
  cout<<ans;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

string arr[1005];

string binary(unsigned x)
{
	string s;
    for (int i = sizeof(x) * CHAR_BIT; i--; )
    {
        s+='0' + ((x >> i) & 1);
    }
    return s;
}

int main() {

unsigned long long num;
int n,m,k,counter(0),ans(0);
string fedor,temp,str;
cin>>n>>m>>k;

for(int i=0; i<m+1; i++){
	cin>>num;
	str=binary(num);
	arr[i]=str;
	//cout<<str<<endl;
	}

// 1 2 4 8 16
	fedor=arr[m];
	for(int i=0; i<m; i++){
		temp=arr[i];
		counter=0;
	 for(int j=temp.size()-1; j>=n; j--){
		if(temp[j]!=fedor[j]) counter++;
		//cout<<temp[j]<<" "<<fedor[j]<<endl;
	}
	if(counter<=k) ans++;
	}
  cout<<ans;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

string arr[1005];

string binary(unsigned x)
{
	string s;
    for (int i = sizeof(x) * CHAR_BIT; i--; )
    {
        s+='0' + ((x >> i) & 1);
    }
    return s;
}

int main() {

unsigned num;
int n,m,k,counter(0),ans(0),j,count(0);
string fedor,str;
cin>>n>>m>>k;

for(int i=0; i<m+1; i++){
	cin>>num;
	str=binary(num);
	arr[i]=str;
	}

// 1 2 4 8 16
	fedor=arr[m];
	for(int i=0; i<m; i++){
		string temp=arr[i];
		counter=0;
	 for( j=fedor.size()-1; j>((fedor.size()-1)-n); j--){
		if(temp[j]!=fedor[j]) counter++;
	}
	if(counter<=k) ans++;
	}
  cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , m , k , a , b=0 ,c=0, arr[10000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++){
        cin >> a;
        while(a != 0){
                if (a % 2 != 0){
                    b++;
                }
                a=a/2;
        }
        arr[i] = b; b=0;
    }
    for (int i=0; i<m; i++){
        if (abs(arr[m]+arr[i]) <= k){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , m , k , a=0 , c=0;
    string arm[1000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++) cin >> arm[i];

    for (int i=0; i<m; i++){ a=0;
       for (int f=0; f<arm[m].size(); f++){
         for (int y=0; y<arm[i].size(); y++){
            if (arm[m][f] != arm[i][y]) a++;
         }
        }
         if (a<=k) c++;
       }
     cout << c << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;
int main()
{
	int n, m, k, a, b = 0, c = 0, arr[10000];
	cin >> n >> m >> k;
	for (int i = 0; i <= m; i++){
		cin >> a;
		while (a != 0){
			if (a % 2 != 0){
				b++;
			}
			a = a / 2;
		}
		arr[i] = b; b = 0;
	}
	for (int i = 0; i<m; i++){
		if (abs(arr[m] - arr[i]) <= k){
			c++;
		}
	}
	cout << c << endl;
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , m , k , a , b=0 ,c=0, arr[10000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++){
        cin >> a;
        while(a != 0){
                if (a % 2 != 0){
                    b++;
                }
                a=a/2;
        }
        arr[i] = b;
    }
    for (int i=0; i<m; i++){
        if (arr[m]-arr[i] <= k){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , m , k , a=0 , c=0;
    string arm[1000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++) cin >> arm[i];

    for (int i=0; i<m; i++){ a=0;
       for (int f=0; f<arm[m].size(); f++){
         for (int y=0; y<arm[i].size(); y++){
            if (arm[m][f] != arm[i][y]) a++;
         }
        }
        cout << a << endl;
         if (a<=k) c++;
       }
     cout << c << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;
int main()
{
	int n, m, k, b, d = 0 , c = 0 , arr[100000];
	cin >> n >> m >> k;
	for (int i = 0; i <= m; i++){
		cin >> arr[i];
	}
	for (int i = 0; i < m; i++){
		c = 0;
		b = arr[m];
		while (arr[i] > 0 ||  b > 0){
			if (arr[i] % 2 != b % 2){
				c++;
			}
			else {
			}
				arr[i] = arr[i] / 2;
				b = b / 2;
		}
		if (c <= k){
			d++;
		}
	}
	cout << d << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , m , k , a=0 ;
    int arm[1000];
    cin >> n >> m >> k;
    for (int i=0;  i<=m; i++) cin >> arm[i];

    for (int i=0; i<m; i++){
       if (abs(arm[m]- arm[i]) <= k+n){
        a++;}
    }
     cout << a << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , m , k , a , b=0 ,c=0, arr[10000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++){
        cin >> a;
        while(a != 0){
                if (a % 2 != 0){
                    b++;
                }
                a=a/2;
        }
        arr[i] = b; b=0;
    }
    for (int i=0; i<m; i++){
        if (arr[m]-arr[i] <= k){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , m , k , a=0 , c=0;
    string arm[1000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++) cin >> arm[i];

    for (int i=0; i<m; i++){ a=0;
       for (int f=0; f<arm[m].size(); f++){
         for (int y=0; y<arm[i].size(); y++){
                if (arm[m][f] == '1' && arm[i][y] == '1')a++;
            else if (arm[m][f] != arm[i][y] && arm[m][f] != '1' && arm[i][y] != '1') a++;
         }
        }
         if (a<k) c++;
       }
     cout << c << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , m , k , a=0 ;
    int arm[1000];
    cin >> n >> m >> k;
    for (int i=0;  i<=m; i++) cin >> arm[i];

    for (int i=0; i<m; i++){
       if (abs(arm[m]- arm[i]) <= k){
        a++;}
    }
     cout << a << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , m , k , a , b=0 ,c=0, arr[10000];
    cin >> n >> m >> k;
    for (int i=0; i<=m; i++){
        cin >> a;
        while(a != 0){
                if (a % 2 != 0){
                    b++;
                }
                a=a/2;
        }
        arr[i] = b; b=0;
        cout << arr[i] << endl;
    }
    for (int i=0; i<m; i++){
        if (abs(arr[m]+arr[i]) <= k){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int sz[1001];
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1][21];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>x;
    int j = 0 ;
    while(x!=0)
    {
        arr[i][j]=x%2;

        x/=2;
        j++;
    }
    sz[i]=j;

}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{ int cntr=0;
    for(int j = 0 ; j <=min(sz[m],sz[i]);j++)
    {
        if(arr[i][j]==arr[m][j])
        {
            cntr++;
        }
    }
    if(max(sz[m],sz[i])-cntr<=k&&max(sz[m],sz[i])-cntr>=0)
    {
        fr++;
    }

}
cout<<fr;
    return 0 ;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int sz[1001];
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1][21];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>x;
    int j = 0 ;
    while(x!=0)
    {
        arr[i][j]=x%2;

        x/=2;
        j++;
    }
    sz[i]=j;
 if(j%2!=0)
 {
     for(int l = 0 ;  l<(j+1)/2 ; l++)
     {
         swap(arr[i][l],arr[i][j-1-l]);
     }
 }
 else{ for(int l = 0 ;  l<j/2 ; l++)
     {
         swap(arr[i][l],arr[i][j-1-l]);
     }}

}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{ int cntr=0;
    for(int j = 0 ; j <min(sz[m],sz[i]);j++)
    {
        if(arr[i][j]!=arr[m][j])
        {
            cntr++;
        }
    }
    if(max(sz[m],sz[i])-cntr<=k)
    {
        fr++;
    }

}
cout<<fr;
    return 0 ;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int sz[1001];
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1][21];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>x;
    int j = 0 ;
    while(x!=0)
    {
        arr[i][j]=x%2;

        x/=2;
        j++;
    }
    sz[i]=j;

}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{ int cntr=0;
    for(int j = 0 ; j <=min(sz[m],sz[i]);j++)
    {
        if(arr[i][j]!=arr[m][j])
        {
            cntr++;
        }
    }
    if(cntr<=k)
    {
        fr++;
    }

}
cout<<fr;
    return 0 ;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int sz[1001];
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1][21];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>x;
    int j = 0 ;
    while(x!=0)
    {
        arr[i][j]=x%2;

        x/=2;
        j++;
    }
    sz[i]=j;

}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{ int cntr=0;
    for(int j = 0 ; j <min(sz[m],sz[i]);j++)
    {
        if(arr[i][j]!=arr[m][j])
        {
            cntr++;
        }
    }
    if(cntr<=k)
    {
        fr++;
    }

}
cout<<fr;
    return 0 ;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int sz[1001];
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1][21];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>x;
    int j = 0 ;
    while(x!=0)
    {
        arr[i][j]=x%2;

        x/=2;
        j++;
    }
    sz[i]=j;

}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{ int cntr=0;
    for(int j = 0 ; j <min(sz[m],sz[i]);j++)
    {
        if(arr[i][j]==arr[m][j])
        {
            cntr++;
        }
    }
    if(max(sz[m],sz[i])-cntr<=k)
    {
        fr++;
    }

}
cout<<fr;
    return 0 ;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int sz[1001];
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1][21];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>x;
    int j = 0 ;
    while(x!=0)
    {
        arr[i][j]=x%2;

        x/=2;
        j++;
    }
    sz[i]=j;

}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{ int cntr=0;
    for(int j = 0 ; j <=min(sz[m],sz[i]);j++)
    {
        if(arr[i][j]==arr[m][j])
        {
            cntr++;
        }
    }
    if(max(sz[m],sz[i])-cntr<=k)
    {
        fr++;
    }

}
cout<<fr;
    return 0 ;
}


#include<bits/stdc++.h>
#define Enigma
using namespace std ;
int main()
{ Enigma
int n,m,k,x;
cin>>n>>m>>k ;
int arr[m+1];
for(int i = 0 ; i <m+1 ; i++)
{
    cin>>arr[i];
}
int fr=0 ;
for(int i=0 ; i<m ; i++)
{
  if(__builtin_popcount((arr[i]^arr[m]))<=k)
  {
      fr++;
  }
}
cout<<fr;
    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> v(m+2);
    for(int i=1;i<=m+1;i++)cin>>v[i];
   	int ttl=0,cnt=0;
   	int temp=v[m+1];
   	for(int i=1;i<m+1;i++){
   		temp=v[i]^v[m+1];
   		while(temp>0){
   			if(temp&1)cnt++;
   			temp>>=1;
   		}
   		if(cnt<=k)ttl++;
   		cnt=0;
   	}
   	cout<<ttl<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> v(m+2);
    for(int i=1;i<=m+1;i++)cin>>v[i];
   	int j=0,fed[21]={0},ttl=0,cnt=0,flag=0;
   	int temp=v[m+1];
   	while(temp>0){
   		fed[j]=((v[m+1])&(1<<j))!=0?1:0;
   		//cout<<fed[j]<<" ";
   		j++;
   		temp>>=1;
   	}
   	for(int i=1;i<m+1;i++){
   		j=0; cnt=0;
   		temp=v[i];
   		while(temp>0){
   			if(((v[i])&(1<<j))!=0?1:0!=fed[j])cnt++;
   			//cout<<cnt<<" ";
   			if(cnt>k){
   				flag=1;
   				temp=0;
   			}
   			j++;
   			temp>>=1;
   		}
   		if(flag==0)ttl++;
   		flag=0;
   	}
   	cout<<ttl<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(m+1),freq(1001,0);
    for(int i=0;i<m+1;i++)cin>>a[i];
    for(int i=0;i<m+1;i++){
        ll temp=a[i],j=0;
        while(temp>0){
            freq[j]+=(temp>>1)&1;
            temp=temp>>1;
            j++;
        }
    }
    ll cnt=0;
    for(int i=0;i<m+1;i++){
        if(freq[i]>k){
            cnt=0;
            break;}
        else{
            cnt+=freq[i];
        }
      // cout<<freq[i]<<" ";
    }
    cout<<cnt<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(m+1),freq(n+1,0),fm(n+1,0);
    for(int i=0;i<m+1;i++)cin>>a[i];
    for(int i=0;i<m;i++){
        ll temp=a[i],j=0;
        while(temp>0){
            freq[j]+=(temp>>1)&1;
            temp=temp>>1;
            j++;
        }
    }
    ll temp=a[m],j=0;
        while(temp>0){
            fm[j]+=(temp>>1)&1;
            temp=temp>>1;
            j++;
        }
    ll cnt=0;
    for(int i=0;i<m;i++){
            if(freq[i]){
                if(n-freq[i]>k)continue;
                cnt+=n-freq[i];
            }
            else if(freq[i]!=fm[i]){
                if(n>k)continue;
                cnt+=n-1;
            }

     //  cout<<cnt<<" ";
    }
    cout<<cnt<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> v(m+2);
    for(int i=1;i<=m+1;i++)cin>>v[i];
   	int j=0,fed[21]={0},ttl=0,cnt=0,flag=0,chck[21]={0};
   	int temp=v[m+1];
   	while(temp>0){
   		fed[j]=((v[m+1])&(1<<j))!=0?1:0;
   		//cout<<fed[j]<<" ";
   		j++;
   		temp>>=1;
   	}
   	for(int i=1;i<m+1;i++){
   		j=0; cnt=0;
   		temp=v[i];
   		while(temp>0){
   			chck[j]=((v[i])&(1<<j))!=0?1:0;
   			//cout<<x<<" "<<fed[j]<<"||";
   			//if(x!=fed[j])cnt++;
   			//cout<<x<<" "<<cnt;
   			j++;
   			temp>>=1;
   		}j=0;
   		while(j<21){
   			if(chck[j]!=fed[j])cnt++;
   			if(cnt>k){
   				j=21;
   				flag=1;
   			}
   			j++;
   		}
   		if(flag==0)ttl++;
   		flag=0;
   	}
   	cout<<ttl<<endl;
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    static long prefix[],dp[][];
    static int n,m,k;
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        n=input.scanInt();
        m=input.scanInt();
        k=input.scanInt();
        long arr[]=new long[n];
        dp=new long[5001][5001];
        prefix=new long[n];
        for(int i=0;i<n;i++) {
            arr[i]=input.scanInt();
        }
        prefix[0]=arr[0];
        for(int i=1;i<n;i++) {
            prefix[i]=prefix[i-1]+arr[i];
        }
        for(int i=0;i<5001;i++) {
            for(int j=0;j<5001;j++) {
                dp[i][j]=-1L;
            }
        }
        System.out.println(solve(0,0));
    }
    public static long solve(int indx,int strt) {
        if(indx==k) {
            return 0;
        }
        if(strt==n) {
            return Integer.MIN_VALUE;
        }
        if(dp[indx][strt]!=-1) {
            return dp[indx][strt];
        }
        long max=0;
        max=Math.max(max,solve(indx,strt+1));
        max=Math.max(max,solve(indx+1,strt+m)+range_sum(strt,strt+m-1));
        dp[indx][strt]=max;
        return max;
    }
    public static long range_sum(int l,int r) {
        if(r==0 || l==0) {
            return prefix[r];
        }
        return prefix[r]-prefix[l-1];
    }
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    static long prefix[],dp[][];
    static int n,m,k;
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        n=input.scanInt();
        m=input.scanInt();
        k=input.scanInt();
        long arr[]=new long[n];
        dp=new long[5001][5001];
        prefix=new long[n];
        for(int i=0;i<n;i++) {
            arr[i]=input.scanInt();
        }
        prefix[0]=arr[0];
        for(int i=1;i<n;i++) {
            prefix[i]=prefix[i-1]+arr[i];
        }
        for(int i=0;i<5001;i++) {
            for(int j=0;j<5001;j++) {
                dp[i][j]=-1L;
            }
        }
        System.out.println(solve(0,0));
    }
    public static long solve(int indx,int strt) {
        if(indx==k) {
            return 0;
        }
        if(dp[indx][strt]!=-1) {
            return dp[indx][strt];
        }
        long max=0;
        for(int i=strt;i+m-1<n-((k-indx-1)*m);i++) {
            max=Math.max(max,solve(indx+1,i+m)+range_sum(i,i+m-1));
        }
        dp[indx][strt]=max;
        return max;
    }
    public static long range_sum(int l,int r) {
        if(r==0 || l==0) {
            return prefix[r];
        }
        return prefix[r]-prefix[l-1];
    }
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    static long prefix[],dp[][];
    static int n,m,k;
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        n=input.scanInt();
        m=input.scanInt();
        k=input.scanInt();
        long arr[]=new long[n];
        dp=new long[5001][5001];
        prefix=new long[n];
        for(int i=0;i<n;i++) {
            arr[i]=input.scanInt();
        }
        prefix[0]=arr[0];
        for(int i=1;i<n;i++) {
            prefix[i]=prefix[i-1]+arr[i];
        }
        for(int i=0;i<5001;i++) {
            for(int j=0;j<5001;j++) {
                dp[i][j]=-1L;
            }
        }
        System.out.println(solve(0,0));
    }
    public static long solve(int indx,int strt) {
        if(indx==k) {
            return 0;
        }
        if(dp[indx][strt]!=-1) {
            return dp[indx][strt];
        }
        long max=0;
        for(int i=strt;i+m-1<n-(k-indx)+1;i++) {
            max=Math.max(max,solve(indx+1,i+m)+range_sum(i,i+m-1));
        }
        dp[indx][strt]=max;
        return max;
    }
    public static long range_sum(int l,int r) {
        if(r==0 || l==0) {
            return prefix[r];
        }
        return prefix[r]-prefix[l-1];
    }
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    static long prefix[],dp[][];
    static int n,m,k;
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        n=input.scanInt();
        m=input.scanInt();
        k=input.scanInt();
        long arr[]=new long[n];
        dp=new long[5001][5001];
        prefix=new long[n];
        for(int i=0;i<n;i++) {
            arr[i]=input.scanInt();
        }
        prefix[0]=arr[0];
        for(int i=1;i<n;i++) {
            prefix[i]=prefix[i-1]+arr[i];
        }
        for(int i=0;i<5001;i++) {
            for(int j=0;j<5001;j++) {
                dp[i][j]=-1L;
            }
        }
        System.out.println(solve(0,0));
    }
    public static long solve(int indx,int strt) {
        if(indx==k) {
            return 0;
        }
        if(strt+m-1>=n) {
            return Integer.MIN_VALUE;
        }
        if(dp[indx][strt]!=-1) {
            return dp[indx][strt];
        }
        long max=0;
        max=Math.max(max,solve(indx,strt+1));
        max=Math.max(max,solve(indx+1,strt+m)+range_sum(strt,strt+m-1));
        dp[indx][strt]=max;
        return max;
    }
    public static long range_sum(int l,int r) {
        if(r==0 || l==0) {
            return prefix[r];
        }
        return prefix[r]-prefix[l-1];
    }
}