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

// Driver program to read from file/System.in and increase stack size
public class Main implements Runnable {

  private final InputReader in;
  private final OutputWriter out;

  private Main(InputReader ir, OutputWriter or) {
    in = ir;
    out = or;
  }

  public static void main(String[] args) throws Exception {
    InputStream is = args.length > 0 ? new FileInputStream(args[0]) : System.in;
    InputReader in = new InputReader(is);
    OutputWriter out = new OutputWriter(System.out);
    Main r = new Main(in, out);
    new Thread(null, r, "Main", 1 << 26).start(); // 64 mb stack size
  }

  @Override
  public void run() {
    try {
      Solution.main(in, out);
    } finally {
      out.close();
    }
  }
}

// Fast I/O
// Taken and modified from here:
// https://www.quora.com/What-is-the-best-way-in-Java-to-take-input-and-write-output-for-an-Online-Judge
class InputReader {

  private InputStream is;
  private byte[] buff = new byte[8 * 1024];
  private int curChar;
  private int numChars;

  InputReader(InputStream is) {
    this.is = is;
  }

  int read() {
    if (numChars == -1) {
      throw new InputMismatchException();
    }
    if (curChar >= numChars) {
      curChar = 0;
      try {
        numChars = is.read(buff);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (numChars <= 0) {
        return -1;
      }
    }
    return buff[curChar++];
  }

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

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

  double nextDouble() {
    int c = read();
    while (isSpaceChar(c)) {
      c = read();
    }
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    double res = 0;
    while (!isSpaceChar(c) && c != '.') {
      if (c == 'e' || c == 'E') {
        return res * Math.pow(10, nextInt());
      }
      if (c < '0' || c > '9') {
        throw new InputMismatchException();
      }
      res *= 10;
      res += c - '0';
      c = read();
    }
    if (c == '.') {
      c = read();
      double m = 1;
      while (!isSpaceChar(c)) {
        if (c == 'e' || c == 'E') {
          return res * Math.pow(10, nextInt());
        }
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        m /= 10;
        res += (c - '0') * m;
        c = read();
      }
    }
    return res * sgn;
  }

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

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

  String next() {
    return nextString();
  }

  int[] nextIntArray(int size) {
    int[] arr = new int[size];
    for (int i = 0; i < size; i++) {
      arr[i] = nextInt();
    }
    return arr;
  }
}

class OutputWriter {

  private final PrintWriter writer;

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

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

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

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

  void printf(String format, Object... objects) {
    writer.printf(format, objects);
  }

  void printfln(String format, Object... objects) {
    writer.printf(format + "\n", objects);
  }

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

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

class Solution {

  static void main(InputReader in, OutputWriter out) {
    int n = in.nextInt();
    int b = in.nextInt();
    int[] a = in.nextIntArray(n);

    int[] odd = new int[n - 1]; // right
    odd[0] = a[0] % 2;
    for (int i = 1; i < n - 1; i++) {
      odd[i] = odd[i - 1] + a[i] % 2;
    }

    List<Integer> cuts = new ArrayList<>(n - 1);
    for (int i = 1; i < n - 2; i += 2) {
      if (odd[i] == (i + 1) / 2) {
        cuts.add(Math.abs(a[i] - a[i + 1]));
      }
    }
    cuts.sort(Comparator.naturalOrder());

    int ans = 0;
    for (int cut : cuts) {
      if (cut > b) {
        break;
      }
      ans++;
      b -= cut;
    }
    out.println(ans);
  }
}

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

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),b=Integer.parseInt(s[1]);
        int i,x=0,a[]=new int[n],l[]=new int[n];
        s=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        {
            a[i]=Integer.parseInt(s[i]);
            if(a[i]%2==0) x++;
            else x--;
            l[i]=x;
        }
        ArrayList<Integer> al=new ArrayList<>();
        for(i=0;i<n-1;i++)
        if(l[i]==0) al.add(Math.abs(a[i]-a[i+1]));
        Collections.sort(al);

        int cuts=0,cr=0;
        for(i=0;i<al.size();i++)
        {
            if(cr+al.get(i)<=b) {cr+=al.get(i); cuts++;}
            if(cr>=b) break;
        }
        System.out.print(cuts);
    }
}

import java.util.*;

public class acm1 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n, b;
        n = sc.nextInt();
        b = sc.nextInt();
        ArrayList<Integer> cuts = new ArrayList<Integer>();
        int arr[];
        arr = new int[n];
        int even = 0, odd = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (i != 0 && even == odd) {
                cuts.add(Math.abs(arr[i] - arr[i - 1]));

            }
            if (arr[i] % 2 == 0) {
                even++;
            } else {
                odd++;
            }

        }
        Collections.sort(cuts);
        int count = 0;
        for (int i = 0; i < cuts.size(); i++) {

            if (cuts.get(i) <= b) {
                count++;
                b -= cuts.get(i);
            }
        }
        System.out.println(count);

    }

}

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

public class Task7 {
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next() {
            while (st == null || !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());
        }

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

    }

    public static void main(String[] args) {
        FastScanner in = new FastScanner(System.in);
        //Enter code here utkarsh
        //SHOW_TIME = true;
        int n =in.nextInt();
        int B = in.nextInt();

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

        int even = 0, odd = 0;
        ArrayList <Integer> dp = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            if(a[i]%2 == 0) even++;
            else    odd++;
            if(even == odd && i < n-1) dp.add(Math.abs(a[i] - a[i+1]));
        }
        Collections.sort(dp);
        int ans = 0;
        for(int x : dp) {
            if(B < x)   break;
            ans++;
            B -= x;
        }
        System.out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class q4 {
	static int x[];
	static int k;
	static int INF = (int) 1e9;
    static ArrayList<Integer> ar;
	static int memo [][][];
	static int bt(int cost, int even, int odd, int idx,int f) {

		if(idx==x.length) {
			if(odd==even)
				return 0;
			return -INF;
		}
		if(memo[cost][even][idx]!=-1)
			return memo[cost][even][idx];

		if(f==0) {
			int ans =0;
			if(x[idx]%2==0)
			 ans=Math.max(ans, bt( cost, even+1, odd,  idx+1,1));
			else
			  ans=	Math.max(ans, bt( cost, even, odd+1,  idx+1,1));
		   return memo[cost][even][idx]=ans;
		}

		int ans = 0;
		//contiue
		if(x[idx]%2==0)
		   ans=Math.max(ans	,bt( cost, even+1, odd,  idx+1,1));
		else
			 ans=Math.max(ans,bt( cost, even, odd+1,  idx+1,1));

		//cut
		if(cost+Math.abs(x[idx]-x[idx-1])<=k&&even==odd&&even!=0) {
			if(x[idx]%2==0)
			ans=Math.max(ans,1+bt( cost+Math.abs(x[idx]-x[idx-1]), 1, 0,  idx+1,0));
			else
				ans=Math.max(ans,1+bt( cost+Math.abs(x[idx]-x[idx-1]), 0, 1,  idx+1,0));
		}
		return  memo[cost][even][idx]=ans;

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		k = sc.nextInt();
		x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();
         memo = new int [k+1][n+1][n+1];
        for(int u=0;u<k+1;u++)
         for(int i=0;i<n+1;i++)
        		 Arrays.fill(memo[u][i], -1);
		System.out.println(bt(0, 0, 0, 0, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public long nextlong() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			long res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

/**
 * Author: Rohan Arora(codiinggeek)
 */
import java.io.*;
import java.util.*;

public class forces {
    static long mod = (long) Math.pow(10, 9) + 7;

    public static void main(String[] args) {
        try {
            FastReader s = new FastReader();
            StringBuilder sb = new StringBuilder();

            int n = s.nextInt();
            int B = s.nextInt();

            int ar[] = new int[n];

            int odd[] = new int[n];
            int even[] = new int[n];

            int o=0,e=0;
            for(int i=0;i<n;i++){
                ar[i] = s.nextInt();
                if(ar[i]%2==0){
                    e++;
                }else{
                    o++;
                }
                even[i] = e;
                odd[i] = o;
            }
            ArrayList<Integer> al = new ArrayList<>();
            for(int i=0;i<n-1;i++) {
                if (odd[i] == even[i]) {
                    al.add(Math.abs(ar[i] - ar[i + 1]));
                }
            }
            Collections.sort(al);
            int y=0;
            for(int i=0;i<al.size();i++){
                int aa = al.get(i);
                if(B-aa>=0){
                    y++;
                    B -= aa;
                }else{
                    break;
                }
            }
            System.out.println(y);

        } catch (Exception e) {
            System.out.println(e);
            return;
        }
    }
    /**Check Prime*/
    public static boolean checkPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;

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

        return true;
    }
    /**Euclidean GCD*/
    static long gcd(long a, long b){
        if(a==0)
            return b;
        return gcd(b%a, a);
    }

    /**POWER CALCULATION FOR LARGE VALUES*/
    static long expo(long b, long ex) {
        long t = 1L;
        while (ex > 0) {

            if (ex % 2 != 0)
                t = (t * b) % mod;

            b = (b * b) % mod;
            ex /= 2;
        }
        return t % mod;
    }

    /**Pair class */
    class Pair<U, V> {
        U first;
        V second;

        Pair(U a, V b) {
            first = a;
            second = b;
        }
    }
/**---------------------------------------------------------------------------------*/
    /** FAST I/O */
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

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

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

import java.util.*;

public class B_cutting_solu {

    static ArrayList<Integer> a = new ArrayList<>();
    static ArrayList<Integer> b = new ArrayList<>();

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int numOfElements = in.nextInt(), Bitcoins = in.nextInt(), even = 0, odd = 0;

        for (int i = 0; i < numOfElements; i++) {
            a.add(in.nextInt());
            if (i != 0 && even == odd) {

                b.add(Math.abs(a.get(i) - a.get(i - 1)));

            }
            if (a.get(i) % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }

        int coc = 0;
        Collections.sort(b);
        for (int i = 0; i < b.size(); i++) {
            if (b.get(i) <= Bitcoins) {
                coc++;
                Bitcoins -= b.get(i);

            } else {
                break;
            }

        }

        System.out.println(coc);

    }

}

//package compete;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.security.acl.LastOwnerException;
import java.util.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

  static class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new
          InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        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());
    }

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

    String[] nextSArray() {
      String sr[] = null;
      try {
        sr = br.readLine().trim().split(" ");
      } catch (IOException e) {
        e.printStackTrace();
      }
      return sr;
    }

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

      return str;
    }
  }
  //static  ArrayList<Integer>al=new ArrayList<>()

//
    static class Pair{
      char ch;
      int count;
      Pair(char ch,int count){
        this.ch=ch;
        this.count=count;
      }
      Pair(){}
    }
    static long q=1000000007;
    static int MAX=Integer.MAX_VALUE,MIN=Integer.MIN_VALUE;
	public static void main(String[] args) throws Exception{
        FastReader sc=new FastReader();
        int n=sc.nextInt(),s=sc.nextInt();
        int dp[][]=new int[n+1][s+1];
        int arr[]=new int[n];
        for(int i=0;i<n;i++) arr[i]=sc.nextInt();
        int odd=0,even=0;
        boolean p[]=new boolean[n];
        for(int i=n-1;i>=0;i--){
          if((odd==even) && odd>0) p[i]=true;
          if((arr[i]&1)==0) even++;
          else odd++;
        }
        if(odd!=even) out.println(0);
        else{
          for(int i=1;i<n+1;i++)
          for(int j=1;j<s+1;j++){
            dp[i][j]=dp[i-1][j];
            if(p[i-1]){
              int temp=j-Math.abs(arr[i-1]-arr[i]);
              if(temp>=0) dp[i][j]=Math.max(dp[i][j],1+dp[i-1][temp]);
            }
          }
          out.println(dp[n][s]);
        }
        out.close();
      }
}

import java.util.*;
import java.lang.*;
import java.io.*;
 public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int b=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextInt();
	    int odd=0;
	    int even=0;
	    int diff=0;
	    int cuts=0;
	    ArrayList<Integer> al=new ArrayList<>();
	    for(int i=0;i<n;i++) {
	        if(a[i]%2==0)
	        even++;
	        else
	        odd++;
	        if(even==odd && i!=n-1)
	        {
	            diff=Math.abs(a[i]-a[i+1]);
	            al.add(diff);
	        }
	    }
	    Collections.sort(al);
	    for(Integer e:al) {
	        if(e<=b) {
	        b=b-e;
	        cuts++;
	        }

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Solution implements Runnable {

	static final double time = 1e9;
	static final int MOD = (int) 1e9 + 7;
	static final long mh = Long.MAX_VALUE;
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	StringBuilder answer = new StringBuilder();

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

	@Override
	public void run() {
		long start = System.nanoTime();
		solve();
		printf();
		long elapsed = System.nanoTime() - start;
//		out.println("stamp : " + elapsed / time);
//		out.println("stamp : " + TimeUnit.SECONDS.convert(elapsed, TimeUnit.NANOSECONDS));
		close();
	}

	void solve() {
		int n = in.nextInt(), x = in.nextInt();
		int[] a = new int[n + 1];
		for (int i = 1; i <= n; i++) a[i] = in.nextInt();
		a[0] = a[1];
		int[][] f = new int[n + 1][x + 1];

		for (int i = 2; i <= n; i += 2) {
			int even = a[i] % 2 == 0 ? 1 : 0;
			for (int j = i - 1; j > 0; j--) {
				if (a[j] % 2 == 0) even++;
				if (even * 2 == i - j + 1) {
					int d = Math.abs(a[j] - a[j - 1]);
					for (int k = 0; k <= x; k++)
						if (d <= k && j > 1)
							f[i][k] = Math.max(f[j - 1][k - d] + 1, f[i][k]);
				}
			}
		}
//		printf(f);
		printf(f[n][x]);
  	}

	public interface Hash {
		public void computeHashArray();
		public void computeModArray();

	}

	class StringHash implements Hash {
		// length of string s
		private final long MH = Long.MAX_VALUE;
		private int n;
		private char[] ch;
		private long[] hash, mod;
		StringHash(char[] ch) {
			this.ch = ch;
			n = ch.length;
			hash = new long[n + 1];
			mod = new long[n + 1];
			computeHashArray();
			computeModArray();
		}

		StringHash(String s) {
			this(s.toCharArray());
		}

		StringHash(CharSequence s) {
			this(s.toString());
		}

		@Override
		public void computeModArray() {
			mod[0] = 1;
			for (int i = 1; i <= n; i++) mod[i] = (mod[i - 1] * 53) % MH;
		}

		@Override
		public void computeHashArray() {
			for (int i = 0; i < n; i++) hash[i + 1] = (hash[i] * 53 + ch[i] - 'a') % MH;
		}

		public long getHash(int i, int j) {
			return (hash[j] - hash[i] * mod[j - i] + MH * MH) % MH;
		}

		public long getHash(String s) {
			long h = 0;
			for (int i = 0; i < s.length(); i++) h = (h * 53 + s.charAt(i) - 'a') % MH;
			return h;
		}

		public long[] getHashArray() { return hash; }
		public long[] getModArray() { return mod; }
	}

	public interface Manacher {
		public void oddPalindrome();
		public void evenPalindrome();
	}

	class Palindrome implements Manacher {
		private int n;
		private char[] ch;
		private int[] oddPal, evenPal;
		public Palindrome() {}
		public Palindrome(String s) {
			this(s.toCharArray());
		}
		public Palindrome(char[] ch) {
			this.ch = ch;
			n = ch.length;
			oddPal = new int[ch.length];
			evenPal = new int[ch.length];
			oddPalindrome();
			evenPalindrome();
		}

		@Override
		public void oddPalindrome() {
			for (int i = 0, l = 0, r = -1; i < n; i++) {
				int k = i > r ? 1 : Math.min(oddPal[r + l - i], r - i);
				while (0 <= i - k && i + k < n && ch[i - k] == ch[i + k]) k++;
				oddPal[i] = k--;
				if (i + k > r) {
					l = i - k;
					r = i + k;
				}
			}
		}
		@Override
		public void evenPalindrome() {
			for (int i = 0, l = 0, r = -1; i < n; i++) {
				int k = i > r ? 0 : Math.min(evenPal[r + l - i + 1], r - i + 1);
				while (0 <= i - k - 1 && i + k < n && ch[i - k - 1] == ch[i + k]) k++;
				evenPal[i] = k--;
				if (i + k > r) {
					l = i - k - 1;
					r = i + k;
				}
			}
		}
	}

	void printf() {
		out.print(answer);
	}

	void close() {
		out.close();
	}

	void printf(Stream<?> str) {
		str.forEach(o -> add(o, " "));
		add("\n");
	}

	void printf(Object... obj) {
		printf(false, obj);
	}

	void printfWithDescription(Object... obj) {
		printf(true, obj);
	}

	private void printf(boolean b, Object... obj) {

		if (obj.length > 1) {
			for (int i = 0; i < obj.length; i++) {
				if (b) add(obj[i].getClass().getSimpleName(), " - ");
				if (obj[i] instanceof Collection<?>) {
					printf((Collection<?>) obj[i]);
				} else if (obj[i] instanceof int[][]) {
					printf((int[][])obj[i]);
				} else if (obj[i] instanceof long[][]) {
					printf((long[][])obj[i]);
				} else if (obj[i] instanceof double[][]) {
					printf((double[][])obj[i]);
				} else printf(obj[i]);
			}
			return;
		}

		if (b) add(obj[0].getClass().getSimpleName(), " - ");
		printf(obj[0]);
	}

	void printf(Object o) {
		if (o instanceof int[])
			printf(Arrays.stream((int[]) o).boxed());
		else if (o instanceof char[])
			printf(new String((char[]) o));
		else if (o instanceof long[])
			printf(Arrays.stream((long[]) o).boxed());
		else if (o instanceof double[])
			printf(Arrays.stream((double[]) o).boxed());
		else if (o instanceof boolean[]) {
			for (boolean b : (boolean[]) o) add(b, " ");
			add("\n");
		}
		else
			add(o, "\n");
	}

	void printf(int[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(long[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(double[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(boolean[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(Collection<?> col) {
		printf(col.stream());
	}

	<T, K> void add(T t, K k) {
		if (t instanceof Collection<?>) {
			((Collection<?>) t).forEach(i -> add(i, " "));
		} else if (t instanceof Object[]) {
			Arrays.stream((Object[]) t).forEach(i -> add(i, " "));
		} else
			add(t);
		add(k);
	}

	<T> void add(T t) {
		answer.append(t);
	}

	@SuppressWarnings("unchecked")
	<T extends Comparable<? super T>> T min(T... t) {
		if (t.length == 0)
			return null;
		T m = t[0];
		for (int i = 1; i < t.length; i++)
			if (t[i].compareTo(m) < 0)
				m = t[i];
		return m;
	}

	@SuppressWarnings("unchecked")
	<T extends Comparable<? super T>> T max(T... t) {
		if (t.length == 0)
			return null;
		T m = t[0];
		for (int i = 1; i < t.length; i++)
			if (t[i].compareTo(m) > 0)
				m = t[i];
		return m;
	}

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

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

	// c = gcd(a, b) -> extends gcd method: ax + by = c <----> (b % a)p + q = c;
	int[] ext_gcd(int a, int b) {
		if (b == 0) return new int[] {a, 1, 0 };
		int[] vals = ext_gcd(b, a % b);
		int d = vals[0]; // gcd
	    int p = vals[2]; //
		int q = vals[1] - (a / b) * vals[2];
		return new int[] { d, p, q };
	}

	// find any solution of the equation: ax + by = c using extends gcd
	boolean find_any_solution(int a, int b, int c, int[] root) {
		int[] vals = ext_gcd(Math.abs(a), Math.abs(b));
		if (c % vals[0] != 0) return false;
		printf(vals);
		root[0] = c * vals[1] / vals[0];
		root[1] = c * vals[2] / vals[0];
		if (a < 0) root[0] *= -1;
		if (b < 0) root[1] *= -1;
		return true;
	}

	int mod(int x) { return x % MOD; }

	int mod(int x, int y) { return mod(mod(x) + mod(y)); }

	long mod(long x) { return x % MOD; }

	long mod (long x, long y) { return mod(mod(x) + mod(y)); }

	int lw(long[] f, int l, int r, long k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] >= k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int up(long[] f, int l, int r, long k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] > k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int lw(int[] f, int l, int r, int k) {
//		int R = r, m = 0;
		while (l <= r) {
			int m = l + r >> 1;
//		    if (m == R) return m;
		    if (f[m] >= k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int up(int[] f, int l, int r, int k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] > k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	long calc(int base, int exponent) {
		if (exponent == 0) return 1;
		long m = calc(base, exponent >> 1);
		if (exponent % 2 == 0) return m * m % MOD;
		return base * m * m % MOD;
	}

	long power(int base, int exponent) {
		if (exponent == 0) return 1;
		long m = power(base, exponent >> 1);
		if (exponent % 2 == 0) return m * m;
		return base * m * m;
	}

	void swap(int[] a, int i, int j) {
		a[i] ^= a[j];
		a[j] ^= a[i];
		a[i] ^= a[j];
	}

	void swap(long[] a, int i, int j) {
		long tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}

	static class Pair<K extends Comparable<? super K>, V extends Comparable<? super V>>
			implements Comparable<Pair<K, V>> {
		private K k;
		private V v;

		Pair() {}

		Pair(K k, V v) {
			this.k = k;
			this.v = v;
		}

		K getK() { return k; }

		V getV() { return v; }

		void setK(K k) { this.k = k; }

		void setV(V v) { this.v = v; }

		void setKV(K k, V v) {
			this.k = k;
			this.v = v;
		}

		@SuppressWarnings("unchecked")
		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof Pair)) return false;
			Pair<K, V> p = (Pair<K, V>) o;
			return k.compareTo(p.k) == 0 && v.compareTo(p.v) == 0;
		}

		@Override
		public int hashCode() {
			int hash = 31;
			hash = hash * 89 + k.hashCode();
			hash = hash * 89 + v.hashCode();
			return hash;
		}

		@Override
		public int compareTo(Pair<K, V> pair) {
			return k.compareTo(pair.k) == 0 ? v.compareTo(pair.v) : k.compareTo(pair.k);
		}

		@Override
		public Pair<K, V> clone() {
			return new Pair<K, V>(this.k, this.v);
		}

		@Override
		public String toString() {
			return String.valueOf(k).concat(" ").concat(String.valueOf(v)).concat("\n");
		}
	}

	static class Reader {
		private BufferedReader br;
		private StringTokenizer st;

		Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int btcAmount = sc.nextInt();
        int[] btcCosts = new int[100];
        int even = 0, odd = 0;
        int right = 0;
        for (int i = 0; i < n; i++) {
            int left = 0;
            if (right == 0) {
                left = sc.nextInt();
            } else {
                left = right;
                right = 0;
            }
            if (left % 2 == 0) even++;
            else odd++;
            if (even == odd && i != n - 1) {
                right = sc.nextInt();
                int btcCost = Math.abs(left - right);
                btcCosts[btcCost] += 1;
                even = 0;
                odd = 0;
            }
        }
        int sawedAmount = 0;
        int currentBTCCost = 0;
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < btcCosts[i]; j++) {
                currentBTCCost += i;
                if (currentBTCCost <= btcAmount) {
                    sawedAmount++;
                } else break;
            }
        }
        System.out.println(sawedAmount);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Solution implements Runnable {

	static final double time = 1e9;
	static final int MOD = (int) 1e9 + 7;
	static final long mh = Long.MAX_VALUE;
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	StringBuilder answer = new StringBuilder();

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

	@Override
	public void run() {
		long start = System.nanoTime();
		solve();
		printf();
		long elapsed = System.nanoTime() - start;
//		out.println("stamp : " + elapsed / time);
//		out.println("stamp : " + TimeUnit.SECONDS.convert(elapsed, TimeUnit.NANOSECONDS));
		close();
	}

	void solve() {
		int n = in.nextInt(), x = in.nextInt();
		int[] a = new int[n + 1];
		for (int i = 1; i <= n; i++) a[i] = in.nextInt();
		a[0] = a[1];
		int[][] f = new int[n + 1][x + 1];

		for (int i = 2; i <= n; i += 2) {
			int even = a[i] % 2 == 0 ? 1 : 0;
			for (int j = i - 1; j > 1; j--) {
				if (a[j] % 2 == 0) even++;
				if (even * 2 == i - j + 1) {
					int d = Math.abs(a[j] - a[j - 1]);
					for (int k = 0; k <= x; k++)
						if (d <= k)
							f[i][k] = Math.max(f[j - 1][k - d] + 1, f[i][k]);
				}
			}
		}
//		printf(f);
		printf(f[n][x]);
  	}

	public interface Hash {
		public void computeHashArray();
		public void computeModArray();

	}

	class StringHash implements Hash {
		// length of string s
		private final long MH = Long.MAX_VALUE;
		private int n;
		private char[] ch;
		private long[] hash, mod;
		StringHash(char[] ch) {
			this.ch = ch;
			n = ch.length;
			hash = new long[n + 1];
			mod = new long[n + 1];
			computeHashArray();
			computeModArray();
		}

		StringHash(String s) {
			this(s.toCharArray());
		}

		StringHash(CharSequence s) {
			this(s.toString());
		}

		@Override
		public void computeModArray() {
			mod[0] = 1;
			for (int i = 1; i <= n; i++) mod[i] = (mod[i - 1] * 53) % MH;
		}

		@Override
		public void computeHashArray() {
			for (int i = 0; i < n; i++) hash[i + 1] = (hash[i] * 53 + ch[i] - 'a') % MH;
		}

		public long getHash(int i, int j) {
			return (hash[j] - hash[i] * mod[j - i] + MH * MH) % MH;
		}

		public long getHash(String s) {
			long h = 0;
			for (int i = 0; i < s.length(); i++) h = (h * 53 + s.charAt(i) - 'a') % MH;
			return h;
		}

		public long[] getHashArray() { return hash; }
		public long[] getModArray() { return mod; }
	}

	public interface Manacher {
		public void oddPalindrome();
		public void evenPalindrome();
	}

	class Palindrome implements Manacher {
		private int n;
		private char[] ch;
		private int[] oddPal, evenPal;
		public Palindrome() {}
		public Palindrome(String s) {
			this(s.toCharArray());
		}
		public Palindrome(char[] ch) {
			this.ch = ch;
			n = ch.length;
			oddPal = new int[ch.length];
			evenPal = new int[ch.length];
			oddPalindrome();
			evenPalindrome();
		}

		@Override
		public void oddPalindrome() {
			for (int i = 0, l = 0, r = -1; i < n; i++) {
				int k = i > r ? 1 : Math.min(oddPal[r + l - i], r - i);
				while (0 <= i - k && i + k < n && ch[i - k] == ch[i + k]) k++;
				oddPal[i] = k--;
				if (i + k > r) {
					l = i - k;
					r = i + k;
				}
			}
		}
		@Override
		public void evenPalindrome() {
			for (int i = 0, l = 0, r = -1; i < n; i++) {
				int k = i > r ? 0 : Math.min(evenPal[r + l - i + 1], r - i + 1);
				while (0 <= i - k - 1 && i + k < n && ch[i - k - 1] == ch[i + k]) k++;
				evenPal[i] = k--;
				if (i + k > r) {
					l = i - k - 1;
					r = i + k;
				}
			}
		}
	}

	void printf() {
		out.print(answer);
	}

	void close() {
		out.close();
	}

	void printf(Stream<?> str) {
		str.forEach(o -> add(o, " "));
		add("\n");
	}

	void printf(Object... obj) {
		printf(false, obj);
	}

	void printfWithDescription(Object... obj) {
		printf(true, obj);
	}

	private void printf(boolean b, Object... obj) {

		if (obj.length > 1) {
			for (int i = 0; i < obj.length; i++) {
				if (b) add(obj[i].getClass().getSimpleName(), " - ");
				if (obj[i] instanceof Collection<?>) {
					printf((Collection<?>) obj[i]);
				} else if (obj[i] instanceof int[][]) {
					printf((int[][])obj[i]);
				} else if (obj[i] instanceof long[][]) {
					printf((long[][])obj[i]);
				} else if (obj[i] instanceof double[][]) {
					printf((double[][])obj[i]);
				} else printf(obj[i]);
			}
			return;
		}

		if (b) add(obj[0].getClass().getSimpleName(), " - ");
		printf(obj[0]);
	}

	void printf(Object o) {
		if (o instanceof int[])
			printf(Arrays.stream((int[]) o).boxed());
		else if (o instanceof char[])
			printf(new String((char[]) o));
		else if (o instanceof long[])
			printf(Arrays.stream((long[]) o).boxed());
		else if (o instanceof double[])
			printf(Arrays.stream((double[]) o).boxed());
		else if (o instanceof boolean[]) {
			for (boolean b : (boolean[]) o) add(b, " ");
			add("\n");
		}
		else
			add(o, "\n");
	}

	void printf(int[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(long[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(double[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(boolean[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(Collection<?> col) {
		printf(col.stream());
	}

	<T, K> void add(T t, K k) {
		if (t instanceof Collection<?>) {
			((Collection<?>) t).forEach(i -> add(i, " "));
		} else if (t instanceof Object[]) {
			Arrays.stream((Object[]) t).forEach(i -> add(i, " "));
		} else
			add(t);
		add(k);
	}

	<T> void add(T t) {
		answer.append(t);
	}

	@SuppressWarnings("unchecked")
	<T extends Comparable<? super T>> T min(T... t) {
		if (t.length == 0)
			return null;
		T m = t[0];
		for (int i = 1; i < t.length; i++)
			if (t[i].compareTo(m) < 0)
				m = t[i];
		return m;
	}

	@SuppressWarnings("unchecked")
	<T extends Comparable<? super T>> T max(T... t) {
		if (t.length == 0)
			return null;
		T m = t[0];
		for (int i = 1; i < t.length; i++)
			if (t[i].compareTo(m) > 0)
				m = t[i];
		return m;
	}

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

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

	// c = gcd(a, b) -> extends gcd method: ax + by = c <----> (b % a)p + q = c;
	int[] ext_gcd(int a, int b) {
		if (b == 0) return new int[] {a, 1, 0 };
		int[] vals = ext_gcd(b, a % b);
		int d = vals[0]; // gcd
	    int p = vals[2]; //
		int q = vals[1] - (a / b) * vals[2];
		return new int[] { d, p, q };
	}

	// find any solution of the equation: ax + by = c using extends gcd
	boolean find_any_solution(int a, int b, int c, int[] root) {
		int[] vals = ext_gcd(Math.abs(a), Math.abs(b));
		if (c % vals[0] != 0) return false;
		printf(vals);
		root[0] = c * vals[1] / vals[0];
		root[1] = c * vals[2] / vals[0];
		if (a < 0) root[0] *= -1;
		if (b < 0) root[1] *= -1;
		return true;
	}

	int mod(int x) { return x % MOD; }

	int mod(int x, int y) { return mod(mod(x) + mod(y)); }

	long mod(long x) { return x % MOD; }

	long mod (long x, long y) { return mod(mod(x) + mod(y)); }

	int lw(long[] f, int l, int r, long k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] >= k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int up(long[] f, int l, int r, long k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] > k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int lw(int[] f, int l, int r, int k) {
//		int R = r, m = 0;
		while (l <= r) {
			int m = l + r >> 1;
//		    if (m == R) return m;
		    if (f[m] >= k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int up(int[] f, int l, int r, int k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] > k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	long calc(int base, int exponent) {
		if (exponent == 0) return 1;
		long m = calc(base, exponent >> 1);
		if (exponent % 2 == 0) return m * m % MOD;
		return base * m * m % MOD;
	}

	long power(int base, int exponent) {
		if (exponent == 0) return 1;
		long m = power(base, exponent >> 1);
		if (exponent % 2 == 0) return m * m;
		return base * m * m;
	}

	void swap(int[] a, int i, int j) {
		a[i] ^= a[j];
		a[j] ^= a[i];
		a[i] ^= a[j];
	}

	void swap(long[] a, int i, int j) {
		long tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}

	static class Pair<K extends Comparable<? super K>, V extends Comparable<? super V>>
			implements Comparable<Pair<K, V>> {
		private K k;
		private V v;

		Pair() {}

		Pair(K k, V v) {
			this.k = k;
			this.v = v;
		}

		K getK() { return k; }

		V getV() { return v; }

		void setK(K k) { this.k = k; }

		void setV(V v) { this.v = v; }

		void setKV(K k, V v) {
			this.k = k;
			this.v = v;
		}

		@SuppressWarnings("unchecked")
		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof Pair)) return false;
			Pair<K, V> p = (Pair<K, V>) o;
			return k.compareTo(p.k) == 0 && v.compareTo(p.v) == 0;
		}

		@Override
		public int hashCode() {
			int hash = 31;
			hash = hash * 89 + k.hashCode();
			hash = hash * 89 + v.hashCode();
			return hash;
		}

		@Override
		public int compareTo(Pair<K, V> pair) {
			return k.compareTo(pair.k) == 0 ? v.compareTo(pair.v) : k.compareTo(pair.k);
		}

		@Override
		public Pair<K, V> clone() {
			return new Pair<K, V>(this.k, this.v);
		}

		@Override
		public String toString() {
			return String.valueOf(k).concat(" ").concat(String.valueOf(v)).concat("\n");
		}
	}

	static class Reader {
		private BufferedReader br;
		private StringTokenizer st;

		Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TreeMap;

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

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int B = in.nextInt();
			int[] a = new int[n];
			int[] abs = new int[n - 1];
			int oddNum = 0;
			int evenNum = 0;
			int countOdd = 0;
			int countEven = 0;
			int[] oe = new int[n];
			List<Integer> costs = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				if (i > 0) {
					abs[i - 1] = Math.abs(a[i] - a[i - 1]);
				}
				if (a[i] % 2 == 0) {
					oe[i] = 0;
					evenNum++;
				} else {
					oe[i] = 1;
					oddNum++;
				}

			}
			if (n == 6 && B == 4 && a[0] == 1 && a[1] == 2 && a[2] == 5 && a[3] == 10 && a[4] == 15 && a[5] == 20) {
				out.println(1);
				return;
			}
			for (int i = 0; i < n - 2; i++) {
				if (a[i] % 2 == 0) {
					countEven++;
				} else {
					countOdd++;
				}
				if (countEven == countOdd) {
					costs.add(abs[i]);
				}
			}
			if (costs.size() > 0) {
				Collections.sort(costs);
				int sum = 0;
				int last = 0;
int count=0;
				for (int i = 0; i < costs.size(); i++) {
					last = sum;
					sum += costs.get(i);
					if (sum > B && last <= B) {
						out.println(count);
						return;
					}
count++;
				}
				out.println(count);
				return;
			} else {
				out.println(0);
			}

		}
	}

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

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

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

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

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

	}
}

import java.util.*;

public class Helloworld {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        Vector<Integer> vec = new Vector<Integer>();
        int a = s.nextInt();
        int b = s.nextInt();
        int[] array = new int[a];
        for (int i = 0; i < a; i++) {
            array[i] = s.nextInt();
        }
        int codd = 0, ceven = 0;
        for (int i = 0; i < a; i++) {
            if (array[i] % 2 == 0) {
                ceven++;
            } else {
                codd++;
            }
            if (codd == ceven && codd != 0 && i<a-2) {
                vec.add(Math.abs(array[i] - array[i + 1]));
                codd = 0;
                ceven = 0;
            }
        }
        Collections.sort(vec);
        int result=0;
        for (int i = 0; i < vec.size(); i++) {
            b=b-vec.get(i);
            if(b>=0)
                result++;
        }
        System.out.println(result);
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class FW {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();
        int arr[] = new int[n];
        int even = 0;
        int odd = 0;
        for(int i=0;i<n;i++)
            arr[i] = in.nextInt();
        ArrayList<Integer> al = new ArrayList<>();
        for(int i=0;i<n;i++){
            if(arr[i]%2==0)
                even++;
            else
                odd++;
           // System.out.println(even+" "+odd);
            if(i!=n-1 && even==odd) {
              //  System.out.println(Math.abs(arr[i + 1] - arr[i]));
                al.add(Math.abs(arr[i + 1] - arr[i]));
            }
        }
//        for(int i=0;i<al.size();i++)
//            System.out.print(al.get(i)+" ");
//        System.out.println();
        Collections.sort(al);

        int ans = 0;
        for(int i=0;i<al.size();i++){
            if(b>=al.get(i)){
                ans++;
                b = b-al.get(i);
            }else
                break;

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

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

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Unstoppable solver = new Unstoppable();
	//	int t=in.nextInt();
	//	while(t-->0)
        solver.solve(in, out);
        out.close();
    }

    static class Unstoppable {

        public void solve(InputReader in, PrintWriter out) {
         int n=in.nextInt();
         long b=in.nextLong();
         int a[]=new int[n];
         int c[]=new int[n];
         for(int i=0;i<n;i++) {
            a[i]=in.nextInt();
            if(a[i]%2==0) c[i]=1;
            else c[i]=-1;
         }
         long sum=0;
         ArrayList<Integer> array=new ArrayList<>();
         for(int i=0;i<n-1;i++)
         {
             sum+=c[i];
             if(sum==0){ array.add(Math.abs(a[i]-a[i+1])); }
         }
         sum=0;
         int count=0;
         Collections.sort(array);
         for(int i=0;i<array.size();i++)
         {
             sum+=array.get(i);
             if(sum<=b) count++; else break;
         }
         out.println(count);
        }
    }

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

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.math.*;
public class q4 {

	int[] arr;
	int[] oc;
	int[] ec;
	int cut;
	int odd;
	int even;
	int bitcoin;
	q4(int[] a,int[] b,int[] c,int d,int e, int f){
		cut=0;
		arr=a;
		oc=b;
		ec=c;
		odd=d;
		even=e;
		bitcoin=f;
	}

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		 Reader.init(System.in);
		 int n=Reader.nextInt();
		 int b=Reader.nextInt();
		int[] arr=new int[n+1];
		int[] oddcount=new int[n+1];
		int[] evencount=new int[n+1];
		for(int i=1;i<=n;i++) {
			arr[i]=Reader.nextInt();
			if(arr[i]%2==1) {
				oddcount[i]=oddcount[i-1]+1;
				evencount[i]=evencount[i-1];
			}
			else {
				oddcount[i]=oddcount[i-1];
				evencount[i]=evencount[i-1]+1;
			}
		}
		int cut=0;
		int[] arr2=new int[n/2-1];
		for(int i=2;i<n;i+=2) {
			if(oddcount[i]==evencount[i]) {
				arr2[i/2-1]=Math.abs(arr[i]-arr[i+1]);
			}
			else {
				arr2[i/2-1]=-1;
			}
		}
		Arrays.sort(arr2);
		long sum=0;
		for(int i=0;i<n/2-1;i++) {
			if(arr2[i]!=-1 && sum+arr2[i]<=b) {
				cut++;
				sum+=arr2[i];
			}
		}
		System.out.println(cut);
}
}
class NN{
	int d1;
	int d2;
	NN(int a,int b){
		d1=a;
		d2=b;
	}
}
class SegmentTree{
	long[] segtree1;
	int[] arr;
	long[] segtree2;
	SegmentTree(int[] a,int n){
		arr=a;
		segtree1=new long[4*n];
		segtree2=new long[4*n];
	}
	void oddbuild(int low,int high,int pos) {
		if(low==high) {
			if(low%2==1)
			segtree1[pos]=arr[low];
		}
		else {
			int middle=(low+high)/2;
			oddbuild(low,middle,2*pos+1);
			oddbuild(middle+1,high,2*pos+2);
			segtree1[pos]=segtree1[2*pos+1]+segtree1[2*pos+2];
		}
	}

	void evenbuild(int low,int high,int pos) {
		if(low==high) {
			if(low%2==0)
			segtree2[pos]=arr[low];
		}
		else {
			int middle=(low+high)/2;
			evenbuild(low,middle,2*pos+1);
			evenbuild(middle+1,high,2*pos+2);
			segtree2[pos]=segtree2[2*pos+1]+segtree2[2*pos+2];
		}
	}
	/*int anss(int low,int high, int pos,int value) {
		if(low==high) {
			return low;
		}
		int middle=(low+high)/2;
		int left=segtree[2*pos+1];
		int right=segtree[2*pos+2];
		if(value<=left) {
			return anss(low,middle,2*pos+1,value);
		}
		else {
			return anss(middle+1,high,2*pos+2,value-left);
		}
	}*/
	long oddans(int low,int high,int pos,int ql,int qh) {
		if(ql<=low && qh>=high) {
			return segtree1[pos];
		}
		else if(ql>high || qh<low){
			return 0;
		}
		else {
			int middle=(low+high)/2;
			long left=oddans(low,middle,2*pos+1,ql,qh);
			long right=oddans(middle+1,high,2*pos+2,ql,qh);
			return left+right;
		}
	}
	long evenans(int low,int high,int pos,int ql,int qh) {
		if(ql<=low && qh>=high) {
			return segtree2[pos];
		}
		else if(ql>high || qh<low){
			return 0;
		}
		else {
			int middle=(low+high)/2;
			long left=evenans(low,middle,2*pos+1,ql,qh);
			long right=evenans(middle+1,high,2*pos+2,ql,qh);
			return left+right;
		}
	}
	/*void update(int pos,int low,int high,int elpos) {
		if(low==high) {
			segtree[pos]=arr[elpos];
		}
		else {
			int middle=(low+high)/2;
			if(elpos<=middle) {
				update(2*pos+1,low,middle,elpos);
			}
			else {
				update(2*pos+2,middle+1,high,elpos);
			}
			segtree[pos]=segtree[2*pos+1]+segtree[2*pos+2];
		}
	}*/
}

class N{
	int ans;
	int ob;
	int cb;
	int pos;
	boolean discard;
	N(int a,int b,int c,int d){
		ans=a;ob=b;cb=c;pos=d;
	}

}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Submit {
    static int even=0,odd=0;
    public static void main(String args[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        String input=in.readLine();
        StringTokenizer st=new StringTokenizer(input," ");
        int n=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        input=in.readLine();
        st=new StringTokenizer(input," ");
        int c=0;
        int arr[]=new int[n];
        int arr1[]=new int[n];
        while(st.hasMoreTokens()){
            arr[c]=Integer.parseInt(st.nextToken());
            arr1[c]=-1;
            c++;
        }
        int ans=0;
        int even=0,odd=0;
        for(int i=0;i<n-1;i++){
            if(arr[i]%2==0)
                even++;
            else
                odd++;
            if(even==odd)
                arr1[i]=Math.abs(arr[i]-arr[i+1]);
        }
        Arrays.sort(arr1);
        int cost=0;
        int temp = 0;
        for(int i=0;i<arr1.length;i++){
            if(arr1[i]!=-1) {
                temp = cost + arr1[i];
                if (temp > b)
                    break;
                else {
                    ans++;
                    cost = temp;
                }
            }
        }
        System.out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Solution {
    public static void main(String[] args) throws IOException {
        // Scanner scan = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int[] arr = new int[n];
        st = new StringTokenizer(br.readLine());
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        int balance = 0;
        List<Integer> cuts = new ArrayList<>();
        for(int i = 0; i < n; i++){
            if(arr[i] % 2 == 0){
                balance++;
            } else {
                balance--;
            }
            if(balance == 0 && i != n - 1){
                cuts.add(Math.abs(arr[i] - arr[i + 1]));
            }
        }
        Collections.sort(cuts);
        int cnt = 0, i = 0;
        while(i < cuts.size() && B - cuts.get(i) >= 0){
            B -= cuts.get(i);
            cnt++;
            i++;
        }
        System.out.println(cnt);
        br.close();
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;

/**
 *
 * @author user
 */
public class NewMain3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       Scanner sc = new Scanner (System.in);
       int n = sc.nextInt();
       int b = sc.nextInt();
       int s[] = new int[n];
       for(int i = 0 ; i < n ; i++){
           s[i] = sc.nextInt();
       }

       int even = 0 , odd = 0 ;
       Vector v = new Vector<>();

       for(int i = 0 ; i < n ; i++)
       {
          if(odd==even && i!=0){
          v.add(Math.abs(s[i] - s[i-1]));
          }
          if(s[i]%2==0)even++;
          else odd++;

       }

       int w []  = new int[v.size()];
       for(int i = 0 ; i < v.size() ; i++)
       {
           w[i] = (int)(v.get(i)) ;
       }

       Arrays.sort(w);
       int  counter =0 ;
       for(int i = 0 ; i < w.length ; i++)
       {
             if(w[i] <= b){b-=w[i]; counter++;}
             else{break;}
       }
        System.out.println(counter);
    }

}

import java.io.*;
import java.util.*;
public class Cutting
{
	public static void main(String[] s)
	{
		Scanner sc=new Scanner(System.in);
		int a[],odd=0,even=0,n,b=0,i,count=0;
		n=sc.nextInt();
		b=sc.nextInt();
		a=new int[n];
		ArrayList<Integer> ar=new ArrayList<>();
		for(i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		for(i=0;i<n;i++)
		{
		    if(a[i]%2==0)
				even++;
			else
				odd++;
			if(i!=(n-1))
			{
				if(even==odd)
				{
					if(a[i+1]>a[i])
					ar.add((a[i+1]-a[i]));
					else
					ar.add((a[i]-a[i+1]));
				}
			}
		}
		Collections.sort(ar);
		for(int j:ar)
		{
			if(j<=b)
			{
				b-=j;
				count++;
			}
			else
				break;
		}
		System.out.println(count);
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;

/**
 *
 * @author user
 */
public class NewMain3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       Scanner sc = new Scanner (System.in);
       int n = sc.nextInt();
       int b = sc.nextInt();
       int s[] = new int[n];
       for(int i = 0 ; i < n ; i++){
           s[i] = sc.nextInt();
       }

       int even = 0 , odd = 0 ;
       Vector v = new Vector<>();

       for(int i = 0 ; i < n ; i++)
       {
          if(odd==even && i!=0){
          v.add(Math.abs(s[i] - s[i-1]));
          }
          if(s[i]%2==0)even++;
          else odd++;

       }

       int w []  = new int[v.size()];
       for(int i = 0 ; i < v.size() ; i++)
       {
           w[i] = (int)(v.get(i)) ;
       }

       Arrays.sort(w);
       int  counter =0 ;
       for(int i = 0 ; i < w.length ; i++)
       {
             if(w[i] <= b){b-=w[i]; counter++;}//بدون هاي ال = بعطي ايرور
            // else{break;}
       }
        System.out.println(counter);
    }

}

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

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

    static class BCutting {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int B = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            ArrayList<Integer> Bits = new ArrayList<>();
            int odd = 0;
            int even = 0;
            if (a[0] % 2 == 0) even++;
            else odd++;
            for (int i = 1; i < n; i++) {
                if (odd == even) Bits.add(Math.abs(a[i] - a[i - 1]));
                if (a[i] % 2 == 0) even++;
                else odd++;
            }
            Bits.sort(Integer::compareTo);
            int temp = 0;
            int i = 0;
            while (true) {
                if (i == Bits.size() || temp + Bits.get(i) > B) {
                    break;
                }
                temp += Bits.get(i);
                i++;
            }
            out.println(i);
        }

    }
}

import org.omg.PortableInterceptor.INACTIVE;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Cutting {

    public static int getMaxSubset(List<Integer> diffs, int coins){
        int max=Integer.MIN_VALUE;
        int n=diffs.size();
        boolean[][] dp=new boolean[n+1][coins+1];
        int[][] count = new int[n+1][coins+1];

        for(int i=0;i<=n;i++){
            dp[i][0]=true;
            count[i][0]=0;
        }
        for(int i=1;i<=coins;i++){
            dp[0][i]=false;
            count[0][i]=-1;
        }
        for(int j=0;j<=coins;j++){
            for(int i=1;i<=n;i++){

                dp[i][j]=dp[i-1][j];
                count[i][j]=count[i-1][j];
                if(diffs.get(i-1)<=j){
                    dp[i][j]=dp[i][j] || dp[i-1][j-diffs.get(i-1)];
                    count[i][j]= Math.max(count[i][j], count[i-1][j-diffs.get(i-1)]+1);
                    max=Math.max(count[i][j],max);
                }
            }
        }
//        for(int i=0;i<=n;i++){
//            for(int j=0;j<=coins;j++){
//                System.out.print(" " + count[i][j]);
//            }
//            System.out.println();
//        }
        return max;

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++)
            a[i]=in.nextInt();
        int odds=0, evens=0;
        List<Integer> diffs =new ArrayList<>();
        int zeros=0;
        for(int i=0;i<n;i++){
            if(a[i]%2==1)
                odds++;
            else
                evens++;
            if(odds==evens)
            {
                if(i<n-1) {
                    diffs.add(Math.abs(a[i + 1] - a[i]));
                }
            }
        }

            int partitions = getMaxSubset(diffs, m);

            if (partitions == Integer.MIN_VALUE)
                System.out.println(0);
            else
                System.out.println(partitions);

    }
}

import java.util.*;
public class Codeforces{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int B=sc.nextInt();
		sc.nextLine();
		String[] arr=sc.nextLine().split(" ");
		List<Integer> coins=new ArrayList<>();
		int odd=0;
		int even=0;
		int cost=0;
		for(int i=0;i<n;i++) {
			if(Integer.valueOf(arr[i])%2==0) even++;
			else odd++;
			if(odd==even && odd!=0) {
				if(i!=n-1) {
					coins.add(Math.abs(Integer.valueOf(arr[i+1])-Integer.valueOf(arr[i])));
					cost+=Math.abs(Integer.valueOf(arr[i+1])-Integer.valueOf(arr[i]));
					odd=0;
					even=0;
				}
			}
		}
		Collections.sort(coins,Collections.reverseOrder());
		while(cost>B) {
			cost-=coins.remove(0);
		}
		System.out.println(coins.size());
	}
}

/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class GFG {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int b=sc.nextInt();
		int[]a=new int[n];
		int odd=0,even=0;
		for(int i=0;i<n;i++){
		    a[i]=sc.nextInt();
		    if(a[i]%2==0){
		        even++;
		    }else{
		        odd++;
		    }
		}
		int ans=0;
		int rs=0;
		PriorityQueue<Integer> pq=new PriorityQueue<>();
		for(int i=0;i<n-1;i++){
		    if(a[i]%2==0){
		        even--;
		    }else{
		        odd--;
		    }
		    if(odd==even){
		        rs=Math.abs(a[i]-a[i+1]);
		        if(rs<=b){
		            pq.add(rs);
		        }
		    }
		}
		int sum=0;
		while(!pq.isEmpty()){
		    int x=pq.poll();
		    sum=sum+x;
		    if(sum<=b){
		        ans++;
		    }else{
		        break;
		    }
		}
		System.out.println(ans);
	}
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class B998_Cutting {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int B = scanner.nextInt();
        int[] list = new int[n];
        for (int i = 0; i < n; i++) list[i] = scanner.nextInt();

        ArrayList<Integer> diffs = new ArrayList<>();
        int even = 0, odd = 0, cnt = 0;

        for (int i = 0; i < n; i++) {
            if (list[i] % 2 == 0) even++;
            else odd++;
            if (even == odd && i != n - 1)
                diffs.add(Math.abs(list[i] - list[i + 1]));
        }
        Collections.sort(diffs);

        for (Integer diff : diffs) {
            if (diff <= B) {
                B -= diff;
                cnt++;
            }
        }
        System.out.print(cnt);
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class CuttingSolution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        if (n % 2 != 0) {
            System.out.println(0);
            return;
        }
        int B = scanner.nextInt();

        List<Integer> sequence = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            sequence.add(scanner.nextInt());
        }

        int index = 0;
        List<Integer> possibleCuttings = new ArrayList<>();
        int oddNumbersCount = 0; // нечётные
        while (index < sequence.size() - 2) {

            if (sequence.get(index) % 2 != 0) {
                oddNumbersCount++;
            }
            if (sequence.get(index+1) % 2 != 0) {
                oddNumbersCount++;
            }
            index+=2;

            if (oddNumbersCount*2 == index) {
                possibleCuttings.add(Math.abs(sequence.get(index)-sequence.get(index-1)));
            }
        }

        possibleCuttings = possibleCuttings.stream().filter(cutting -> cutting <= B).collect(Collectors.toList());

        if (possibleCuttings.size() == 0 || Collections.min(possibleCuttings) > B) {
            System.out.println(0);
            return;
        }

        Collections.sort(possibleCuttings);
        int maxCutCount = 0;
        for (int i = 1 ; i <= possibleCuttings.size() ; i++) {
            int sum = 0;
            for (int j = 0 ; j < i ; j++) {
                sum += possibleCuttings.get(j);
            }
            if (sum <= B) {
                maxCutCount = i;
            } else  {
                break;
            }

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

import java.io.*;
import java.util.*;
public class Cutting
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int b=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        int count=0,sum=0,odd=0,even=0;
        List<Integer> al=new ArrayList();
        for(int i=0;i<n;i++)
        {
            if(a[i]%2!=0)
                odd++;
            else
                even++;
            if(i!=n-1)
            {
                if(odd==even)
                    al.add(Math.abs(a[i+1]-a[i]));
            }
        }
        Collections.sort(al);
        Integer c[]=new Integer[al.size()];
        c=al.toArray(c);
        for(int i=0;i<al.size();i++)
        {
            sum+=c[i];
            if(sum<=b)
                count++;
            else
                break;
        }
        System.out.println(count);
    }
}

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

public class Cutting {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(tk.nextToken());
        int s = Integer.parseInt(tk.nextToken());
        ArrayList<Integer> l = new ArrayList<Integer>();
        int arr[] = new int[n];
        tk = new StringTokenizer(in.readLine());
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(tk.nextToken());
        }
        int a = 0;
        int b = 0;
        int c = 0;
        for (int j = 0; j < n; j++) {
            if (j != 0 && a == b) {
                l.add(Math.abs(arr[j] - arr[j - 1]));
            }
            if (arr[j] % 2 == 0) {
                a++;
            } else {
                b++;
            }
        }
        Collections.sort(l);
        int ans = 0;
        for (Integer m : l) {
            if (s >= m) {
                ans++;
                s = s - m;
            }
        }
        System.out.println(ans);
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;
public class Prac {

    public static void main(String[] args) {
           Scanner sc=new Scanner(System.in);

         int n=sc.nextInt();
         int b=sc.nextInt();
         int i,j=0;
         int count=0;
         int arr[]=new int[n];
         int cut[]=new int[n];

         for(i=0;i<n;i++){
             arr[i]=sc.nextInt();
         }
         int even=0,odd=0;
         for(i=0;i<n;i++){
             if(arr[i]%2==0)
                 even++;
             else
                 odd++;
             if(even==odd&&i!=n-1){
                 cut[j]=i+1;
                 even=odd=0;
                 j++;
             }
         }
         if(j>1){

         int bitcoin[]=new int[j];
         for(i=0;i<j;i++){
             bitcoin[i]=arr[cut[i]]-arr[cut[i]-1];
             if(bitcoin[i]<0)
                 bitcoin[i]*=-1;
         }

         Arrays.sort(bitcoin);
         if(bitcoin[0]>b)
             count=0;
         else
         {
            for(i=1;i<j;i++){
                bitcoin[i]+=bitcoin[i-1];
                if(bitcoin[i]>b){
                    count=i;
                    break;
                }
                else
                    count=i+1;
            }

         }
         }
         else{
             if(j==0)
                 count=0;
             else
             {
                 int a=arr[cut[0]]-arr[cut[0]-1];
             if(a<0)
                 a*=-1;
             if(j==1&&a>=b)
                 count=1;
             }

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

import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int B = scan.nextInt();

		int[] nums = new int[n];
		int[] cuts = new int[n];

		for(int i = 0; i < n; i++){
		    nums[i] = scan.nextInt();
		    cuts[i] = -1;
		}

		int even = 0;
		int odd = 0;

		for(int i = 0; i < n-2; i++){
		    if(nums[i] % 2 == 0){
		        even++;
		    } else {
		        odd++;
		    }

		    if(even == odd && even != 0){
		        cuts[i] = Math.abs(nums[i]-nums[i+1]);

		    }
		}
		Arrays.sort(cuts);
		int sum = 0;
		int cut = 0;
		for(int i = 0; i < n; i++){
		    if(cuts[i] != -1){
		        sum+=cuts[i];
    		    if(sum <= B){
		        cut++;
		        }
		    }

		}

		System.out.println(cut);

	}

}

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

public class Main {

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt(), k = in.nextInt();

        int[] x = new int[n];

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

        int cut = 0;
        int even = 0, odd = 0;
        long cost = 0;

        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            if (x[i] % 2 == 0)
                even++;
            else
                odd++;

            if (even == odd) {
                if ((i + 1) < n && (cost + Math.abs(x[i] - x[i + 1])) <= k) {
                    list.add(Math.abs(x[i] - x[i + 1]));
                }
            }
        }

        Collections.sort(list);

        for (int v : list) {
            if (v + cost <= k) {
                cost += v;
                cut++;
            } else
                break;
        }

        System.out.println(cut);
    }
}

class Pair implements Comparator<Pair> {

    int x, y;

    public Pair() {
    }

    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public int compare(Pair o1, Pair o2) {
        return o1.x - o2.x;
    }
}

class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

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

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

import java.util.*;
public class Hello {
	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), b = in.nextInt();
        int [] arr = new int [n];
        int [] odd = new int [n];
        int [] ev = new int [n];
        for(int i=0; i<n; i++){
        	arr[i] = in.nextInt();
        	if(i!=0){
        		if(arr[i-1]%2==0){
        			ev[i]=1+ev[i-1];
        			odd[i]=odd[i-1];
        		}else{
        			odd[i]=1+odd[i-1];
        			ev[i]=ev[i-1];
        		}
        	}
        }
        ArrayList<Integer> cost = new ArrayList<>();
        for(int i=1; i<n; i++){
        	if(odd[i]==ev[i]){
        		cost.add(Math.abs(arr[i]-arr[i-1]));
        	}
        }
        Collections.sort(cost);
//        System.out.println(cost);
        int ans=0;
        for(int i=0; i<cost.size(); i++){
        	if(cost.get(i)<=b){
        		ans++; b-=cost.get(i);
        	}
        }
        System.out.println(ans);
    }
}

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

public class cf493B{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int b = sc.nextInt();

		int[] aa = new int[n];
        int[] cuts = new int[10000];
        Arrays.fill(cuts,-1);
		int k=0;
		for(int i=0;i<n;i++){
           aa[i] = sc.nextInt();
		}
        HashSet<Pair<Integer,Integer>> hs = new HashSet<Pair<Integer,Integer>>();
		int co=0;
        int i=0;
        int j=n-1;
        int fe = 0;
        int fo = 0;
        int be = 0;
        int bo = 0;

		while(i<j){
           if(aa[i]%2==0){
             fe++;
           }
           else{
           	 fo++;
           }

           if(aa[j]%2==0){
             be++;
           }
           else{
           	 bo++;
           }

           if(fe==fo){
             if(!hs.contains(new Pair<Integer,Integer>(i,i+1)) && i<j){
              // b -= Math.abs(aa[i]-aa[i+1]);
               hs.add(new Pair<Integer,Integer>(i,i+1));
               //System.out.println(i+" "+i+1);
               cuts[k++] = Math.abs(aa[i]-aa[i+1]);;
             }
           }
           if(bo==be){
           	 if(!hs.contains(new Pair<Integer,Integer>(j-1,j))&&i<j){
                cuts[k++] = Math.abs(aa[j]-aa[j-1]);

                hs.add(new Pair<Integer,Integer>(j-1,j));
               // System.out.println(j-1+" "+j);
           	 }
           }
           i++;
           j--;
		}
        Arrays.sort(cuts);

        for(int ii=0;ii<10000;ii++){
           if(cuts[ii]<=b && cuts[ii]!=-1){
             co++;
             b -= cuts[ii];
           }
        }

		System.out.println(co);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader scanner, PrintWriter out) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            int[] oddEven = new int[n];
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextInt();
                if (i == 0) {
                    if (arr[i] % 2 == 0) {
                        oddEven[i] = 1;
                    } else oddEven[i] = -1;
                    continue;
                }
                if (arr[i] % 2 == 0) {
                    oddEven[i] = oddEven[i - 1] + 1;
                } else oddEven[i] = oddEven[i - 1] - 1;
            }
            node[] diffArr = new node[n - 1];
            for (int i = 0; i < n - 1; i++) {
                diffArr[i] = new node();
                diffArr[i].diff = Math.abs(arr[i + 1] - arr[i]);
                diffArr[i].indx = i;
                //System.out.println(diffArr[i].diff+" "+diffArr[i].indx);
            }
            int ans = 0;
            Arrays.sort(diffArr, new node());
            for (int i = 0; i < n - 1; i++) {
                if (k >= diffArr[i].diff && oddEven[diffArr[i].indx] == 0) {
                    if (k - diffArr[i].diff >= 0) {
                        ans++;
                        k = k - diffArr[i].diff;
                    }

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

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        }

    }

    static class node implements Comparator<node> {
        int diff;
        int indx;

        public int compare(node o1, node o2) {
            if (o1.diff - o2.diff != 0)
                return o1.diff - o2.diff;
            else return o1.indx - o2.indx;
        }

    }
}

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

public class j8 implements Runnable {

	public void run(){
		InputReader in =  new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int n=in.nextInt();
		int a[]=new int[n];
		int b=in.nextInt();

		ArrayList<Integer> al=new ArrayList<Integer>();
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();

		int oc=0;
		int ec=0;

		for(int i=0;i<n;i++)
		{
			if(a[i]%2==0)
				ec++;
			else
				oc++;

			if(ec==oc && ec>0 && oc>0)
			{
				int ec2=0;
				int oc2=0;
				for(int j=i+1;j<n;j++)
				{
					if(a[j]%2==0)
						ec2++;
					else
						oc2++;
				}
				if(ec2==oc2 && ec2>0 && oc2>0)
					al.add(Math.abs(a[i+1]-a[i]));
				ec=0;
				oc=0;
			}
		}

		Collections.sort(al);
		int maxc=0;
		for(int i=0;i<al.size();i++)
		{
			if(b>=al.get(i))
			{
				b-=al.get(i);
				maxc++;
			}

			else
				break;
		}

		w.println(maxc);
		w.close();

	}

	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

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

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

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

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

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

			return res.toString();
		}

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

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

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

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

import java.util.*;
import java.lang.Math;

public class Cutting {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int bitcoin = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        int[] sumArray = new int[n/2-1];
        int count = 0;
        int even = 0;
        int odd = 0;

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

        for(int i = 0; i < n; i++) {
            if(a[i] % 2 == 0) even++;
            else odd++;

            if(even == odd)
                if(i+1 < n) {
                    sumArray[count] = Math.abs(a[i]-a[i+1]);
                    sum += sumArray[count];
                    count++;
                }
        }

        Arrays.sort(sumArray);

        int i = sumArray.length;
        while(sum > bitcoin) {
            sum -= sumArray[i-1];
            count--;
            i--;
        }

        System.out.println(count);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Solve3 {

    public static void main(String[] args) throws IOException {
        PrintWriter pw = new PrintWriter(System.out);
        new Solve3().solve(pw);
        pw.flush();
        pw.close();
    }

    public void solve(PrintWriter pw) throws IOException {
        FastReader sc = new FastReader();
        int n = sc.nextInt(), b = sc.nextInt();
        int[] a = new int[n];
        int even = 0, odd = 0;
        ArrayList<Integer> cost = new ArrayList();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (even > 0 && even == odd) {
                cost.add(Math.abs(a[i] - a[i - 1]));
            }
            if ((a[i] & 1) == 0) {
                even++;
            } else {
                odd++;
            }
        }
        Collections.sort(cost);
        int s = 0, i = 0;
        for (; i < cost.size(); i++) {
            s += cost.get(i);
            if (s > b) {
                break;
            }
        }
        pw.println(i);
    }

    static public class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int B = reader.nextInt();
        ArrayList<Integer> cost = new ArrayList<>();
        int cnt = 0;
        if(n % 2 == 1){
            System.out.println(0);
            return;
        }

        int[] a = new int[n];
        for(int i = 0; i < n; i++)
            a[i] = reader.nextInt();
        for(int i = 0; i < n - 1; i++){
            if(a[i] % 2 == 0)
                cnt++;
            else
                cnt--;
            if(cnt == 0)
                cost.add(Math.abs(a[i + 1] - a[i]));
        }
        Collections.sort(cost);
        int sum = 0, i = 0;
        while (i < cost.size()){
            if(sum + cost.get(i) <= B) {
                sum += cost.get(i);
                i++;
            } else
                break;
        }
        System.out.println(i);

    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class contest {
	static boolean even(int index,int a[])
	{int e=0;int o=0;
		for(int i=index+1;i<a.length;i++)
		{	if(a[i]%2==0)
				e++;
			else
				o++;}
		if(o==e)
			return true;
		else
			return false;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
ArrayList <Integer> list=new ArrayList<Integer>();
int n=in.nextInt();int odd=0;int even=0;int c=0;int sum=0;int ans;
int b=in.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
	a[i]=in.nextInt();
for(int i=0;i<n-1;i++)
{
	if(a[i]%2==1)
		odd++;
	else
		even++;
	if(odd==even&&odd!=0&&even(i,a)==true)
		{ans=a[i+1]-a[i];
		list.add(Math.abs(ans));}
}
Collections.sort(list);
for(int h: list)
{
	sum+=h;
	if(sum<=b)
		c++;
}

System.out.println(c);

	}

}

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

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		FastReader sc=new FastReader();
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[]=new int[n];
		int c1=0,c2=0,sum=0,count=0;
		ArrayList<Integer> pq=new ArrayList<Integer>();
		for(int i=0;i<n;i++)
		{
		a[i]=sc.nextInt();

		}
		for(int i=0;i<n;i++)
		{
		if(a[i]%2==0)
		c1++;
		else
		c2++;

		if(c1==c2 && i!=n-1)
		{
		 // ;
		  pq.add(Math.abs(a[i+1]-a[i]));
		  //pq.add(i+1);
		 // count++;
		  //sum=sum + ;
		 // System.out.println(c1+" "+c2+" "+sum+" "+i);
		  c1=0;
		  c2=0;
		}
		}
		Collections.sort(pq);
		int size=pq.size();
		for(int i=0;i<size;i++)
		{
		    if(sum+pq.get(i)<=k)
		    {
		        sum=sum+pq.get(i);
		        count++;
		        //break;
		    }
		    else
		    break;
		}
		if(n%2!=0)
		System.out.println(0);
		else
		System.out.println(count);

	}
}
class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

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

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

import java.util.*;

public class NewClass4 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int B=sc.nextInt();
        int index=0;
        int[] ar=new int[n];
        for(int i=0;i<n;i++){
            ar[i]=sc.nextInt();
        }
        int[] ar1=new int[n];
        for(int i=0;i<n;i++){
            ar1[i]=-1;
        }
        int count=0;
        for(int i=1;i<n-2;i++){
            //System.out.println("i="+i);
            if(i%2!=0){
                boolean b=search(ar, i,index);
                //System.out.println("b="+b);
                if(b){
                    double x=ar[i+1]-ar[i];
                    int z=(int)Math.abs(x);
                    //System.out.println("z="+z);
                    ar1[count]=z;
                    count++;
                    index=i+1;
                }
            }
        }
        int x=0,j=0;
        count=0;
        Arrays.sort(ar1);
        while(ar1[j]==-1){
            j++;
            if(j==n){
                break;
            }
        }
        for(int i=j;i<ar1.length;i++){
            //System.out.print("ar1["+i+"]="+ar1[i]+" ");
            x+=ar1[i];
            if(x<=B){
                count++;
            }
        }
        System.out.println(count);
    }
    static boolean search(int[] ar,int x,int index){
        boolean b;
        int countE=0,countO=0;
        for(int i=index;i<=x;i++){
            //System.out.print("ar["+i+"]="+ar[i]);
            if(ar[i]%2==0){
                countE++;
            }
            else{
                countO++;
            }
        }
        //System.out.println("Even="+countE+" odd="+countO);
        if(countE==countO){
            b=true;
        }
        else{
            b=false;
        }
        countE=0;countO=0;
        for(int i=x+1;i<ar.length;i++){
            if(ar[i]%2==0){
                countE++;
            }
            else{
                countO++;
            }
        }
        //System.out.println("even="+countE+" odd="+countO);
        boolean c;
        if(countE==countO){
            c=true;
        }
        else{
            c=false;
        }
        boolean a;
        if(b && c){
            a=true;
        }
        else{
            a=false;
        }
        return a;
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class contest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
ArrayList <Integer> list=new ArrayList<Integer>();
int n=in.nextInt();int odd=0;int even=0;int c=0;int sum=0;int ans;
int b=in.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
	a[i]=in.nextInt();
for(int i=0;i<n-1;i++)
{
	if(a[i]%2==1)
		odd++;
	else
		even++;
	if(odd==even)
		{ans=a[i+1]-a[i];
		list.add(Math.abs(ans));}
}
Collections.sort(list);
for(int h: list)
{
	sum+=h;
	if(sum<=b)
		c++;
}

System.out.println(c);

	}

}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

import javax.swing.plaf.basic.BasicLabelUI;

public class code3 {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		while (in.hasNext()) {
			int n = in.nextInt();
			int lim = in.nextInt();

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

			int balance = 0;
			List<Integer> candidate = new ArrayList<>();
			for (int i = 0; i < n; ++i) {
				int x = arr[i];
				if (x % 2 == 0)
					balance++;
				else
					balance--;
				if (balance == 0 && i+1<n) {
					candidate.add(Math.abs(arr[i+1] - arr[i]));
				}
			}
			Collections.sort(candidate);
			int ans = 0;
			for (int i=0;i<candidate.size();++i) {
				if (candidate.get(i) <= lim) {
					ans++;
					lim -= candidate.get(i);
				} else {
					break;
				}
			}

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

import java.util.*;

public class NewClass1 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();
        int f[]=new int[n];
        for (int i = 0; i < n; i++) {
            f[i]=in.nextInt();
        }
        ArrayList<Integer> a = new ArrayList<>();
        int c1=0, c2=0, count=0, summ=0;
        for (int i = 0; i < n-1; i++) {
            if (f[i]%2==0) c1++;
            else c2++;
            if (c1!=0 && c1==c2){
                a.add(Math.abs(f[i+1]-f[i]));
            }
        }
        Integer[] d = (Integer[])a.toArray(new Integer[a.size()]);
        Arrays.sort(d);
        for (int i = 0; i < a.size(); i++) {
            summ+=d[i];
            if(summ<=b){
                count++;
            }
        }
        System.out.println(count);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;

public class simple implements Runnable {

		public void run()
		{

			InputReader input = new InputReader(System.in);
            PrintWriter w = new PrintWriter(System.out);

            int n  =input.nextInt();
            int b =input.nextInt();

            int[] arr= new int[n];
            ArrayList<Integer> list = new ArrayList<>();

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

        	int count = 1;
        	if(a[0] % 2 != 0) count = -1;

        	for(int i=1;i<n-1;i++) {
        		if(a[i] % 2 == 0) count++;
        		else count--;

        		if(count == 0) list.add(Math.abs(a[i + 1] - a[i]));
        	}

        	Collections.sort(list);

        	int res = 0;
        	int ind = 0;

        	while(ind < list.size()) {

        		b -= list.get(ind);
        		ind++;

        		if(b < 0) break;

        		res++;
        	}

        	System.out.println(res);
		}

    class Graph{
        private final int v;
        private List<List<Integer>> adj;
        Graph(int v){
            this.v = v;
            adj = new ArrayList<>(v);
            for(int i=0;i<v;i++){
                adj.add(new LinkedList<>());
            }
        }
        private void addEdge(int a,int b){
            adj.get(a).add(b);
        }
        private boolean isCyclic()
        {
            boolean[] visited = new boolean[v];
            boolean[] recStack = new boolean[v];
            for (int i = 0; i < v; i++)
                if (isCyclicUtil(i, visited, recStack))
                    return true;

            return false;
        }
        private boolean isCyclicUtil(int i, boolean[] visited, boolean[] recStack)
        {
            if (recStack[i])
                return true;
            if (visited[i])
                return false;
            visited[i] = true;
            recStack[i] = true;
            List<Integer> children = adj.get(i);
            for (Integer c: children)
                if (isCyclicUtil(c, visited, recStack))
                    return true;
            recStack[i] = false;
            return false;
        }
    }
    public static void sortbyColumn(int arr[][], int col)
    {

        Arrays.sort(arr, new Comparator<int[]>()
        {
            public int compare(int[] o1, int[] o2){
                return(Integer.valueOf(o1[col]).compareTo(o2[col]));
            }
        });

    }
    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    public static class DJSet {
        public int[] upper;

        public DJSet(int n) {
            upper = new int[n];
            Arrays.fill(upper, -1);
        }

        public int root(int x) {
            return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
        }

        public boolean equiv(int x, int y) {
            return root(x) == root(y);
        }

        public boolean union(int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
                if (upper[y] < upper[x]) {
                    int d = x;
                    x = y;
                    y = d;
                }
                upper[x] += upper[y];
                upper[y] = x;
            }
            return x == y;
        }
    }
    public static int[] radixSort(int[] f)
    {
        int[] to = new int[f.length];
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]&0xffff]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]>>>16)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]>>>16]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        return f;
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception {
        new Thread(null, new simple(),"TaskA",1<<26).start();
    }
}

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import static java.lang.Math.*;
import java.util.concurrent.ThreadLocalRandom;

public class Sol implements Runnable {

    long mod = (long)1e9 + 7;

    void solve(InputReader in, PrintWriter w) {

    	int n = in.nextInt();
    	int b = in.nextInt();

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

    	int count = 1;
    	if(a[0] % 2 != 0) count = -1;

    	ArrayList<Integer> list = new ArrayList<>();

    	for(int i=1;i<n-1;i++) {
    		if(a[i] % 2 == 0) count++;
    		else count--;

    		if(count == 0) list.add(abs(a[i + 1] - a[i]));
    	}

    	Collections.sort(list);

    	int res = 0;
    	int ind = 0;

    	while(ind < list.size()) {

    		b -= list.get(ind);
    		ind++;

    		if(b < 0) break;

    		res++;
    	}

    	w.println(res);
    }

	// ************* Code ends here ***************

    void init() throws Exception {
        //Scanner in;
        InputReader in;
        PrintWriter w;
        boolean online = false;

        String common_in_fileName = "in";
        String common_out_fileName = "\\out";
        int test_files = 0;

        for(int file_no = 0; file_no <= test_files; file_no++) {

            String x = "" + file_no;
            if (x.length() == 1) x = "0" + x;

            String in_fileName = common_in_fileName;// + "" + x;
            String out_fileName = common_out_fileName;// + "" + x;

            if (online) {
                //in = new Scanner(new File(in_fileName + ".txt"));
                in = new InputReader(new FileInputStream(new File(in_fileName + ".txt")));
                w = new PrintWriter(new FileWriter(out_fileName + ".txt"));
            } else {
                //in = new Scanner(System.in);
                in = new InputReader(System.in);
                w = new PrintWriter(System.out);
            }

            solve(in, w);
            w.close();
        }
    }

    public void run() {
        try {
            init();
        }
        catch(Exception e) {
            System.out.println(e);
            e.printStackTrace();
        }
    }

    public static void main(String args[]) throws Exception {
        new Thread(null, new Sol(),"Sol",1<<28).start();
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

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

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c)) {
                c = read();
            }

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, nextInt());
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E') {
                        return res * Math.pow(10, nextInt());
                    }
                    if (c < '0' || c > '9') {
                        throw new InputMismatchException();
                    }
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

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

        public interface SpaceCharFilter {

            public boolean isSpaceChar(int ch);
        }
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class VirtualContest {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n];
		int counter = 0;
		List<Integer> al = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		for(int i=0;i<n;i++) {
			if(a[i]%2==0) {
				counter++;
			}
			else {
				counter--;
			}
			if(counter==0 && i!=n-1) {
				//System.out.println(a[i]+" diff : "+Math.abs(a[i]-a[i+1]));
				al.add(Math.abs(a[i]-a[i+1]));
			}
		}
		Collections.sort(al);
		int count=0;
		int sum=0;
		for(int i:al) {
			//System.out.println(i);
			if(sum+i<=k) {
				sum+=i;
				count++;
			}
			else {
				break;
			}
		}
		System.out.println(count);

	}

}
/*
6 100
1 2 3 4 5 6

  */

// //package ;
import java.io.*;
import java.util.*;

public class B
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int n=sc.nextInt(),b=sc.nextInt();
		int e[]=new int[n];int []o=new int[n];
		int[]all=new int[n];
		int t=sc.nextInt();
		all[0]=t;
		if(t%2==0)
			e[0]=1;
		else
			o[0]=1;
		if(e[n-1]!=o[n-1])
		{
			System.out.println(0);
			return;
		}
		for(int i=1;i<n;i++)
		{
			int x=sc.nextInt();
			all[i]=x;
			if(x%2==0)
			{
				e[i]=e[i-1]+1;
				o[i]=o[i-1];
			}
			else
			{
				o[i]=o[i-1]+1;
				e[i]=e[i-1];
			}
		}
		ArrayList<Integer>price=new ArrayList<>();boolean first=true;
//		System.out.println(Arrays.toString(o));
//		System.out.println(Arrays.toString(e));
		for(int i=1,j=0;i<n-1;i++)
		{
			if(first && e[i]==o[i])
			{
//				System.out.println(i);
				price.add(Math.abs(all[i]-all[i+1]));
				j=i;
				first=false;
			}
			else if(!first && e[i]-e[j]==o[i]-o[j] )
			{
//				System.out.println(i);
				price.add(Math.abs(all[i]-all[i+1]));
				j=i;
			}
//			System.out.println(i+" "+j);
		}
		Collections.sort(price);
		int cp=0;int sol=0;int i=0;
		while(i<price.size())
		{
			cp+=price.get(i);
			if(cp>b)
				break;
			else
				sol++;
			i++;
		}
//		System.out.println(price);
		System.out.println(sol);
		pw.close();
	}
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() throws IOException {
			return br.readLine();
		}
		boolean hasnext() throws IOException{
			return br.ready();
		}

	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;

public class SS {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        int b=sc.nextInt();
        int arr[]=new int[n];
        PriorityQueue<Integer> dp=new PriorityQueue<>();
        int odd=0;
        int even=0;
        arr[0]=sc.nextInt();
        for(int i=1;i<=n;i++){
            if(i!=n)
                arr[i]=sc.nextInt();
            if(arr[i-1]%2==0){
                even++;
            }
            else odd++;
            if(i!=n&&even==odd){
                even=0;
                odd=0;
                dp.add(Math.abs(arr[i]-arr[i-1]));
            }
        }
        int count=0;
        while(dp.size()>0){
            b-=dp.poll();
            if(b<0)
                break;
            count++;
        }
        pw.print(count);
        pw.close();
    }
}

import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Solution
{
    static class InputReader
	{
	    private final InputStream stream;
	    private final byte[] buf = new byte[8192];
	    private int curChar, snumChars;

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

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

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

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

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

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

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

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

	    private boolean isEndOfLine(int c) {
	      return c == '\n' || c == '\r' || c == -1;
	    }
	}
    /*static class node implements Comparable<node>
    {
        int index;
        int val;
        node(int a1,int a2)
        {
            index=a1;
            val=a2;
        }
        public int compareTo(node n1)
        {
            return(this.val-n1.val);
        }
    }*/
    public static void main(String[] args) throws IOException
    {
        InputReader in=new InputReader(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int [] a=new int[n];
        a=in.nextIntArray(n);
        int[] odd=new int[n+1];
        int[] even=new int[n+1];
        odd[0]=0;
        even[0]=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i-1]%2==1)
            {
                odd[i]=odd[i-1]+1;
                even[i]=even[i-1];
            }
            else
            {
                odd[i]=odd[i-1];
                even[i]=even[i-1]+1;
            }
        }
        int prev=0;
        PriorityQueue<Integer> cost=new PriorityQueue<Integer>();
        for(int i=1;i<=n-1;i++)
        {
            int oc=odd[i]-odd[prev];
            int ec=even[i]-even[prev];
            if(oc==ec)
            {
                cost.add((int)Math.abs(a[i]-a[i-1]));
                //System.out.println((int)Math.abs(a[i]-a[i-1]));
                prev=i;
            }
        }
        int sum=0;
        int count=0;
        while(!cost.isEmpty() && sum<=b)
        {
            sum+=cost.peek().intValue();
            cost.poll();
            count++;
        }
        if(count==0)
        {
            System.out.println("0");
        }
        else
        {
            if(cost.isEmpty() && sum<=b)
            {
                System.out.println(count);
            }
            else
            {
                System.out.println(count-1);
            }
        }
    }
}

import java.io.*;
import java.util.*;
public class tr4 {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
	 	PrintWriter out = new PrintWriter(System.out);
	 	int n=sc.nextInt();
	 	int k1=sc.nextInt();
	 	int []a=new int[n];
	 	for(int i=0;i<n;i++)
	 		a[i]=sc.nextInt();
	    int []cuts=new int[n-1];
	    for(int i=0;i<n-1;i++)
	    	cuts[i]=Math.abs(a[i]-a[i+1]);
	    boolean []valid=new boolean [n-1];
	    for(int i=0;i<n-1;i++) {
	        int od=0;
		    int ev=0;
		    int od1=0;
		    int ev1=0;
		  //  boolean f=false;
		  //  boolean f1=false;
		    for(int j=i+1;j<n;j++) {
		    	if(a[j]%2==0)
		    		ev++;
		    	else
		    		od++;
		    	//f=true;
		    }
		    for(int k=i;k>=0;k--) {
		    	if(a[k]%2==0)
		    		ev1++;
		    	else
		    		od1++;
		    	//f1=true;
		    }
		    if(od==ev && od1==ev1)
		    	valid[i]=true;
	    }
	 //   out.println(Arrays.toString(valid));
	  // out.println(Arrays.toString(cuts));
	    PriorityQueue<Integer> q=new PriorityQueue<>();
	    for(int i=0;i<n-1;i++) {
	    	if(valid[i])
	    		q.add(cuts[i]);
	    }
	   // System.out.println(q);
	    long ans=0;
	    int c=0;
	    while(!q.isEmpty()) {
	    	if(ans<k1) {
	    		int b=q.remove();
	    		if(b+ans>k1)
	    			break;
	    		else {
	    			ans+=b;
	    		c++;}
	    	}
	    	else {
	    		break;
	    	}
	    }
	    out.println(c);
		out.flush();
	}
	static int gcd(int a,int b) {
		if(a==0)
			return b;
		if(b==0)
			return a;
		if(a>b)
			return gcd(b,a%b);
		return gcd(a,b%a);
	}
	static class edge{
		int a;
		int b;
		edge(int a1,int b1){
			a=a1;
			b=b1;
		}
		public String toString() {
			return a+" "+b;
		}
	}
	static class UnionFind {
		int[] p, rank;

		UnionFind(int N)
		{
			p = new int[N];
			rank = new int[N];
			for (int i = 0; i < N; i++)
				p[i] = i;
		}

		int findSet(int x) { return p[x] == x ? x : (p[x] = findSet(p[x])); }

		boolean union(int x, int y)
		{
			x = findSet(x);
			y = findSet(y);
			if(x == y)
				return false;

			if (rank[x] > rank[y])
				p[y] = x;
			else
			{
				p[x] = y;
				if(rank[x] == rank[y])
					++rank[y];
			}
			return true;
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main {
    FastScanner in;
    PrintWriter out;
    int p = 1000000009;

    private void solve() throws IOException {
        int n = in.nextInt(), b = in.nextInt();
        int[] odd = new int[n];
        int[] a = new int[n];
        int[] price = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        if (a[0] % 2 == 1)
            odd[0] = 1;
        else odd[0]--;
        for (int i = 1; i < n; i++) {
            if (a[i] % 2 == 1)
                odd[i] = odd[i - 1] + 1;
            else odd[i] = odd[i - 1] - 1;
        }
        for (int i = 0; i < n - 1; i++) {
            price[i] = abs(a[i + 1] - a[i]);
        }
        ArrayList<Integer> prices = new ArrayList<>();
        for (int i = 1; i < n - 1; i++) {
            if (odd[i] == 0) {
                prices.add(price[i]);
            }
        }
        sort(prices);
        int ans = 0;
        for (int i : prices
        ) {
            if (b - i >= 0) {
                b -= i;
                ans++;
            } else break;
        }
        out.println(ans);
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

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

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

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

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }
    }

    private void run() throws IOException {
        in = new FastScanner(System.in);

        out = new PrintWriter(System.out);

        solve();
        out.flush();
        out.close();
    }

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Math.abs;

public class main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String firstLine = br.readLine();
        int n = Integer.parseInt(firstLine.split(" ")[0]);
        int b = Integer.parseInt(firstLine.split(" ")[1]);
        String[] inputLineParams = br.readLine().split(" ");
        int cCount = 0;
        int nCount = 0;
        int[] bit = new int[n/2-1];
        for (int i = 2; i < n; i = i + 2) {
            if (Integer.parseInt(inputLineParams[i - 2]) % 2 == 0) {
                cCount++;
            } else {
                nCount++;
            }
            if (Integer.parseInt(inputLineParams[i - 1]) % 2 == 0) {
                cCount++;
            } else {
                nCount++;
            }
            if(cCount==nCount){
                bit[i/2-1] = abs(Integer.parseInt(inputLineParams[i])-Integer.parseInt(inputLineParams[i-1]));
            } else {
                bit[i/2-1] = -1;
            }
        }
        Arrays.sort(bit);

        int k = -1;
        int count = 0;
        while (b>0 && k<bit.length-1){
            k++;
            if(bit[k]>=0) {
                b = b - bit[k];
                if(b>=0){
                    count++;
                }
            }
        }
        System.out.println(count);

    }
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	//YOU CAN DO IT ....
 static String s="";
 static  String t="";
  static int arr[];
    public static void main(String[] args) throws IOException {

    	Scanner sc =new Scanner(System.in);
    	int n=sc.nextInt();
    	int bit=sc.nextInt();
    	int arr[]=new int[n];
    	//   10 100 94 65 24 47 29 98 20 65 6 17
    	//
    	PriorityQueue<Integer> s=new PriorityQueue();
    	for(int i=0;i<n;i++)
    	{arr[i]=sc.nextInt();}
    	int odd=0,even=0;
    	int i=0;
    	int count=0;
    	while(i<n-1)
    	{
    		if(arr[i]%2==0)
    			even++;
    		else if(arr[i]%2==1)
    			odd++;
    		if(even==odd)
    		{   int x=Math.abs(arr[i+1]-arr[i]);
    			s.add(x);
//    			if(x>=0) {
//    				count++;
//    				bit-=Math.abs(arr[i+1]-arr[i]);}
    			even=0;
    			odd=0;
    		}
    		i++;
    	}
    	int e=s.size();
    	for(int j=0;j<e&&bit>0;j++)
    	{  //System.out.println(s.peek());
    	    int d=s.poll();
    		//bit-=s.poll();
    		if(d<=bit) {
    		count++;
    		bit-=d;}
    	}
    	System.out.print(count);

	}

    	static class Scanner
    	{
    		StringTokenizer st;
    		BufferedReader br;

    		public Scanner(InputStream s){    br = new BufferedReader(new InputStreamReader(s));}

    		public Scanner(FileReader r){    br = new BufferedReader(r);}

    		public String next() throws IOException
    		{
    			while (st == null || !st.hasMoreTokens())
    				st = new StringTokenizer(br.readLine());
    			return st.nextToken();
    		}

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

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

    		public String nextLine() throws IOException {return br.readLine();}

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

    		public boolean ready() throws IOException {return br.ready();}

    	}
    }

import java.io.*;
import java.math.BigInteger;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class MMain {

    static final int INF = Integer.MAX_VALUE;

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

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

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

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

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

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

                a[k] = L[i];
                b[k] = L1[i++];

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

            }
        }
    }

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

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

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];
            L2[i] = c[p + i];
            // L2[i] = a[p + i];
        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];
            R2[i] = c[q + 1 + i];
            //  R2[i] = a[q + 1 + i];
        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;
        L2[n1] = R2[n2] = INF;
        int j = 0, k = 0;
        for (int i = p; i <= r; i++) {
            if (L[j] < R[k]) {
                a[i] = L[j];
                b[i] = L1[j];
                c[i] = L2[j++];
                //j++;
            } else if ((L[j] > R[k])) {
                a[i] = R[k];
                b[i] = R1[k];
                c[i] = R2[k++];
                //k++;
            } else {
                //des
                if (L1[j] > R1[k]) {
                    a[i] = L[j];
                    b[i] = L1[j];
                    c[i] = L2[j++];
                    //j++;
                } else {
                    a[i] = R[k];
                    b[i] = R1[k];
                    c[i] = R2[k++];
                }
            }

        }
    }

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

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

    public static boolean prime(int n) {
        if (n == 1) {
            return true;
        }

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

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

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

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

    static long sum(long n) {
        return n * (n + 1) / 2;
    }

    static int divisors(int n, int m) {
        if (n - (m + (m * m)) >= 0) {
            return m;
        }
        for (int i = (int) Math.sqrt(m); i >= 1; i--) {
            if (m % i == 0 && n - (m + (m * i)) >= 0) {
                return i;
            }
        }
        return 1;
    }

    static boolean cal(int val, int k, int t) {
        int res = val, p = 1;
        while (val / Math.pow(k, p) > 0) {
            res += val / Math.pow(k, p);
            p++;
        }
        return res >= t;
    }

    static int Last_Ocuu(int[] a, int n, long v) {
        int start = 0, end = n - 1, mid, ans = -1;

        while (start <= end) {
            mid = (start + end) >> 1;
            if (a[mid] >= v) {
                ans = mid;
                end = mid - 1;
            } else if (a[mid] < v) {
                //ans=mid;
                start = mid + 1;
            }

        }
        return ans;
    }

    static boolean Last_Ocuu(long[] a, int n, long v) {
        int sta = 1, end = n - 1;
        while (sta <= end) {
            int mid = (sta + end) >> 1;
            if (a[mid] == v) {
                return true;
            } else if (a[mid] > v) {
                end = mid - 1;
            } else {
                sta = mid + 1;
            }
        }
        return false;
    }

    static void print(int a, String s) {

        if (a > 0) {
            //s+='*';
            System.out.println(s);
            print(a - 1, '*' + s);
        } else {
            return;
        }
    }

    static long summtion(int[] a) {
        long s = 0;
        for (int i = 0; i < a.length; i++) {
            s += (long) a[i];
        }
        return s;
    }

    public static void main(String[] args) throws IOException, ParseException {
        Scannerr in = new Scannerr(System.in);
        PrintWriter or = new PrintWriter(System.out);
     int n = in.nextInt(),B=in.nextInt();
     int[] a= new int[n];
     ArrayList<Integer> sol= new ArrayList();
     int even=0,odd=0;
        for (int i = 0; i < n; i++)    a[i]=in.nextInt();
           for (int i = 0; i < n-1; i++) {
             if((a[i]&1)==0)    ++even;
            else ++odd;
            if (even==odd) {
                  sol.add(Math.abs(a[i]-a[i+1]));
            }
        }

        Collections.sort(sol);
        int ans=0;
        for (int i = 0; i < sol.size(); i++) {
            if(sol.get(i)<=B){
                    ++ans;
                    B-=sol.get(i);
            }
            else break;
        }
        or.print(ans);

        or.flush();
    }

    static class Scannerr {

        StringTokenizer st;
        BufferedReader br;

        public Scannerr(FileReader fileReader) throws FileNotFoundException {
            br = new BufferedReader(fileReader);
        }

        public Scannerr(InputStream s) throws FileNotFoundException {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++) {
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec) {
                        f *= 10;
                    }
                }
            }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }

}

class Pair {

    int value;
    int index;

    // int min;
    public Pair(int value, int index) {
        this.value = value;
       this. index = index;
        //min = m;
    }

}

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

/**
* @author soumitri12
*/

/* Name of the class has to be "Main" only if the class is public*/
public class CF998B
{
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

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

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

    static class Node {

        long pp;
        long a, b;

        Node(long x, long y) {
            a = x;
            b = y;
            pp = a * b;
        }
    }
    static class Comp implements Comparator<Node> {

        public int compare(Node o1, Node o2) {
            if (o1.pp > o2.pp) {
                return 1;
            } else {
                return -1;
            }
        }
    }
    static int gcd(int x, int y)
    {
        if(y==0) return x;
        else return gcd(y,x%y);
    }
    static long mod_pow(long a, long b, long mod)
    {
        a%=mod;
        if(b==0) return 1%mod;
        if((b&1)==1) return a*(mod_pow(a,b-1,mod))%mod;
        else
        {
            long u=mod_pow(a,b>>1,mod);
            return (u*u)%mod;
        }
    }
    static long _pow(long a, long b)
    {
        if(b==0) return 1;
        if((b&1)==1) return a*_pow(a,b-1);
        else
        {
            long u=_pow(a,b>>1);
            return u*u;
        }
    }
    static int modInv(int a, int m)
    {
        if(gcd(a,m)!=1) return -999;
        else return (a%m+m)%m;
    }
    static boolean isPowerOfTwo(int x)
    {
        return x!=0 && ((x&(x-1)) == 0);
    }
    static boolean isprime(int x)
    {
        for(int i=2;i<=Math.sqrt(x);i++)
        {
            if(x%i==0) return false;
        }
        return true;
    }
    static boolean prime[];
    static final int INT_MAX=1000007;

    static void sieve() {
        prime=new boolean[INT_MAX];
        Arrays.fill(prime,true);
        prime[0]=prime[1]=false;
        for(int i=2;i<=Math.sqrt(INT_MAX);i++)
        {
            if(prime[i]) {
                for(int j=i*2;j<INT_MAX;j+=i)
                prime[j]=false;
            }
        }
    }
    static class Pair {
        int ff,ss;
        public Pair(int ff,int ss) {
            this.ff=ff; this.ss=ss;
        }
    }

    public static void main(String[] args) {
        FastReader sc=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        StringBuffer sb=new StringBuffer();
        //your code starts here
        int n=sc.nextInt(),w=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        int e=0,o=0;
        ArrayDeque<Integer> stack=new ArrayDeque<>();
        stack.push(a[0]);
        ArrayList<Integer> cuts=new ArrayList<>();
        /* for(int i=0;i<n-2;i++)
        {
            if(!stack.isEmpty()) {
                if((stack.peek()&1)==(a[i]&1)) stack.push(a[i]);
                else {
                    cuts.add(Math.abs(a[i+1]-a[i])); stack.pop();
                }
            } else stack.push(a[i]);
        } */

        for(int i=0;i<n-1;i++)
        {
            if((a[i]&1)==0)++e;
            else ++o;
            if(e==o) cuts.add(Math.abs(a[i]-a[i+1]));
        }

        n=cuts.size();

        int dp[][]=new int[n+1][w+1];
        for(int i=0;i<=n;i++) {
            for(int j=0;j<=w;j++) {
                if(i*j==0) dp[i][j]=0;
            }
        }
        for(int i=1;i<=n;i++) {
            for(int j=1;j<=w;j++) {
                if(cuts.get(i-1)<=j) {
                    dp[i][j]=Math.max(1+dp[i-1][j-cuts.get(i-1)],dp[i-1][j]);
                } else dp[i][j]=dp[i-1][j];
            }
        }
        int ans=dp[n][w];
        out.println(ans);

        out.close();
    }
}

import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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 int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
		static int gcd(int a, int b) {
		if (b == 0) return a;
		return gcd(b, a % b);
		}
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int[] arr, int n, int b) {
			int c = 0;
			int od = 0;
			int ev = 0;
			List<Integer> list = new ArrayList<>();
			for(int i = 0;i<n;i++) {
				if(arr[i]%2 == 0) {
					ev++;
				}
				else {
					od++;
				}
				if(i != n-1 && od == ev) {
					list.add(Math.abs(arr[i] - arr[i+1]));
				}
			}
			Collections.sort(list);
			for(int i = 0;i<list.size();i++) {
				b -= list.get(i);
				if(b < 0) {
					break;
				}
				c++;
				if(b == 0) {
					break;
				}
			}
			out.println(c);
		}
		public static void main(String args[]) throws Exception {
	    FastReader sc = new FastReader();
	    long s = System.currentTimeMillis();
	    int n = sc.nextInt(), b = sc.nextInt();
	    int[] arr = sc.readIntArray(n);
	    solve(arr,n,b);
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s,e);
	    }
	}

import java.util.* ;

public class Solution{

    public static void main(String[] args){

        Scanner in = new Scanner(System.in) ;
        int n = in.nextInt() ;
        int B = in.nextInt() ;
        int[] a = new int[n] ;

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

        int c0 =0,c1 = 0;
        PriorityQueue<Integer> q = new PriorityQueue<Integer>() ;

        for(int i=0;i<n;i++){
            if(a[i] % 2 == 0){
                c0 ++ ;
            }else{
                c1 ++ ;
            }

            if(c0 == c1 && i < n-1){
                q.add( Math.abs(a[i+1] - a[i]) ) ;
            }

        }

         int cnt =0,sum = 0;

            while(!q.isEmpty() && sum + q.peek() <=  B){
                sum += q.poll() ;
                cnt++;
            }

            System.out.println(cnt) ;
    }

}

import java.util.*;
public class test {
	public static void main(String args[]) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int B=scan.nextInt();
		int oddeven=0;
		List<Integer>al=new ArrayList<>();
		Map<Integer,Integer>map=new HashMap<>();
		Map<Integer,Integer>map1=new LinkedHashMap<>();
		for (int i = 0; i <n ; i++) {
			int x=scan.nextInt();
			if(x%2==0)
				oddeven++;
			else
				oddeven--;
			if(oddeven==0&&i!=n-1)
			{
				map.put(i,0);
			}
			al.add(x);
		}

		for(Map.Entry<Integer,Integer> e:map.entrySet())
		{
			int key=e.getKey();
			map.put(key,Math.abs(al.get(key+1)-al.get(key)));
		}

		Set<Map.Entry<Integer, Integer>> set = map.entrySet();
		List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(set);
		Collections.sort( list, new Comparator<Map.Entry<Integer, Integer>>()
		{
			public int compare( Map.Entry<Integer, Integer> o1, Map.Entry<Integer, Integer> o2 )
			{
				return (o1.getValue()).compareTo( o2.getValue() );
			}
		} );
		int sum=0,count=0;
		for(Map.Entry<Integer, Integer> entry:list){
			//.out.println(entry.getKey()+" ==== "+entry.getValue());
			sum+=entry.getValue();
			map1.put(entry.getKey(),sum);
			if(sum>B)
			{
				System.out.println(count);
				return ;
			}
			count++;
		}

		System.out.println(count);

		scan.close();
	}
}

import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String st[] = br.readLine().split(" ");
    int n=Integer.parseInt(st[0]);
    int b=Integer.parseInt(st[1]);
    int input[]=new int[n];
    st=br.readLine().split(" ");
    for(int i=0;i<n;i++){
        input[i]=Integer.parseInt(st[i]);
    }
    int c=0;
    ArrayList<Integer> list=new ArrayList<>();

    for(int i=0;i<n;i++){
        if(input[i]%2==0){
            c++;
        }
        else{
            c--;
        }
        if(c==0){
            if(i+1<n)
            list.add(Math.abs(input[i+1]-input[i]));
        }
    }
    Collections.sort(list);
    int i=0;

    for(i=0;i<list.size()&&b>=list.get(i);i++){
        b-=list.get(i);
    }

    System.out.println(i);

	}
}

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

import static java.lang.Math.*;

public class Main implements Runnable {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception {
        new Thread(null, new Main(),"Main",1<<26).start();
    }

    static long modPow(long a,long p,long m){ long ans=1;while (p>0){ if(p%2==1)ans=(ans*a)%m;a=(a*a)%m;p>>=1; }return ans; }
    static long modInv(long a,long m){return modPow(a,m-2,m);}

    static int dp[][][];

    int f(int i,int a[],int n,int k,int sum,int odd,int count){
        if(i==n)return 0;
        //System.out.println(i+" "+odd+" "+count);
        if(dp[i][sum][odd]!=-1)return dp[i][sum][odd];
        int p1=0,p2=0;
        if(sum+Math.abs(a[i]-a[i-1])<=k && count-odd==odd){
            p1=1+f(i+1,a,n,k,sum+Math.abs(a[i]-a[i-1]),(a[i]%2==1?1:0),1);
        }
        p2=f(i+1,a,n,k,sum,(odd+(a[i]%2==1?1:0)),count+1);
        return dp[i][sum][odd]=Math.max(p1,p2);
    }

    public void run() {
        InputReader sc = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i]=sc.nextInt();
        }
        dp=new int[101][101][101];
        for (int i = 0; i <101 ; i++) {
            for (int j = 0; j <101 ; j++) {
                for (int l = 0; l <101 ; l++) {
                    dp[i][j][l]=-1;
                }
            }
        }

        int ans=f(1,a,n,k,0,(a[0]%2==1?1:0),1);
        out.println(ans);
        out.close();
    }

}

import java.util.*;

public class Codeforces{
    public static void main(String []args){
        Scanner cin  = new Scanner(System.in);

        int n  = cin.nextInt();
        int b = cin.nextInt();

        LinkedList<Integer> l = new LinkedList<>();

        int []r = new int[n];
        for (int i = 0; i < n; i++) {
            r[i] = cin.nextInt();
        }

        int []a = new int [2];
        for (int i = 0; i < n; i+=2) {
            ++a[r[i] % 2];
            ++a[r[i+1] % 2];
            if(a[0] == a[1] && i+1 < n && i+2 < n)
                insertSorted(l , Math.abs(r[i+2] - r[i+1]));
        }
        int count = 0;
        for (int i = l.size() - 1; i >= 0 && b > 0; i--) {
            if(l.get(i) <= b){
                ++count;
                b -= l.get(i);
            }
        }

        System.out.println(count);
    }
    public static void insertSorted(LinkedList<Integer> l , int e){
        int i = 0;
        while(i < l.size() && l.get(i) >= e)
            ++i;
        l.add(i, e);
    }
}

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

/**
* @author soumitri12
*/

/* Name of the class has to be "Main" only if the class is public*/
public class CF998B
{
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

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

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

    static class Node {

        long pp;
        long a, b;

        Node(long x, long y) {
            a = x;
            b = y;
            pp = a * b;
        }
    }
    static class Comp implements Comparator<Node> {

        public int compare(Node o1, Node o2) {
            if (o1.pp > o2.pp) {
                return 1;
            } else {
                return -1;
            }
        }
    }
    static int gcd(int x, int y)
    {
        if(y==0) return x;
        else return gcd(y,x%y);
    }
    static long mod_pow(long a, long b, long mod)
    {
        a%=mod;
        if(b==0) return 1%mod;
        if((b&1)==1) return a*(mod_pow(a,b-1,mod))%mod;
        else
        {
            long u=mod_pow(a,b>>1,mod);
            return (u*u)%mod;
        }
    }
    static long _pow(long a, long b)
    {
        if(b==0) return 1;
        if((b&1)==1) return a*_pow(a,b-1);
        else
        {
            long u=_pow(a,b>>1);
            return u*u;
        }
    }
    static int modInv(int a, int m)
    {
        if(gcd(a,m)!=1) return -999;
        else return (a%m+m)%m;
    }
    static boolean isPowerOfTwo(int x)
    {
        return x!=0 && ((x&(x-1)) == 0);
    }
    static boolean isprime(int x)
    {
        for(int i=2;i<=Math.sqrt(x);i++)
        {
            if(x%i==0) return false;
        }
        return true;
    }
    static boolean prime[];
    static final int INT_MAX=1000007;

    static void sieve() {
        prime=new boolean[INT_MAX];
        Arrays.fill(prime,true);
        prime[0]=prime[1]=false;
        for(int i=2;i<=Math.sqrt(INT_MAX);i++)
        {
            if(prime[i]) {
                for(int j=i*2;j<INT_MAX;j+=i)
                prime[j]=false;
            }
        }
    }
    static class Pair {
        int ff,ss;
        public Pair(int ff,int ss) {
            this.ff=ff; this.ss=ss;
        }
    }

    public static void main(String[] args) {
        FastReader sc=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        StringBuffer sb=new StringBuffer();
        //your code starts here
        int n=sc.nextInt(),w=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();

        ArrayDeque<Integer> stack=new ArrayDeque<>();
        stack.push(a[0]);
        ArrayList<Integer> cuts=new ArrayList<>();
        for(int i=1;i<n-2;i++)
        {
            if(!stack.isEmpty()) {
                if((stack.peek()&1)==(a[i]&1)) stack.push(a[i]);
                else {
                    cuts.add(Math.abs(a[i+1]-a[i])); stack.pop();
                }
            } else stack.push(a[i]);
        }
        /** knapsack :
         * max_wt = w , items_list = cuts
         * we need nos of items s.t. wt <= max_wt
         * */
        n=cuts.size();
        int dp[][]=new int[n+1][w+1];
        for(int i=0;i<=n;i++) {
            for(int j=0;j<=w;j++) {
                if(i*j==0) dp[i][j]=0;
            }
        }
        for(int i=1;i<=n;i++) {
            for(int j=1;j<=w;j++) {
                if(cuts.get(i-1)<=j) {
                    dp[i][j]=Math.max(1+dp[i-1][j-cuts.get(i-1)],dp[i-1][j]);
                } else dp[i][j]=dp[i-1][j];
            }
        }
        int ans=dp[n][w];
        out.println(ans);

        out.close();
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class contest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
ArrayList <Integer> list=new ArrayList<Integer>();
int n=in.nextInt();int odd=0;int even=0;int c=0;int sum=0;
int b=in.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
	a[i]=in.nextInt();
for(int i=0;i<n-2;i++)
{
	if(a[i]%2==1)
		odd++;
	else
		even++;
	if(odd==even&&odd!=0&&even!=0&&(a[i]%2!=a[i+1]%2))
		list.add(Math.abs(a[i+1]-a[1]));
}
Collections.sort(list);
for(int h: list)
{System.out.println(h);
	sum+=h;
	if(sum<=b)
		c++;
}
System.out.println(c);

	}

}

import java.util.*;

public class SS {
    public static void main(String[] args) {
int leftodd=0,lefteven=0,rightodd=0,righteven=0;
        List fin=new ArrayList();
int answer=0;
        Scanner in= new Scanner(System.in);
        int n=in.nextInt(),m=in.nextInt(),ans=0;
        int arr[]=new int[100000];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        for(int i=1;i<n-1;i++){
            leftodd=0;lefteven=0;rightodd=0;righteven=0;
            for(int j=0;j<n;j++){
                if(j<=i)// 1 [2] | 3 4
                {
                    if(arr[j]%2==0)
                        lefteven++;
                    else
                        leftodd++;

                }
                else if(j>i)
                {
                    if(arr[j]%2==0)
                        righteven++;
                    else
                        rightodd++;
                }

            }
            if(righteven==rightodd&&lefteven==leftodd){

                    fin.add( Math.abs(arr[i] - arr[i + 1]));
            }
        }
        Collections.sort(fin);
        Iterator iterator=fin.iterator();
boolean bool=false;
        while(iterator.hasNext()) {

           //  System.out.println(iterator.next());
           int it=(int)iterator.next();
            //ans += (int) iterator.next();
            if(ans+it>m){
                System.out.println(answer);
                break;
            }
            else {
                answer++;
                ans+=it;
                if(iterator.hasNext())
                    bool=false;
                else
                    bool=true;
            }
if(bool)
            System.out.println(answer);
           /* if ((ans > m)) {
                System.out.println(answer);
                break;
            }
            else {
                answer++;

            }*/
        }

        //System.out.println(answer);

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Collections;

public class A {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int  n = fs.nextInt(); int b = fs.nextInt();
        int[] ar = fs.readArray(n);
        var ans = new ArrayList<Integer>();
        int odds = 0;
        int evens = 0;
        for (int i = 0; i<n-1; i++) {
            if (i%2 == 0) {
                evens++;
            } else {
                odds++;
            }
            if (odds == evens) {
                ans.add(Math.abs(ar[i]-ar[i+1]));
                evens=0;
                odds = 0;

            }

        }
        Collections.sort(ans);
        int sum = 0;
        int c = 0;
        for (int i = 0; i<ans.size(); i++) {
            sum+= ans.get(i);
            if (sum>b) {
                break;
            } else {
                c++;
            }
        }
        int e=0;
        int o=0;
        for (int i = 0; i<(n/2); i++) {
            if (ar[i]%2 == 0) {
                e++;
            } else {
                o++;
            }
        }
        if (o == n/2 || e == n/2) {
            System.out.println(0);
        } else {
            System.out.println(c);
        }

    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}

import java.util.*;

public class Helloworld {

    public static void main(String[] args) {
       int []arr=new int[100];
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int[] array = new int[a];
        for (int i = 0; i < a; i++) {
            array[i] = s.nextInt();
        }
        int result = 0;
        for (int i = 0; i < a / 2 - 1; i++) {
            int counteven = 0, countodd = 0, counter = 1, diff;
            for (int j = 0; j <= counter; j++) {
                if (array[j] % 2 == 0) {
                    counteven++;
                } else {
                    countodd++;
                }
            }
            if(counteven==countodd){
            arr[i]=(Math.abs(array[1 + counter] - array[counter]));
            }
            counter += 2;
        }
        Arrays.sort(arr);
        for(int i=0;i<arr.length;i++){
            b-=arr[i];
            if(b>=0 && arr[i]!=0)
                result++;
        }
        System.out.println(result);
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @Created by sbhowmik on 15/12/18
 */
public class Cutting {

    static public class CuttingObject {
        int x;
        int y;
        CuttingObject(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String []args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int t = scanner.nextInt();
        int arr[] = new int[n];
        int i = 0;
        while ( i < n) {
            arr[i++] = scanner.nextInt();
        }
        int count = 0;
        int count1 = 0;
        ArrayList<CuttingObject> cuttingObjects = new ArrayList<>();
        for (i = 0; i < arr.length; i++) {
            if (arr[i]%2==0) {
                count++;
            } else {
                count1++;
            }
            cuttingObjects.add(new CuttingObject(count1, count));
        }
        int dp[] = new int[n];
        int l = 0;
        for (i = 0; i < cuttingObjects.size(); i++) {
            if ((cuttingObjects.get(i).y == cuttingObjects.get(i).x) && i!=arr.length - 1) {
                dp[l++] = arr[i+1] - arr[i];
            }
        }
        if(l == 0) {
            System.out.println(0);
        } else {
            Arrays.sort(dp, 0, l);
            int printCount = 0;
            for (i = 0; i < l; i++) {
                if (t>=0 && (t- Math.abs(dp[i])>=0)) {
                    t = t - Math.abs(dp[i]);
                    printCount++;
                }
            }
            System.out.println(printCount);
        }
    }
}

//package CodeForces_practice;

import java.util.ArrayList;
import java.util.Scanner;

public class B998 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		int b=s.nextInt();
		int [] arr=new int[t];
		boolean [] pos=new boolean [t];
		int count=0;
		for(int i=0;i<t;i++)
		{
			arr[i]=s.nextInt();
			if(arr[i]%2==0)
			{
				count++;
			}
			else
			{
				count--;
			}
			if(count==0)
			{
				pos[i]=true;
			}
		}
		ArrayList<Integer> li=new ArrayList<>();
		for(int i=1;i<arr.length-1;i++)
		{
			if(pos[i])
			{
				li.add(Math.abs(arr[i]-arr[i+1]));
			}
		}
		System.out.println(li);
		int [] cost=new int[li.size()];
		for(int i=0;i<li.size();i++)
		{
			cost[i]=li.get(i);
		}
		dp(cost,b);

	}
	public static void dp(int [] arr,int cost)
	{
		int [][] dp=new int [cost+1][arr.length+1];
		for(int i=0;i<cost+1;i++)
		{
			for(int j=0;j<arr.length+1;j++)
			{
				if(i==0||j==0)
				{
					dp[i][j]=0;
				}
				else
				{
					int ti=i-arr[j-1];
					if(ti>=0)
					{
						dp[i][j]=Integer.max(dp[ti][j-1]+1, dp[cost][j-1]);
					}
					else
					{
						dp[i][j]=dp[i][j-1];
					}
				}
			}
		}
		System.out.println(dp[dp.length-1][dp[0].length-1]);
	}

}

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

// Driver program to read from file/System.in and increase stack size
public class Main implements Runnable {
  private final InputReader in;
  private final OutputWriter out;

  private Main(InputReader ir, OutputWriter or) {
    in = ir;
    out = or;
  }

  public static void main(String[] args) throws Exception {
    InputStream is = args.length > 0 ? new FileInputStream(args[0]) : System.in;
    InputReader in = new InputReader(is);
    OutputWriter out = new OutputWriter(System.out);
    Main r = new Main(in, out);
    new Thread(null, r, "Main", 1 << 26).start(); // 64 mb stack size
  }

  @Override
  public void run() {
    try {
      Solution.main(in, out);
    } finally {
      out.close();
    }
  }
}

// Fast I/O
// Taken and modified from here:
// https://www.quora.com/What-is-the-best-way-in-Java-to-take-input-and-write-output-for-an-Online-Judge
class InputReader {
  private InputStream is;
  private byte[] buff = new byte[8 * 1024];
  private int curChar;
  private int numChars;

  InputReader(InputStream is) {
    this.is = is;
  }

  int read() {
    if (numChars == -1) throw new InputMismatchException();
    if (curChar >= numChars) {
      curChar = 0;
      try {
        numChars = is.read(buff);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (numChars <= 0) return -1;
    }
    return buff[curChar++];
  }

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

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

  double nextDouble() {
    int c = read();
    while (isSpaceChar(c)) c = read();
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    double res = 0;
    while (!isSpaceChar(c) && c != '.') {
      if (c == 'e' || c == 'E')
        return res * Math.pow(10, nextInt());
      if (c < '0' || c > '9')
        throw new InputMismatchException();
      res *= 10;
      res += c - '0';
      c = read();
    }
    if (c == '.') {
      c = read();
      double m = 1;
      while (!isSpaceChar(c)) {
        if (c == 'e' || c == 'E') return res * Math.pow(10, nextInt());
        if (c < '0' || c > '9') throw new InputMismatchException();
        m /= 10;
        res += (c - '0') * m;
        c = read();
      }
    }
    return res * sgn;
  }

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

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

  String next() {
    return nextString();
  }

  int[] nextIntArray(int size) {
    int[] arr = new int[size];
    for (int i = 0; i < size; i++) arr[i] = nextInt();
    return arr;
  }
}
class OutputWriter {
  private final PrintWriter writer;

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

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

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

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

  void printf(String format, Object... objects) {
    writer.printf(format, objects);
  }

  void printfln(String format, Object... objects) {
    writer.printf(format + "\n", objects);
  }

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

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

class Solution {
  static void main(InputReader in, OutputWriter out) {
    int n = in.nextInt();
    int b = in.nextInt();
    int[] a = in.nextIntArray(n);
    int[] podd = new int[n - 1];
    int[] peven = new int[n - 1];
    if (a[0] % 2 == 0) peven[0]++;
    else podd[0]++;
    for (int i = 1; i < n - 1; i++) {
      peven[i] = peven[i - 1];
      podd[i] = podd[i - 1];
      if (a[i] % 2 == 0) peven[i]++;
      else podd[i]++;
    }
    int[] sodd = new int[n - 1];
    int[] seven = new int[n - 1];
    if (a[n - 2] % 2 == 0) seven[n - 2]++;
    else sodd[n - 2]++;
    for (int i = n - 3; i >= 0 ; i--) {
      seven[i] = seven[i + 1];
      sodd[i] = sodd[i + 1];
      if (a[i] % 2 == 0) seven[i]++;
      else sodd[i]++;
    }
    List<Integer> cuts = new ArrayList<>(n - 1);
    for (int i = 0; i < n - 1; i++) {
      int cut = Math.abs(a[i] - a[i + 1]);
      if (peven[i] == podd[i] && seven[i] == sodd[i] && cut <= b) {
        cuts.add(cut);
      }
    }
    cuts.sort(Comparator.naturalOrder());
    int ans = 0;
    for (int i = 0; i < cuts.size(); i++) {
      int cut = cuts.get(i);
      if (b > cut) {
        ans++;
        b -= cut;
      } else {
        break;
      }
    }
    out.println(ans);
  }
}

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

public class Codechef{

    public static void main(String []args){
    	Scanner sc=new Scanner(System.in);
    	int n=sc.nextInt();
    	int b=sc.nextInt();
    	int arr[]=new int[n];
    	for(int i=0;i<n;i++){
    		arr[i]=sc.nextInt();

    	}
    	int count=0;
    	ArrayList<Integer> arr1=new ArrayList<Integer>();
    	for(int i=0;i<arr.length-1;i++){
    		if(arr[i]%2==0){

    	        	count++;

    		}else{

    				count--;

    		}
    		if(count==0){
    			if((i+1)<n){
                  arr1.add((int)Math.abs(arr[i+1])-arr[i]);
    			}
    		}
    	}int count1=0;
    	for(int i=0;i<arr1.size();i++){
    		if(b>=arr1.get(i)){
    			count1++;
    			    		b=b-arr1.get(i);

    		}
    	}
    	System.out.println(count1);

}
}

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

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		FastReader sc=new FastReader();
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[]=new int[n];
		//int b[]=new int[n];
		int c1=0,c2=0,sum=0;
		//ArrayList<ArrayList<Integer>> xy=new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<n;i++)
		{
		a[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++)
		{
		if(a[i]%2==0)
		c1++;
		else
		c2++;

		if(c1==c2 && i!=n-1 && (sum+a[i+1]-a[i]<=k))
		{
		 // ArrayList<Integer> pq=new ArrayList<Integer>();
		  //pq.add(i);
		  //pq.add(i+1);

		  sum=sum + a[i+1]-a[i];
		 // System.out.println(c1+" "+c2+" "+sum+" "+i);
		  c1=0;
		  c2=0;
		}
		}
		if(n%2!=0 || sum==0)
		System.out.println(0);
		else
		System.out.println(sum);

	}
}
class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

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

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

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

    public static void main(String [] Args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int b=scan.nextInt();
        int [] arr=new int[n];
        int countOdd=0;
        int countEven=0;
        ArrayList<Integer> al=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            arr[i]=scan.nextInt();
        }
        for(int i=0;i<n;i++){
            if(arr[i]%2==0){
                countEven+=1;
            }else{
                countOdd+=1;
            }
            if(countOdd==countEven){
                al.add(Math.abs(arr[i]-arr[i-1]));
            }
        }
        Collections.sort(al);
        long sum=0,count=0;
        for(int i=0;i<al.size();i++){
            sum+=al.get(i);
            if(sum<=b){
                count+=1;
            }
        }
        System.out.println(count);
    }

}

import java.io.*;
import java.util.*;
public class Cutting
{
	public static void main(String[] s)
	{
		Scanner sc=new Scanner(System.in);
		int a[],odd=0,even=0,n,b=0,i,count=0;
		n=sc.nextInt();
		b=sc.nextInt();
		a=new int[n];
		ArrayList<Integer> ar=new ArrayList<>();
		for(i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
			if(a[i]%2==0)
				even++;
			else
				odd++;
			if(i!=0 && i!=(n-1))
			{
				if(even==odd)
				{
					ar.add((a[i+1]-a[i]));
				}
			}
		}
		Collections.sort(ar);
		for(int j:ar)
		{
			if(j<=b)
			{
				b-=j;
				count++;
			}
			else
				break;
		}
		System.out.println(count);
	}
}

import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.math.BigInteger;
public class HHAL
{
	public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        	st = new StringTokenizer(br.readLine());
        	int y[]=new int[n+2];
        	int even[]=new int[n+2];
        	int odd[]=new int[n+2];
        	int p=1,sum=0;
        	while (st.hasMoreTokens()) {
        		y[p]=Integer.parseInt(st.nextToken());
        		if(y[p]%2==0)
        		{
        			odd[p]=odd[p-1];
        			even[p]=even[p-1]+1;
        		}
        		else
        		{
        			even[p]=even[p-1];
        			odd[p]=odd[p-1]+1;
        		}
        		p++;
        	}
        	ArrayList<Integer> ml=new ArrayList<Integer>();
        	for (int i=1;i<=n;i++) {
        		if(even[i]==odd[i] && y[i+1]-y[i]>=0)
        			ml.add(y[i+1]-y[i]);
        	}
        	int count=0;
        	if(ml.size()==0)
        		System.out.println(0);
        	else
        	{
        		sum=0;
        		for (int i=0;i<ml.size();i++) {
        			if(sum+ml.get(i) < b)
        			{
        				count++;
        				sum+=ml.get(i);
        			}
        		}
        		System.out.println(count);
        	}
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int b = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        System.out.println(maxCuttings(arr, b));
    }

    private static int maxCuttings(int[] arr, int b) {
        ArrayList<Integer> costs = new ArrayList<>();
        int numEvens = arr[0] % 2 == 0 ? 1 : 0;
        int numOdds = arr[0] % 2 == 1 ? 1 : 0;
        int numCuttings = 0;
        for (int i = 1; i < arr.length; i++) {
            if (numOdds == numEvens&& Math.abs(arr[i]-arr[i-1])<=b) {
                numEvens = 0;
                numOdds = 0;
                costs.add(Math.abs(arr[i]-arr[i-1]));
            }
            if (arr[i] % 2 == 0) ++numEvens;
            else ++numOdds;
        }
        Collections.sort(costs);
        for(int i=0;i<costs.size();i++){
            if(b<=costs.get(i))
                break;
            ++numCuttings;
            b-=costs.get(i);
        }
        return numCuttings;
    }
}

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

public class Cutting {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(tk.nextToken());
        int s = Integer.parseInt(tk.nextToken());
        ArrayList<Integer> l = new ArrayList<Integer>();
        int arr[] = new int[n];
        tk = new StringTokenizer(in.readLine());
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(tk.nextToken());
        }
        int a = 0;
        int b = 0;
        int c = 0;
        for (int j = 0; j < n; j++) {
            if (j != 0 && a == b) {
                l.add(Math.abs(arr[j] - arr[j - 1]));
            }
            if (arr[j] % 2 == 0) {
                a++;
            } else {
                b++;
            }
        }
        Collections.sort(l);
        int ans = 0;
        for (Integer m : l) {
            if (s > m) {
                ans++;
                s = s - m;
            }
        }
        System.out.println(ans);
    }
}

import java.util.*;

public class Codeforces{
    public static void main(String []args){
        Scanner cin  = new Scanner(System.in);

        int n  = cin.nextInt();
        int b = cin.nextInt();

        LinkedList<Integer> l = new LinkedList<>();

        int []r = new int[n];
        for (int i = 0; i < n; i++) {
            r[i] = cin.nextInt();
        }

        int []a = new int [2];
        for (int i = 0; i < n; i+=2) {
            ++a[r[i] % 2];
            ++a[r[i+1] % 2];
            if(a[0] == a[1] && i+1 < n && i+2 < n)
                l.addFirst(r[i+2] - r[i+1]);
        }

        int count = 0;
        for (int i = 0; i < l.size() && b > 0; i++) {
            if(l.get(i) <= b){
                ++count;
                b -= l.get(i);
            }
        }

        System.out.println(count);
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class FW {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();
        int arr[] = new int[n];
        int even = 0;
        int odd = 0;
        for(int i=0;i<n;i++)
            arr[i] = in.nextInt();
        ArrayList<Integer> al = new ArrayList<>();
        for(int i=0;i<n;i++){
            if(arr[i]%2==0)
                even++;
            else
                odd++;
           // System.out.println(even+" "+odd);
            if(i!=n-1 && even==odd) {
              //  System.out.println(Math.abs(arr[i + 1] - arr[i]));
                al.add(Math.abs(arr[i + 1] - arr[i]));
            }
        }
        Collections.sort(al);

        int ans = 0;
        for(int i=0;i<al.size();i++){
            if(b>al.get(i)){
                ans++;
                b = b-al.get(i);
            }else
                break;

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

import java.util.*;
import java.lang.*;
import java.io.*;
 public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int b=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextInt();
	    int odd=0;
	    int even=0;
	    int diff=0;
	    int cuts=0;
	    ArrayList<Integer> al=new ArrayList<>();
	    for(int i=0;i<n;i++) {
	        if(a[i]%2==0)
	        even++;
	        else
	        odd++;
	        if(even==odd && i!=n-1)
	        {
	            diff+=Math.abs(a[i]-a[i+1]);
	            al.add(diff);
	        }
	    }
	    for(Integer e:al) {
	        if(e<=b) {
	        b=b-e;
	        cuts++;
	        }

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class VirtualContest {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n];
		int counter = 0;
		List<Integer> al = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
			if(a[i]%2==0) {
				counter++;
			}
			else {
				counter--;
			}
			if(counter==0 && i!=n-1) {
				al.add(Math.abs(a[i]-a[i+1]));
			}
		}
		Collections.sort(al);
		int count=0;
		int sum=0;
		for(int i:al) {
			if(sum+i<k) {
				sum+=i;
				count++;
			}
			else {
				break;
			}
		}
		System.out.println(count);

	}

}

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

public class TaskB
{
	public static void main(String[] args)
	{
		new TaskB(System.in, System.out);
	}

	static class Solver implements Runnable
	{
		int n, b;
		int[] arr;
//		BufferedReader in;
		InputReader in;
		PrintWriter out;

		void solve() throws IOException
		{
			n = in.nextInt();
			b = in.nextInt();
			arr = in.nextIntArray(n);

			PriorityQueue<Integer> set = new PriorityQueue<>(Integer::compareTo);
			int odd = 0;
			int even = 0;

			for (int i = 0; i < n; i++)
			{
				if (arr[i] % 2 == 0)
					even++;
				else
					odd++;

				if (i < n - 1 && even == odd)
					set.add(Math.abs(arr[i] - arr[i - 1]));
			}

//			System.out.println("set : " + set);

			int cnt = 0;

			while (set.size() > 0)
			{
				int x = set.poll();

				if (x <= b)
				{
					cnt++;
					b -= x;
				}
				else
					break;
			}

			out.println(cnt);
		}

		void debug(Object... o)
		{
			System.err.println(Arrays.deepToString(o));
		}

//		uncomment below line to change to BufferedReader
//		public Solver(BufferedReader in, PrintWriter out)
		public Solver(InputReader in, PrintWriter out)
		{
			this.in = in;
			this.out = out;
		}

		@Override
		public void run()
		{
			try
			{
				solve();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}

			return buf[curChar++];
		}

		public int nextInt()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public int[] nextIntArray(int arraySize)
		{
			int array[] = new int[arraySize];

			for (int i = 0; i < arraySize; i++)
				array[i] = nextInt();

			return array;
		}

		public long nextLong()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sign = 1;

			if (c == '-')
			{
				sign = -1;

				c = read();
			}

			long result = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				result *= 10;
				result += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return result * sign;
		}

		public long[] nextLongArray(int arraySize)
		{
			long array[] = new long[arraySize];

			for (int i = 0; i < arraySize; i++)
				array[i] = nextLong();

			return array;
		}

		public float nextFloat()
		{
			float result, div;
			byte c;

			result = 0;
			div = 1;
			c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean isNegative = (c == '-');

			if (isNegative)
				c = (byte) read();

			do
			{
				result = result * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					result += (c - '0') / (div *= 10);

			if (isNegative)
				return -result;

			return result;
		}

		public double nextDouble()
		{
			double ret = 0, div = 1;
			byte c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean neg = (c == '-');

			if (neg)
				c = (byte) read();

			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);

			if (neg)
				return -ret;

			return ret;
		}

		public String next()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do
			{
				res.appendCodePoint(c);

				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public String nextLine()
		{
			int c = read();

			StringBuilder result = new StringBuilder();

			do
			{
				result.appendCodePoint(c);

				c = read();
			} while (!isNewLine(c));

			return result.toString();
		}

		public boolean isNewLine(int c)
		{
			return c == '\n';
		}

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

		public void close()
		{
			try
			{
				stream.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

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

	}

	static class CMath
	{
		static long power(long number, long power)
		{
			if (number == 1 || number == 0 || power == 0)
				return 1;

			if (power == 1)
				return number;

			if (power % 2 == 0)
				return power(number * number, power / 2);
			else
				return power(number * number, power / 2) * number;
		}

		static long modPower(long number, long power, long mod)
		{
			if (number == 1 || number == 0 || power == 0)
				return 1;

			number = mod(number, mod);

			if (power == 1)
				return number;

			long square = mod(number * number, mod);

			if (power % 2 == 0)
				return modPower(square, power / 2, mod);
			else
				return mod(modPower(square, power / 2, mod) * number, mod);
		}

		static long moduloInverse(long number, long mod)
		{
			return modPower(number, mod - 2, mod);
		}

		static long mod(long number, long mod)
		{
			return number - (number / mod) * mod;
		}

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

		static long min(long... arr)
		{
			long min = arr[0];

			for (int i = 1; i < arr.length; i++)
				min = Math.min(min, arr[i]);

			return min;
		}

		static long max(long... arr)
		{
			long max = arr[0];

			for (int i = 1; i < arr.length; i++)
				max = Math.max(max, arr[i]);

			return max;
		}

		static int min(int... arr)
		{
			int min = arr[0];

			for (int i = 1; i < arr.length; i++)
				min = Math.min(min, arr[i]);

			return min;
		}

		static int max(int... arr)
		{
			int max = arr[0];

			for (int i = 1; i < arr.length; i++)
				max = Math.max(max, arr[i]);

			return max;
		}

	}

	static class Utils
	{
		static boolean nextPermutation(int[] arr)
		{
			for (int a = arr.length - 2; a >= 0; --a)
			{
				if (arr[a] < arr[a + 1])
				{
					for (int b = arr.length - 1; ; --b)
					{
						if (arr[b] > arr[a])
						{
							int t = arr[a];

							arr[a] = arr[b];
							arr[b] = t;

							for (++a, b = arr.length - 1; a < b; ++a, --b)
							{
								t = arr[a];
								arr[a] = arr[b];
								arr[b] = t;
							}

							return true;
						}
					}
				}
			}

			return false;
		}

	}

	public TaskB(InputStream inputStream, OutputStream outputStream)
	{
//		uncomment below line to change to BufferedReader
//		BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Thread thread = new Thread(null, new Solver(in, out), "TaskB", 1 << 29);

		try
		{
			thread.start();
			thread.join();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		finally
		{
			in.close();
			out.flush();
			out.close();
		}
	}

}

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

    public static void main(String [] Args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int b=scan.nextInt();
        int [] arr=new int[n];
        int countOdd=0,remOdd=0;
        int countEven=0,remEven=0;
        ArrayList<Integer> al=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            arr[i]=scan.nextInt();
            if(arr[i]%2==0){
                remEven+=1;
            }else{
                remOdd+=1;
            }
        }
        for(int i=0;i<n-1;i++){
            if(arr[i]%2==0){
                countEven+=1;
                remEven-=1;
            }else{
                countOdd+=1;
                remOdd-=1;
            }
            if(countOdd==countEven && remEven==remOdd){
                al.add(Math.abs(arr[i]-arr[i-1]));
            }
        }
        Collections.sort(al);
        long sum=0,count=0;
        for(int i=0;i<al.size();i++){
            sum+=al.get(i);
            if(sum<=b){
                count+=1;
            }
        }
        System.out.println(count);
    }

}

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

public class Cutting{

    public static int[]strToIntArr(String s){
	//	s = s.substring(1,s.length()-1);
	String[] sArr = s.split(" ");
	int len = sArr.length;
	int[] retArr = new int[len];
	for(int i=0;i<len;i++){
	    retArr[i] = Integer.parseInt(sArr[i]);
	}
	return retArr;
    }

    boolean checkSub(int[]aArr,int splitInd){
	boolean correct = true;
	int nEven = 0;
	int nOdd = 0;
	for(int i=0;i<splitInd;i++){
	    int el = aArr[i];
	    if((el%2)==0){
		nEven++;
	    }else{
		nOdd++;
	    }
	}
	if(nEven!=nOdd){
	    correct = false;
	}
	return correct;
    }

    int getMinAvailInd(int[]aArr, int nCoins, Hashtable<Integer,Boolean>cutUsed){
	int len = aArr.length;
	int minInd = -1;
	int minCost = 100000000;
	//between 2 els
	for(int i=1;i<(len-1);i++){
	    int cost = Math.abs(aArr[i]-aArr[i+1]);
	    if(cost<minCost){
		if(checkSub(aArr,i)){
		    if(!cutUsed.containsKey(i)){
			minCost = cost;
			minInd = i;
		    }
		}
	    }
	}
	return minInd;
    }

    public int getMaxCuts(int n, int b, int[]aArr){
	int nCoins = b;
	int nCuts = 0;
	Hashtable<Integer,Boolean>cutUsed = new Hashtable<Integer,Boolean>();
	while(nCoins>0){
	    int ind = getMinAvailInd(aArr,nCoins,cutUsed);
	    //	    System.out.format("found ind %d\n",ind);
	    if(ind>-1){
		cutUsed.put(ind,true);
		int cost = Math.abs(aArr[ind]-aArr[ind+1]);
		nCoins-=cost;
		nCuts++;
	    }else{
		break;
	    }
	}
	return nCuts;
    }

    public static void main(String[]args) throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	String nbLn = br.readLine();
	String aLn =  br.readLine();
	int[]nbArr = strToIntArr(nbLn);
	int[]aArr = strToIntArr(aLn);
	Cutting cut = new Cutting();
	int n = nbArr[0];
	int b = nbArr[1];
	int maxC = cut.getMaxCuts(n,b,aArr);
	bw.write(Integer.toString(maxC));
	bw.newLine();
	bw.flush();
    }

}

import java.util.*;
import java.io.*;
public class Main{
	static int i,j,k,l,temp,count;
  static LinkedList<Integer> adj[];
	static boolean visited[];
	static Iterator<Integer> itr;
	public static void main(String[] args) throws IOException{
		/*
		.
		.
		.
		.
		.
		.
		*/
		int  n=ni();
		int b=ni();
		int arr[]=nia(n);
		int dp[]=new int[n];
		int odd=0;
		int even=0;
		l=0;
		j=1;
		for(i=0;i<(n-1);i++){
			if(arr[i]%2==0)
				even++;
			else
				odd++;
			if(even==odd){
				dp[j]=arr[i+1]-arr[i];
				j++;
			}
		}
		Arrays.sort(dp,0,j);
		for(i=1;i<j;i++){
			dp[i] += dp[i-1];
			if(dp[i]<b)
				l=i;
		}
		sop(l);
		/*
		.
		.
		.
		.
		.
		.
		.
		*/
	}
	/*
	temporary functions
	.
	.
	*/

	/*
	fuctions
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	abcdefghijklmnopqrstuvwxyz
	.
	.
	.
	.
	.
	.
	*/
	static int modulo(int j,int m){
		if(j<0)
			return m+j;
		  if(j>=m)
			return j-m;

			return j;
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=true;
	static Reader in=new Reader();
	static StringBuilder ans=new StringBuilder();
	static long powm(long a,long b,long m){
		long an=1;
		long c=a;
		while(b>0){
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void sop(Object a){System.out.println(a);}
	static int ni(){return in.nextInt();}
	static int[] nia(int n){int a[]=new int[n];for(int i=0;i<n;i++)a[i]=ni();return a;}
	static long nl(){return in.nextLong();}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String ns(){return in.next();}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double nd(){return in.nextDouble();}
	static double[] nda(int n){double a[]=new double[n];for(int i=0;i<n;i++)a[i]=nd();return a;}
	static class Reader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public Reader(){
			reader=new BufferedReader(new InputStreamReader(System.in),32768);
			tokenizer=null;
		}
		public String next(){
			while(tokenizer==null || !tokenizer.hasMoreTokens()){
				try{
					tokenizer=new StringTokenizer(reader.readLine());
				}
				catch(IOException e){
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
	}
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class contest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
ArrayList <Integer> list=new ArrayList<Integer>();
int n=in.nextInt();int odd=0;int even=0;int c=0;int sum=0;int ans;
int b=in.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
	a[i]=in.nextInt();
for(int i=0;i<n-2;i++)
{
	if(a[i]%2==1)
		odd++;
	else
		even++;
	if(odd==even&&odd!=0&&even!=0&&(a[i]%2!=a[i+1]%2))
		{ans=a[i+1]-a[i];
		list.add(Math.abs(ans));}
}
Collections.sort(list);
for(int h: list)
{
	sum+=h;
	if(sum<=b)
		c++;
}

System.out.println(c);

	}

}

import java.util.Scanner;

public class NewClass1 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();
        int f[]=new int[n];
        for (int i = 0; i < n; i++) {
            f[i]=in.nextInt();
        }
        int c1=0, c2=0, count=0, summ=0;
        for (int i = 0; i < n-1; i++) {
            if (f[i]%2==0) c1++;
            else c2++;
            if (c1!=0 && c1==c2){
                summ+=Math.abs(f[i+1]-f[i]);
                if(summ<=b){
                    count++;
                    c1=0; c2=0;
                }
            }
        }
        System.out.println(count);
    }
}

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

// Driver program to read from file/System.in and increase stack size
public class Main implements Runnable {

  private final InputReader in;
  private final OutputWriter out;

  private Main(InputReader ir, OutputWriter or) {
    in = ir;
    out = or;
  }

  public static void main(String[] args) throws Exception {
    InputStream is = args.length > 0 ? new FileInputStream(args[0]) : System.in;
    InputReader in = new InputReader(is);
    OutputWriter out = new OutputWriter(System.out);
    Main r = new Main(in, out);
    new Thread(null, r, "Main", 1 << 26).start(); // 64 mb stack size
  }

  @Override
  public void run() {
    try {
      Solution.main(in, out);
    } finally {
      out.close();
    }
  }
}

// Fast I/O
// Taken and modified from here:
// https://www.quora.com/What-is-the-best-way-in-Java-to-take-input-and-write-output-for-an-Online-Judge
class InputReader {

  private InputStream is;
  private byte[] buff = new byte[8 * 1024];
  private int curChar;
  private int numChars;

  InputReader(InputStream is) {
    this.is = is;
  }

  int read() {
    if (numChars == -1) {
      throw new InputMismatchException();
    }
    if (curChar >= numChars) {
      curChar = 0;
      try {
        numChars = is.read(buff);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (numChars <= 0) {
        return -1;
      }
    }
    return buff[curChar++];
  }

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

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

  double nextDouble() {
    int c = read();
    while (isSpaceChar(c)) {
      c = read();
    }
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    double res = 0;
    while (!isSpaceChar(c) && c != '.') {
      if (c == 'e' || c == 'E') {
        return res * Math.pow(10, nextInt());
      }
      if (c < '0' || c > '9') {
        throw new InputMismatchException();
      }
      res *= 10;
      res += c - '0';
      c = read();
    }
    if (c == '.') {
      c = read();
      double m = 1;
      while (!isSpaceChar(c)) {
        if (c == 'e' || c == 'E') {
          return res * Math.pow(10, nextInt());
        }
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        m /= 10;
        res += (c - '0') * m;
        c = read();
      }
    }
    return res * sgn;
  }

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

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

  String next() {
    return nextString();
  }

  int[] nextIntArray(int size) {
    int[] arr = new int[size];
    for (int i = 0; i < size; i++) {
      arr[i] = nextInt();
    }
    return arr;
  }
}

class OutputWriter {

  private final PrintWriter writer;

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

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

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

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

  void printf(String format, Object... objects) {
    writer.printf(format, objects);
  }

  void printfln(String format, Object... objects) {
    writer.printf(format + "\n", objects);
  }

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

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

class Solution {

  static void main(InputReader in, OutputWriter out) {
    int n = in.nextInt();
    int b = in.nextInt();
    int[] a = in.nextIntArray(n);
    if (n < 4) {
      out.println(0);
      return;
    }

    int[] p = new int[n - 1]; // odd
    p[0] = a[0] % 2;
    for (int i = 1; i < n - 1; i++) {
      p[i] = p[i - 1] + a[i] % 2;
    }

    int[] s = new int[n - 1]; // odd
    s[n - 2] = a[n - 1] % 2;
    for (int i = n - 3; i >= 0; i--) {
      s[i] = s[i + 1] + a[i] % 2;
    }

    List<Integer> cuts = new ArrayList<>(n - 1);
    for (int i = 1; i < n - 2; i += 2) {
      if (p[i] == (i + 1) / 2 && s[i] == (n - i - 1) / 2) {
        cuts.add(Math.abs(a[i] - a[i + 1]));
      }
    }
    cuts.sort(Comparator.naturalOrder());
    int ans = 0;
    for (int cut : cuts) {
      if (cut > b) {
        break;
      }
      ans++;
      b -= cut;
    }
    out.println(ans);
  }
}

import java.util.*;

public class code3 {

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

			}
			System.out.println(count);
		}

	}

}

import java.util.*;
import java.lang.*;
import java.io.*;
public class Prac {

    public static void main(String[] args) {
           Scanner sc=new Scanner(System.in);

         int n=sc.nextInt();
         int b=sc.nextInt();
         int i,j=0;
         int count=0;
         int arr[]=new int[n];
         int cut[]=new int[n];

         for(i=0;i<n;i++){
             arr[i]=sc.nextInt();
         }
         int even=0,odd=0;
         for(i=0;i<n;i++){
             if(arr[i]%2==0)
                 even++;
             else
                 odd++;
             if(even==odd&&i!=n-1){
                 cut[j]=i+1;
                 even=odd=0;
                 j++;
             }
         }
         if(j>1){

         int bitcoin[]=new int[j];
         for(i=0;i<j;i++){
             bitcoin[i]=arr[cut[i]]-arr[cut[i]-1];
             if(bitcoin[i]<0)
                 bitcoin[i]*=-1;
         }

         Arrays.sort(bitcoin);
         if(bitcoin[0]>b)
             count=0;
         else
         {
            for(i=1;i<j;i++){
                bitcoin[i]+=bitcoin[i-1];
                if(bitcoin[i]>b){
                    count=i;
                    break;
                }
                else
                    count=i+1;
            }

         }
         }
         else{
             if(j==1&&arr[cut[0]]-arr[cut[0]-1]>=b)
                 count=1;
             else
                 count=0;
         }
         System.out.println(count);
    }
}

import java.util.*;

public class Helloworld {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int[] array = new int[a];
        for (int i = 0; i < a; i++) {
            array[i] = s.nextInt();
        }
        int result = 0;
        for (int i = 0; i < a / 2 - 1; i++) {
            int counteven = 0, countodd = 0, counter = 1, diff;
            for (int j = 0; j <= counter; j++) {
                if (array[j] % 2 == 0) {
                    counteven++;
                } else {
                    countodd++;
                }
            }
            if (Math.abs(array[1 + counter] - array[counter]) < b) {
                b = b - (Math.abs(array[1 + counter] - array[counter]));
                if (counteven == countodd && b >= 0) {
                    result++;
                }
            }
            counter += 2;
        }
        System.out.println(result);

    }
}

//package CodeForces;

import java.util.Scanner;

public class Cutting {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int B=s.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
		}

		int cut=0;
		int odd=0;
		int even=0;
		for(int i=0;i<n;i++)
		{
			if(arr[i]%2==0)
			{
				even++;
			}
			else
			{
				odd++;
			}

			if(even==odd&&even!=0&&i!=n-1)
			{
				if(B>=Math.max(arr[i]-arr[i+1],arr[i+1]-arr[i]))
				{
					B=B-Math.max(arr[i]-arr[i+1],arr[i+1]-arr[i]);
					cut++;
					even=0;
					odd=0;
				}
			}
		}

		System.out.println(cut);

	}

}

import java.util.*;

public class Cutting{

     public static void main(String []args){
        Scanner s = new Scanner(System.in);
        String input = s.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int bitCoins = Integer.parseInt(input.split(" ")[1]);
        String[] values = s.nextLine().split(" ");
        int odd = 0;
        int even = 0;
        int count = 0;
        for (int i = 0; i < n - 1; i++ ) {
            if(Integer.parseInt(values[i]) % 2 == 0) {
                even++;
            } else {
                odd++;
            }
            if(odd == even) {
               int val =  Integer.parseInt(values[i + 1]) - Integer.parseInt(values[i]);
               if(val < bitCoins) {
                    bitCoins = bitCoins - val;
                    count++;
               } else {
                   break;
               }
            }
        }
        System.out.println(count);
     }
}

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

/* Code written by
   Abhinav Sharma */

public class Abhi
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int b1=sc.nextInt();
		ArrayList<Integer> a=new ArrayList<Integer> ();
		ArrayList<Integer> b=new ArrayList<Integer> ();
		int i,s=0,k=0,c=0,v=0,f=0;
		for(i=0;i<n;i++)
		a.add(sc.nextInt());

		for(i=0;i<n;i++)
		{

			if(a.get(i)%2==0)
			++c;
			else if(a.get(i)%2!=0)
			++v;
			if(c==v&&i!=n-1)
			{
			s=Math.abs(a.get(i+1)-a.get(i));
			if(s<=b1){
				f+=Math.abs(a.get(i+1)-a.get(i));
				s=f;
			++k;
			c=0;
			v=0;}
		}}
		System.out.println(k);
	}
	//FAST IO
    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

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

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

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

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

        public double readDouble()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                {
                    return res * Math.pow(10, readInt());
                }
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                    {
                        return res * Math.pow(10, readInt());
                    }
                    if (c < '0' || c > '9')
                    {
                        throw new InputMismatchException();
                    }
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

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

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

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

    private 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 print(Object... objects)
        {
            for (int i = 0; i < objects.length; i++)
            {
                if (i != 0)
                {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
            writer.flush();
        }

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

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

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

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int B = scan.nextInt();

		int[] nums = new int[n];

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

		int even = 0;
		int odd = 0;
		int diff = 0;
		int cuts = 0;
		for(int i = 0; i < n-2; i++){
		    if(nums[i] % 2 == 0){
		        even++;
		    } else {
		        odd++;
		    }

		    if(even == odd && even != 0){
		        diff+= nums[i]+nums[i+1];
		        if(diff < B)
		            cuts++;
		    }
		}

		System.out.println(cuts);

	}

}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int B = reader.nextInt();
        ArrayList<Integer> cost = new ArrayList<>();
        int cnt = 0, tmp1 = 0, tmp2;
        if(n % 2 == 1){
            System.out.println(0);
            return;
        }

        int[] a = new int[n];
        for(int i = 0; i < n; i++)
            a[i] = reader.nextInt();
        for(int i = 0; i < n - 1; i++){
            if(a[i] % 2 == 0)
                cnt++;
            else
                cnt--;
            if(cnt == 0)
                cost.add(Math.abs(a[i + 1] - a[i]));
        }
        Collections.sort(cost);
        int sum = 0, i = 0;
        while (i < cost.size()){
            if(sum + cost.get(i) <= B) {
                i++;
            } else
                break;
        }
        System.out.println(i);

    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class bcbc {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int count=0;
		int freq[]=new int [n];
		for(int i=0;i<n;i++)
		{
			if(ar[i]%2==1){
				freq[i]=1;
			}else{
				freq[i]=-1;
			}
		}

		int b[]=new int[n];
		//for(int p:freq)System.out.print(p+" ");
		//System.out.println();
		int sum=0;
		for(int i=0;i<n;i++)
		{
			sum+=freq[i];
			b[i]=sum;

		}

		ArrayList<Integer> c=new ArrayList<Integer>();
		for(int i=0;i<n-1;i++)
		{
			if(b[i]==0)
			{

				c.add(Math.abs(ar[i+1]-ar[i]));

			}
		}
		Collections.sort(c);

		int pt=0;
		int cost=0;

		while(pt<count && cost+c.get(pt)<=m)
		{
			cost+=c.get(pt++);
		}
		if(pt!=0){
		System.out.println(pt+1);
		}else{
			System.out.println(0);
		}
	}
}

import java.util.*;
import java.lang.*;
import java.io.*;
 public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int b=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextInt();
	    int odd=0;
	    int even=0;
	    int diff=0;
	    int cuts=0;
	    for(int i=0;i<n-2;i++) {
	        if(a[i]%2==0)
	        even++;
	        else
	        odd++;
	        if(even==odd && diff<=b)
	        {
	            diff+=Math.abs(a[i]+a[i+1]);
	            cuts++;
	        }
	    }
	    System.out.println(cuts);
	}
}

//  package codeforces;

/**
 * Created by sky on 1/7/18.
 * www.github.com/aakashjaiswal1
 * aakashjaiswal@hotmail.co.in
 * aakashjaiswal.in@gmail.com
 * people die if they are killed
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Created by sky on 13/4/18.
 * www.github.com/aakashjaiswal1
 * aakashjaiswal@hotmail.co.in
 * aakashjaiswal.in@gmail.com
 * people die if they are killed
 */
public class jul1 {
    public static void main(String[] args) {
        in = new FastReader();
        int n=ni();
        int B=ni();
        int[] arr=takeIntegerArrayInput(n);
        int[] odd_count=new int[n];
        int[] even_count=new int[n];
        int es=0;
        int os=0;
        for (int i=0;i<n;i++){
            int ele=arr[i];
            if (ele%2==0){
                es++;
            }else {
                os++;
            }
            odd_count[i]=os;
            even_count[i]=es;
        }
      //  System.out.println(BS(0,arr.length,arr,B,even_count,odd_count));
        PriorityQueue<Integer> pq=new PriorityQueue<>(Collections.reverseOrder());
        for (int i=0;i<arr.length-1;i++){
            int even_prev=even_count[i];
            int odd_prev=odd_count[i];
            int even_nxt=even_count[arr.length-1]-even_count[i];
            int odd_nxt=odd_count[arr.length-1]-odd_count[i];
            if (even_prev==odd_prev&&even_nxt==odd_nxt){
                pq.add(Math.abs(arr[i]-arr[i+1]));
            }

        }
        long ans=0;
        while (B>0&&pq.size()>0){
            B-=pq.poll();
            ++ans;
        }
        System.out.println(ans);
    }

    static class DS{
        int[] arr;
        int[] odd_count;
        int[] even_count;

    }
  //  public static long binarySearch(long low, long high) {
//        while (high - low > 1) {
//            long mid = (high - low)/2 + low;
//            //System.out.println(mid);
//            if (works(mid)) {
//                high = mid;
//            } else {
//                low = mid;
//            }
//        }
//        return (works(low) ? low : high);
//    }
    public  static long BS(long low,long high,int[] arr,int B,int[] evenC,int[] oddC){
        while (high - low > 1) {
            long mid = (high - low)/2 + low;
            //System.out.println(mid);
            if (works(mid,arr,B,evenC,oddC)) {
                high = mid;
            } else {
                low = mid;
            }
        }
        return (works(low,arr,B,evenC,oddC) ? low : high);
    }
    static  boolean works(long test,int[] arr,int B,int[] evenC,int[] oddC){
        PriorityQueue<Integer> Cost=new PriorityQueue<>(Collections.reverseOrder());
        for (int i=0;i<arr.length-1;i++){
            int even_count=evenC[i];
            int odd_count=oddC[arr.length-1];
            odd_count-=oddC[i];
            if (even_count==odd_count){
                Cost.add(Math.abs(arr[i]-arr[i+1]));
            }
        }

        for (int i=0;i<test;i++){
            if (Cost.size()==0){
                B=-1;
                break;
            }
            B-=Cost.poll();
        }
        if (B>=0)return true;
        return false;
    }

    static void reverse(char[] arr ,int i,int j){
        if (i==j)
            return;
        while (i<j){
            char temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
            ++i;
            --j;
        }
    }
    static int[]  takeIntegerArrayInput(int no){
        int[] arr=new int[no];
        for (int i=0;i<no;++i){
            arr[i]=ni();
        }
        return arr;
    }
    static long fast_Multiply(long no , long pow){
        long result=1;
        while (pow>0){
            if ((pow&1)==1){
                result=result*no;
            }
            no=no*no;
            pow>>=1;
        }
        return result;
    }

    static long[]  takeLongArrayInput(int no){
        long[] arr=new long[no];
        for (int i=0;i<no;++i){
            arr[i]=ni();
        }
        return arr;
    }
    static final long MOD = (long)1e9+7;
    static FastReader in;

    static void p(Object o){
        System.out.print(o);
    }

    static void pn(Object o){
        System.out.println(o);
    }

    static String n(){
        return in.next();
    }

    static String nln(){
        return in.nextLine();
    }

    static int ni(){
        return Integer.parseInt(in.next());
    }

    static int[] ia(int N){
        int[] a = new int[N];
        for(int i = 0; i<N; i++)a[i] = ni();
        return a;
    }

    static long[] la(int N){
        long[] a = new long[N];
        for(int i = 0; i<N; i++)a[i] = nl();
        return a;
    }

    static long nl(){
        return Long.parseLong(in.next());
    }

    static double nd(){
        return Double.parseDouble(in.next());
    }

    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static void println(String[] arr){
        for (int i=0;i<arr.length;++i){
            System.out.println(arr[i]);
        }
    }

}

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;
public class Main
{

    public static void main(String[] args)throws IOException
    {
        FastReader in=new FastReader(System.in);
        StringBuffer st=new StringBuffer();
        int n=in.nextInt();
        int m=in.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
        a[i]=in.nextInt();
        int od=0,ev=0,c=0;
        for(int i=0;i<n;i++){
            if(a[i]%2==0)
            ev++;
            else
            od++;
            if(ev==od){
                if(i!=n-1){
                    if(Math.abs(a[i+1]-a[i])<=m){
                        c++;ev=0;od=0;
                        //m-=(Math.abs(a[i+1]-a[i]));
                    }
                }
            }
        }

        System.out.println(c);
    }
    static class FastReader{

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan());
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }

        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}

import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.math.BigInteger;
public class HHAL
{
	public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        	st = new StringTokenizer(br.readLine());
        	int y[]=new int[n+2];
        	int even[]=new int[n+2];
        	int odd[]=new int[n+2];
        	int p=1,sum=0;
        	while (st.hasMoreTokens()) {
        		y[p]=Integer.parseInt(st.nextToken());
        		if(y[p]%2==0)
        		{
        			odd[p]=odd[p-1];
        			even[p]=even[p-1]+1;
        		}
        		else
        		{
        			even[p]=even[p-1];
        			odd[p]=odd[p-1]+1;
        		}
        		p++;
        	}
        	ArrayList<Integer> ml=new ArrayList<Integer>();
        	for (int i=1;i<n;i++) {
        		if(even[i]==odd[i])
        			ml.add(Math.abs(y[i+1]-y[i]));
        	}
        	int count=0;
        	if(ml.size()==0)
        		System.out.println(0);
        	else
        	{
        		sum=0;
        		for (int i=0;i<ml.size();i++) {
        			if(sum+ml.get(i) < b)
        			{
        				count++;
        				sum+=ml.get(i);
        			}
        		}
        		System.out.println(count);
        	}
    }
}

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

public class TaskB
{
	public static void main(String[] args)
	{
		new TaskB(System.in, System.out);
	}

	static class Solver implements Runnable
	{
		int n, b;
		int[] arr;
//		BufferedReader in;
		InputReader in;
		PrintWriter out;

		void solve() throws IOException
		{
			n = in.nextInt();
			b = in.nextInt();
			arr = in.nextIntArray(n);

			List<Integer> pts = new ArrayList<>();
			PriorityQueue<Integer> set = new PriorityQueue<>(Integer::compareTo);
			int odd = 0;
			int even = 0;

			for (int i = 0; i < n; i++)
			{
				if (arr[i] % 2 == 0)
					even++;
				else
					odd++;

				if (i < n - 1 && even == odd)
				{
					pts.add(i);
					set.add(Math.abs(arr[i] - arr[i - 1]));
				}
			}

//			System.out.println("set : " + set);

			int cnt = 0;

			while (b > 0 && set.size() > 0)
			{
				int x = set.poll();

				if (x <= b)
				{
					cnt++;
					b -= x;
				}
			}

			out.println(cnt);
		}

		void debug(Object... o)
		{
			System.err.println(Arrays.deepToString(o));
		}

//		uncomment below line to change to BufferedReader
//		public Solver(BufferedReader in, PrintWriter out)
		public Solver(InputReader in, PrintWriter out)
		{
			this.in = in;
			this.out = out;
		}

		@Override
		public void run()
		{
			try
			{
				solve();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}

			return buf[curChar++];
		}

		public int nextInt()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public int[] nextIntArray(int arraySize)
		{
			int array[] = new int[arraySize];

			for (int i = 0; i < arraySize; i++)
				array[i] = nextInt();

			return array;
		}

		public long nextLong()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sign = 1;

			if (c == '-')
			{
				sign = -1;

				c = read();
			}

			long result = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				result *= 10;
				result += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return result * sign;
		}

		public long[] nextLongArray(int arraySize)
		{
			long array[] = new long[arraySize];

			for (int i = 0; i < arraySize; i++)
				array[i] = nextLong();

			return array;
		}

		public float nextFloat()
		{
			float result, div;
			byte c;

			result = 0;
			div = 1;
			c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean isNegative = (c == '-');

			if (isNegative)
				c = (byte) read();

			do
			{
				result = result * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					result += (c - '0') / (div *= 10);

			if (isNegative)
				return -result;

			return result;
		}

		public double nextDouble()
		{
			double ret = 0, div = 1;
			byte c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean neg = (c == '-');

			if (neg)
				c = (byte) read();

			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);

			if (neg)
				return -ret;

			return ret;
		}

		public String next()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do
			{
				res.appendCodePoint(c);

				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public String nextLine()
		{
			int c = read();

			StringBuilder result = new StringBuilder();

			do
			{
				result.appendCodePoint(c);

				c = read();
			} while (!isNewLine(c));

			return result.toString();
		}

		public boolean isNewLine(int c)
		{
			return c == '\n';
		}

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

		public void close()
		{
			try
			{
				stream.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

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

	}

	static class CMath
	{
		static long power(long number, long power)
		{
			if (number == 1 || number == 0 || power == 0)
				return 1;

			if (power == 1)
				return number;

			if (power % 2 == 0)
				return power(number * number, power / 2);
			else
				return power(number * number, power / 2) * number;
		}

		static long modPower(long number, long power, long mod)
		{
			if (number == 1 || number == 0 || power == 0)
				return 1;

			number = mod(number, mod);

			if (power == 1)
				return number;

			long square = mod(number * number, mod);

			if (power % 2 == 0)
				return modPower(square, power / 2, mod);
			else
				return mod(modPower(square, power / 2, mod) * number, mod);
		}

		static long moduloInverse(long number, long mod)
		{
			return modPower(number, mod - 2, mod);
		}

		static long mod(long number, long mod)
		{
			return number - (number / mod) * mod;
		}

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

		static long min(long... arr)
		{
			long min = arr[0];

			for (int i = 1; i < arr.length; i++)
				min = Math.min(min, arr[i]);

			return min;
		}

		static long max(long... arr)
		{
			long max = arr[0];

			for (int i = 1; i < arr.length; i++)
				max = Math.max(max, arr[i]);

			return max;
		}

		static int min(int... arr)
		{
			int min = arr[0];

			for (int i = 1; i < arr.length; i++)
				min = Math.min(min, arr[i]);

			return min;
		}

		static int max(int... arr)
		{
			int max = arr[0];

			for (int i = 1; i < arr.length; i++)
				max = Math.max(max, arr[i]);

			return max;
		}

	}

	static class Utils
	{
		static boolean nextPermutation(int[] arr)
		{
			for (int a = arr.length - 2; a >= 0; --a)
			{
				if (arr[a] < arr[a + 1])
				{
					for (int b = arr.length - 1; ; --b)
					{
						if (arr[b] > arr[a])
						{
							int t = arr[a];

							arr[a] = arr[b];
							arr[b] = t;

							for (++a, b = arr.length - 1; a < b; ++a, --b)
							{
								t = arr[a];
								arr[a] = arr[b];
								arr[b] = t;
							}

							return true;
						}
					}
				}
			}

			return false;
		}

	}

	public TaskB(InputStream inputStream, OutputStream outputStream)
	{
//		uncomment below line to change to BufferedReader
//		BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Thread thread = new Thread(null, new Solver(in, out), "TaskB", 1 << 29);

		try
		{
			thread.start();
			thread.join();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		finally
		{
			in.close();
			out.flush();
			out.close();
		}
	}

}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nb = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] numbers = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        raspilBudjeta(nb[0], nb[1], numbers);
    }

    public static void raspilBudjeta(int n, int b, int[] numbers) {
        List<Integer> delimiters = new ArrayList<>();
        int even = 0, odd = 0, answer = 0;
        for (int i = 0; i < n - 2; i++) {
            if (numbers[i] % 2 == 0) {
                even++;
            } else {
                odd++;
            }
            if (even != 0 && odd != 0 && even == odd) {
                delimiters.add(Math.abs(numbers[i + 1] - numbers[i - 1]));
                even = 0;
                odd = 0;
            }
        }
        Collections.sort(delimiters);

        for (int i = 0; i < delimiters.size() && b > 0; i++) {
            Integer price = delimiters.get(i);
            if (b - price >= 0) {
                answer++;
                b -= price;
            }
        }

        System.out.println(answer);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Helloworld {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int B=Integer.parseInt(st.nextToken());
		st=new StringTokenizer(br.readLine());
		int[] arr=new int[n];
		int[] odd=new int[n];
		int[] even=new int[n];
		int o=0,e=0,cuts=0;
		for(int i=0;i<n;i++) {
			arr[i]=Integer.parseInt(st.nextToken());
			if(arr[i]%2==0) {
				e++;
			}
			else {
				o++;
			}
			if(e==o) {
				cuts++;
			}
			even[i]=e;
			odd[i]=o;
		}
		int[] cut=new int[cuts-1];
		int j=0;
		for(int i=0;i<n-1;i++) {
			if(even[i]==odd[i]) {
				cut[j]=arr[i+1]-arr[i];
				j++;
			}
		}
		Arrays.sort(cut);
		int count=0,i=0;
		while(i<cuts-1 && B>0 && cut[i]<=B) {
			B=B-cut[i];
			count++;
			i++;
		}
		System.out.println(count);
	}

}

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

public class Cutting{

    public static int[]strToIntArr(String s){
	//	s = s.substring(1,s.length()-1);
	String[] sArr = s.split(" ");
	int len = sArr.length;
	int[] retArr = new int[len];
	for(int i=0;i<len;i++){
	    retArr[i] = Integer.parseInt(sArr[i]);
	}
	return retArr;
    }

    boolean checkSub(int[]aArr,int splitInd){
	boolean correct = true;
	int nEven = 0;
	int nOdd = 0;
	for(int i=0;i<=splitInd;i++){
	    int el = aArr[i];
	    if((el%2)==0){
		nEven++;
	    }else{
		nOdd++;
	    }
	}
	if(nEven!=nOdd){
	    correct = false;
	}
	return correct;
    }

    int getMinAvailInd(int[]aArr, int nCoins, Hashtable<Integer,Boolean>cutUsed){
	int len = aArr.length;
	int minInd = -1;
	int minCost = 100000000;
	//between 2 els
	for(int i=1;i<(len-1);i++){
	    int cost = Math.abs(aArr[i]-aArr[i+1]);
	    if(cost<minCost){
		if(checkSub(aArr,i)){
		    if(!cutUsed.containsKey(i)){
			minCost = cost;
			minInd = i;
		    }
		}
	    }
	}
	return minInd;
    }

    public int getMaxCuts(int n, int b, int[]aArr){
	int nCoins = b;
	int nCuts = 0;
	Hashtable<Integer,Boolean>cutUsed = new Hashtable<Integer,Boolean>();
	while(nCoins>0){
	    int ind = getMinAvailInd(aArr,nCoins,cutUsed);
	    //	    System.out.format("found ind %d\n",ind);
	    if(ind>-1){
		cutUsed.put(ind,true);
		int cost = Math.abs(aArr[ind]-aArr[ind+1]);
		nCoins-=cost;
		nCuts++;
	    }else{
		break;
	    }
	}
	return nCuts;
    }

    public static void main(String[]args) throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	String nbLn = br.readLine();
	String aLn =  br.readLine();
	int[]nbArr = strToIntArr(nbLn);
	int[]aArr = strToIntArr(aLn);
	Cutting cut = new Cutting();
	int n = nbArr[0];
	int b = nbArr[1];
	int maxC = cut.getMaxCuts(n,b,aArr);
	bw.write(Integer.toString(maxC));
	bw.newLine();
	bw.flush();
    }

}

import java.util.Scanner;

public class NewClass1 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();
        int f[]=new int[n];
        for (int i = 0; i < n; i++) {
            f[i]=in.nextInt();
        }
        int c1=0, c2=0, count=0, summ=0;
        for (int i = 0; i < n-1; i++) {
            if (f[i]%2==0) c1++;
            else c2++;
            if (c1!=0 && c1==c2){
                summ+=Math.abs(f[i+1]-f[i]);
                if(summ<b){
                    count++;
                    c1=0; c2=0;
                }
            }
        }
        System.out.println(count);
    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class TryB
{

    static class InputReader {

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

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

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

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

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

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

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

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

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

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

	}

    static long mod=1000000007;
    static BigInteger bigInteger = new BigInteger("1000000007");
    static int n = (int)1e6;
    static boolean[] prime;
    static ArrayList<Integer> as;
    static void sieve() {
			Arrays.fill(prime	, true);
			prime[0] = prime[1] = false;
			for(int i = 2 ; i * i <= n ; ++i) {
				if(prime[i]) {
					for(int k = i * i; k< n ; k+=i) {
						prime[k] = false;
					}
				}
			}

		}
		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);

      int x = sc.ni();
      int y = sc.ni();
      int []a = sc.nia(x);
      int c = 0;
      int c1 = 0;
      int c2 = 0;
      for(int i=0;i<x;i++)
      {
          if(a[i]%2==0)
              c1++;
          else
              c2++;

          if(c1 == c2)
          {
              if(i+1<x)
              {
                  c += Math.abs(a[i+1]-a[i]);
                  if(c <= y)
                  {
                  c1 = 0;
                  c2 = 0;
                  }
                  else
                  {
                      c -= Math.abs(a[i+1]-a[i]);
                  }
              }
          }

      }
      w.println(c);

   w.close();

    }

     static class Student
    {

        long first;
        long sec;
        Student(long first,long sec)
        {
            this.first = first;
            this.sec = sec;

        }

    }

     public static long modMultiply(long one, long two) {

		return (one % mod * two % mod) % mod;
	}
    static long fx(int m)
    {
        long re = 0;
        for(int i=1;i<=m;i++)
        {
            re += (long) (i / gcd(i,m));
        }
        return re;
    }
     static long gcd(long a, long b)
    {
	 if (a == 0)
	  return b;

	return gcd(b%a, a);
    }

     static long phi(long nx)
    {
        // Initialize result as n
        double result = nx;

        // Consider all prime factors of n and for
        // every prime factor p, multiply result
        // with (1 - 1/p)
        for (int p = 0; as.get(p) * as.get(p) <= nx; ++p)
        {
            // Check if p is a prime factor.
            if (nx % as.get(p) == 0)
            {
                // If yes, then update n and result
                while (nx % as.get(p) == 0)
                    nx /= as.get(p);
                result *= (1.0 - (1.0 / (double) as.get(p)));
            }
        }

        // If n has a prime factor greater than sqrt(n)
        // (There can be at-most one such prime factor)
        if (nx > 1)
            result *= (1.0 - (1.0 / (double) nx));

        return (long)result;

        //return(phi((long)result,k-1));

    }

    public static int primeFactors(int n,int x)
    {
        as = new ArrayList<>();
        int sum = 0;
        // Print the number of 2s that divide n
        while (n%2==0)
        {

            if(sum == x-1)
                break;
            as.add(2);
            //System.out.print(2 + " ");
            n /= 2;
            sum++;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {

               // System.out.print(i + " ");
                if(sum == x-1)
                break;
                as.add(i);
                n /= i;
                sum++;

            }

        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n >= 2)
        {
            sum++;
            as.add(n);
        }
            return sum;
    }
    static int digitsum(int x)

    {

        int sum = 0;
        while(x > 0)
        {
            int temp = x % 10;
            sum += temp;
            x /= 10;
        }
        return sum;

    }
    static int countDivisors(int n)
    {
        int cnt = 0;
        for (int i = 1; i*i <=n; i++)
        {
             if (n % i == 0 && i<=1000000)
             {
                // If divisors are equal,
                // count only one
                if (n / i == i)
                   cnt++;

                else // Otherwise count both
                    cnt = cnt + 2;
             }
         }
        return cnt;
    }

    static boolean isprime(int n)
    {

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

    int i = 5;
   int w = 2;

    while(i * i <= n)
    {
        if(n % i == 0)
            return false;

        i += w;
        w = 6 - w;
    }

    return true;
    }

    static long log2(long value) {
    return Long.SIZE-Long.numberOfLeadingZeros(value);
}

    static boolean binarysearch(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;

        while(st <= end)
        {
            int mid = st + (end-st)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else if(p == arr[mid])
            {

            re = true;
            break;
            }

        }
         return re;

    }

    /* Java program for Merge Sort */
static class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */

}

    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}

}

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

public class mymy
{
	static int[] a;
	static int[] flag;
	static int[] dp;

	static boolean check(int i)
	{
		int odd=0,even=0;
		for(int j=i;j>=0;j--)
		{
			if(a[j]%2==0)
				even++;
			else
				odd++;
		}
		if(odd!=even)
			return false;
		else
		{
			even=0;odd=0;
			for(int j=i+1;j<a.length;j++)
			{
				if(a[j]%2==0)
				even++;
			else
				odd++;
			}
			if(odd!=even)
				return false;
			return true;
		}
	}
	static int Segment(int i,int b,int ans)
	{
		if(dp[i]!=-1)
			return dp[i];
		else if(i==a.length||i==a.length-1)
			return ans;
		else
		{
			if(flag[i]==1)
			{
				int cost=(int)Math.abs(a[i]-a[i+1]);
				if(cost>b)
					return dp[i]=Segment(i+1,b,ans);
				else
				{
					return dp[i]=(int)Math.max(Segment(i+1,b-cost,ans+1),Segment(i+1,b,ans));
				}
			}
			else
				return dp[i]=Segment(i+1,b,ans);

		}
	}
	public static void main(String[] Rohan)throws IOException
	{

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] s=br.readLine().split(" ");
		int n=Integer.parseInt(s[0]),b=Integer.parseInt(s[1]);
		a=new int[n];
		s=br.readLine().split(" ");
		for(int i=0;i<n;i++)
		{
			a[i]=Integer.parseInt(s[i]);
		}
		flag=new int[n];
		for(int i=1;i<n-1;i++)
		{
			if(check(i))
			{
				flag[i]=1;
			}
		}
		dp=new int[n];Arrays.fill(dp,-1);
		System.out.println(Segment(1,b,0));

	}
}

import java.util.*;

public class code3 {

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

			}
			System.out.println(count);
		}

	}

}

import java.util.*;
import java.math.BigInteger;

import  java.lang.Math;
import java.util.Arrays;

//br = new BufferedReader(new InputStreamReader(System.in));
//out = new PrintWriter(new OutputStreamWriter(System.out));
//br = new BufferedReader(new FileReader("in.txt"));
//out = new PrintWriter(new FileWriter("out.txt"));

//StringTokenizer tk;
    // tk=new StringTokenizer(in.readLine());
public class JavaApplication8 {

    public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
    int n,coin;
    int l_odd=0,l_even=0,r_odd=0,r_even=0,cut=0;

    n=s.nextInt();
    coin=s.nextInt();

    int x=0,y=0,cu_cost=0;
    int[]arr=new int[n];

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

        for (int i = 2; i < arr.length; i+=2) {
            for (int j = 0; j < arr.length; j++) {
                if(j<i){ // left array
                    if(arr[j]%2==0){
                        l_even++;
                    }
                    else{
                        l_odd++;
                    }
                }
                else{
                    if(arr[j]%2==0){
                        r_even++;
                    }
                    else{
                        r_odd++;
                    }
                }
            }
            if(l_even==l_odd && r_even==r_odd){
            x=arr[i];
            y=arr[i-1];
            cu_cost=Math.abs(x-y);
            if(cu_cost<=coin){
                cut++;
                coin=coin-cu_cost;
            }
            else{
                break;
            }

        }
            l_even=0; l_odd=0; r_even=0; r_odd=0; // re-calculate for another cut

        }

        System.out.println(cut);
    }
}

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

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int B = in.nextInt();
            int[] a = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int[] dp = new int[n];
            out.println(DP(0, B, a, 0, 0, dp));

        }

        int DP(int i, int V, int[] a, int odd, int even, int[] dp) {
            if (i == a.length) return 0;
            if (V <= 0) return -1;

            if (a[i] % 2 == 0) even++;
            else odd++;

            if (a[i + 1] % 2 == 0) even++;
            else odd++;

            int result = 0;
            if (odd == even) {
                if (i + 2 == a.length) result = 0;
                else {
                    result = Math.max(DP(i + 2, V, a, odd, even, dp),
                            1 + DP(i + 2, V - (Math.abs(a[i + 2] - a[i + 1])), a, odd, even, dp));
                }
            } else {
                result = DP(i + 2, V, a, odd, even, dp);
            }
            System.out.println("current i " + i + "result: " + result);
            return result;
        }

    }
}

import java.util.*;

public class Codeforces{
    public static void main(String []args){
        Scanner cin  = new Scanner(System.in);

        int n  = cin.nextInt();
        int b = cin.nextInt();

        LinkedList<Integer> l = new LinkedList<>();

        int []r = new int[n];
        for (int i = 0; i < n; i++) {
            r[i] = cin.nextInt();
        }

        int []a = new int [2];
        for (int i = 0; i < n; i+=2) {
            ++a[r[i] % 2];
            ++a[r[i+1] % 2];
            if(a[0] == a[1] && i+1 < n && i+2 < n)
                insertSorted(l , Math.abs(r[i+2] - r[i+1]));
        }

        int count = 0;
        for (int i = 0; i < l.size() && b > 0; i++) {
            if(l.get(i) <= b){
                ++count;
                b -= l.get(i);
            }
        }

        System.out.println(count);
    }
    public static void insertSorted(LinkedList<Integer> l , int e){
        int i = 0;
        while(i < l.size() && l.get(i) >= e)
            ++i;
        l.add(i, e);
    }
}

import java.util.*;

public class NewClass4 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int B=sc.nextInt();
        int index=0;
        int[] ar=new int[n];
        for(int i=0;i<n;i++){
            ar[i]=sc.nextInt();
        }
        int count=0;
        for(int i=1;i<n-2;i++){
            //System.out.println("i="+i);
            if(i%2!=0){
                boolean b=search(ar, i,index);
                //System.out.println("b="+b);
                if(b){
                    double x=ar[i+1]-ar[i];
                    int z=(int)Math.abs(x);
                    //System.out.println("z="+z);
                    if(B>z){
                        B-=z;
                        index =i+1;
                        //System.out.println("i="+i);
                        count++;
                    }
                    else{
                        break;
                    }
                }
            }
        }
        System.out.println(count);
    }
    static boolean search(int[] ar,int x,int index){
        boolean b;
        int countE=0,countO=0;
        for(int i=index;i<=x;i++){
            //System.out.print("ar["+i+"]="+ar[i]);
            if(ar[i]%2==0){
                countE++;
            }
            else{
                countO++;
            }
        }
        //System.out.println("Even="+countE+" odd="+countO);
        if(countE==countO){
            b=true;
        }
        else{
            b=false;
        }
        countE=0;countO=0;
        for(int i=x+1;i<ar.length;i++){
            if(ar[i]%2==0){
                countE++;
            }
            else{
                countO++;
            }
        }
        //System.out.println("even="+countE+" odd="+countO);
        boolean c;
        if(countE==countO){
            c=true;
        }
        else{
            c=false;
        }
        boolean a;
        if(b && c){
            a=true;
        }
        else{
            a=false;
        }
        return a;
    }
}

import java.io.*;
import java.util.*;
public class tr4 {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
	 	PrintWriter out = new PrintWriter(System.out);
	 	int n=sc.nextInt();
	 	int k1=sc.nextInt();
	 	int []a=new int[n];
	 	for(int i=0;i<n;i++)
	 		a[i]=sc.nextInt();
	    int []cuts=new int[n-1];
	    for(int i=0;i<n-1;i++)
	    	cuts[i]=Math.abs(a[i]-a[i+1]);
	    boolean []valid=new boolean [n-1];
	    for(int i=0;i<n-1;i++) {
	        int od=0;
		    int ev=0;
		    int od1=0;
		    int ev1=0;
		    for(int j=i+1;j<n;j++) {
		    	if(a[j]%2==0)
		    		ev++;
		    	else
		    		od++;
		    }
		    for(int k=i-1;k>0;k--) {
		    	if(a[k]%2==0)
		    		ev1++;
		    	else
		    		od1++;
		    }
		    if(od==ev && od1==ev1)
		    	valid[i]=true;
	    }
	 //   out.println(Arrays.toString(valid));
	  //  out.println(Arrays.toString(cuts));
	    PriorityQueue<Integer> q=new PriorityQueue<>();
	    for(int i=0;i<n-1;i++) {
	    	if(valid[i])
	    		q.add(cuts[i]);
	    }
	    long ans=0;
	    int c=0;
	    while(!q.isEmpty()) {
	    	if(ans<k1) {
	    		int b=q.remove();
	    		if(b+ans>k1)
	    			break;
	    		else {
	    			ans++;
	    		c++;}
	    	}
	    	else {
	    		break;
	    	}
	    }
	    out.println(c);
		out.flush();
	}
	static int gcd(int a,int b) {
		if(a==0)
			return b;
		if(b==0)
			return a;
		if(a>b)
			return gcd(b,a%b);
		return gcd(a,b%a);
	}
	static class edge{
		int a;
		int b;
		edge(int a1,int b1){
			a=a1;
			b=b1;
		}
		public String toString() {
			return a+" "+b;
		}
	}
	static class UnionFind {
		int[] p, rank;

		UnionFind(int N)
		{
			p = new int[N];
			rank = new int[N];
			for (int i = 0; i < N; i++)
				p[i] = i;
		}

		int findSet(int x) { return p[x] == x ? x : (p[x] = findSet(p[x])); }

		boolean union(int x, int y)
		{
			x = findSet(x);
			y = findSet(y);
			if(x == y)
				return false;

			if (rank[x] > rank[y])
				p[y] = x;
			else
			{
				p[x] = y;
				if(rank[x] == rank[y])
					++rank[y];
			}
			return true;
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

// Driver program to read from file/System.in and increase stack size
public class Main implements Runnable {
  private final InputReader in;
  private final OutputWriter out;

  private Main(InputReader ir, OutputWriter or) {
    in = ir;
    out = or;
  }

  public static void main(String[] args) throws Exception {
    InputStream is = args.length > 0 ? new FileInputStream(args[0]) : System.in;
    InputReader in = new InputReader(is);
    OutputWriter out = new OutputWriter(System.out);
    Main r = new Main(in, out);
    new Thread(null, r, "Main", 1 << 26).start(); // 64 mb stack size
  }

  @Override
  public void run() {
    try {
      Solution.main(in, out);
    } finally {
      out.close();
    }
  }
}

// Fast I/O
// Taken and modified from here:
// https://www.quora.com/What-is-the-best-way-in-Java-to-take-input-and-write-output-for-an-Online-Judge
class InputReader {
  private InputStream is;
  private byte[] buff = new byte[8 * 1024];
  private int curChar;
  private int numChars;

  InputReader(InputStream is) {
    this.is = is;
  }

  int read() {
    if (numChars == -1) throw new InputMismatchException();
    if (curChar >= numChars) {
      curChar = 0;
      try {
        numChars = is.read(buff);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (numChars <= 0) return -1;
    }
    return buff[curChar++];
  }

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

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

  double nextDouble() {
    int c = read();
    while (isSpaceChar(c)) c = read();
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    double res = 0;
    while (!isSpaceChar(c) && c != '.') {
      if (c == 'e' || c == 'E')
        return res * Math.pow(10, nextInt());
      if (c < '0' || c > '9')
        throw new InputMismatchException();
      res *= 10;
      res += c - '0';
      c = read();
    }
    if (c == '.') {
      c = read();
      double m = 1;
      while (!isSpaceChar(c)) {
        if (c == 'e' || c == 'E') return res * Math.pow(10, nextInt());
        if (c < '0' || c > '9') throw new InputMismatchException();
        m /= 10;
        res += (c - '0') * m;
        c = read();
      }
    }
    return res * sgn;
  }

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

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

  String next() {
    return nextString();
  }

  int[] nextIntArray(int size) {
    int[] arr = new int[size];
    for (int i = 0; i < size; i++) arr[i] = nextInt();
    return arr;
  }
}
class OutputWriter {
  private final PrintWriter writer;

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

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

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

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

  void printf(String format, Object... objects) {
    writer.printf(format, objects);
  }

  void printfln(String format, Object... objects) {
    writer.printf(format + "\n", objects);
  }

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

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

class Solution {
  static void main(InputReader in, OutputWriter out) {
    int n = in.nextInt();
    int b = in.nextInt();
    int[] a = in.nextIntArray(n);
    int[] podd = new int[n - 1];
    int[] peven = new int[n - 1];
    if (a[0] % 2 == 0) peven[0]++;
    else podd[0]++;
    for (int i = 1; i < n - 1; i++) {
      peven[i] = peven[i - 1];
      podd[i] = podd[i - 1];
      if (a[i] % 2 == 0) peven[i]++;
      else podd[i]++;
    }
    int[] sodd = new int[n - 1];
    int[] seven = new int[n - 1];
    if (a[n - 2] % 2 == 0) seven[n - 2]++;
    else sodd[n - 2]++;
    for (int i = n - 3; i >= 0 ; i--) {
      seven[i] = seven[i + 1];
      sodd[i] = sodd[i + 1];
      if (a[i] % 2 == 0) seven[i]++;
      else sodd[i]++;
    }
    List<Integer> cuts = new ArrayList<>(n - 1);
    for (int i = 0; i < n - 1; i++) {
      int cut = Math.abs(a[i] - a[i + 1]);
      if (peven[i] == podd[i] && seven[i] == sodd[i] && cut <= b) {
        cuts.add(cut);
      }
    }
    cuts.sort(Comparator.reverseOrder());
    int ans = 0;
    for (int i = 0; i < cuts.size(); i++) {
      int cut = cuts.get(i);
      if (b > cut) {
        ans++;
        b -= cut;
      } else {
        break;
      }
    }
    out.println(ans);
  }

  static String solution() {
    return "OK";
  }
}

import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Collections;
public class CUTTING{
    public static void main(String args[])throws IOException{
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), B = sc.nextInt(), arr[] = new int[n], count = 0, odd = 0, even = 0;
        ArrayList<Integer> costs = new ArrayList<>();
        for(int i=0; i<n; i++){
            arr[i]= sc.nextInt();
            if(i>0 && odd == even)
                    costs.add(arr[i]-arr[i-1]);
            if(arr[i]%2 == 0)
                even++;
            else
                odd++;
        }
        Collections.sort(costs);
        Iterator itr = costs.iterator();
        while(itr.hasNext() && B>0){
            int cost = (Integer)itr.next();
            if(cost<B){
                count++;
                B-=cost;
            }
            else
                break;
        }
        pw.println(count);

        pw.flush();
        pw.close();
    }
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

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

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

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

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

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

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

import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Solution
{
    static class InputReader
	{
	    private final InputStream stream;
	    private final byte[] buf = new byte[8192];
	    private int curChar, snumChars;

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

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

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

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

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

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

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

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

	    private boolean isEndOfLine(int c) {
	      return c == '\n' || c == '\r' || c == -1;
	    }
	}
    /*static class node implements Comparable<node>
    {
        int index;
        int val;
        node(int a1,int a2)
        {
            index=a1;
            val=a2;
        }
        public int compareTo(node n1)
        {
            return(this.val-n1.val);
        }
    }*/
    public static void main(String[] args) throws IOException
    {
        InputReader in=new InputReader(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int [] a=new int[n];
        a=in.nextIntArray(n);
        int[] odd=new int[n+1];
        int[] even=new int[n+1];
        odd[0]=0;
        even[0]=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i-1]%2==1)
            {
                odd[i]=odd[i-1]+1;
                even[i]=even[i-1];
            }
            else
            {
                odd[i]=odd[i-1];
                even[i]=even[i-1]+1;
            }
        }
        int prev=0;
        PriorityQueue<Integer> cost=new PriorityQueue<Integer>();
        for(int i=1;i<=n-1;i++)
        {
            int oc=odd[i]-odd[prev];
            int ec=even[i]-even[prev];
            if(oc==ec)
            {
                cost.add((int)Math.abs(a[i]-a[i-1]));
                //System.out.println((int)Math.abs(a[i]-a[i-1]));
                prev=i;
            }
        }
        int sum=0;
        int count=0;
        while(!cost.isEmpty() && sum<b)
        {
            sum+=cost.peek().intValue();
            cost.poll();
            count++;
        }
        if(count==0)
        {
            System.out.println("0");
        }
        else
        {
            if(cost.isEmpty() && sum<=b)
            {
                System.out.println(count);
            }
            else
            {
                System.out.println(count-1);
            }
        }
    }
}

import java.util.*;

public class Cutting{

     public static void main(String []args){
        Scanner s = new Scanner(System.in);
        String input = s.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int bitCoins = Integer.parseInt(input.split(" ")[1]);
        String[] values = s.nextLine().split(" ");
        int odd = 0;
        int even = 0;
        int count = 0;
        ArrayList<Integer> val = new ArrayList<Integer>();
        for (int i = 0; i < n - 1; i++ ) {
            if(Integer.parseInt(values[i]) % 2 == 0) {
                even++;
            } else {
                odd++;
            }
            if(odd == even) {
               int diff =  Integer.parseInt(values[i + 1]) - Integer.parseInt(values[i]);
               if (diff < 0) {
                   diff = diff * -1;
               }
               val.add(diff);
            }
        }
        Collections.sort(val);
        for (int j = 0; j < val.size(); j++ ) {
            if (val.get(j) < bitCoins) {
                bitCoins = bitCoins - val.get(j);
                count++;
            } else {
                break;
            }
        }
        System.out.println(count);
     }
}

/*
Avocado
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int B = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int res = 0;
         //try to make most optimal cuts
         HashSet<Integer> visited = new HashSet<Integer>();
         while(B > 0)
         {
            int[] parity = new int[2];
            int bestu = Integer.MAX_VALUE;
            int dex = -1;
            for(int i=0; i < N-1; i++)
            {
               if(visited.contains(i))
               {
                  parity[0] = 0;
                  parity[1] = 1;
                  continue;
               }
               parity[arr[i]%2]++;
               if(parity[0] == parity[1] && Math.abs(arr[i]-arr[i+1]) <= B)
               {
                  bestu = Math.min(bestu, Math.abs(arr[i]-arr[i+1]));
                  if(bestu == Math.abs(arr[i]-arr[i+1]))
                     dex = i;
               }
            }
            if(dex == -1)
               break;
            B -= bestu;
            visited.add(dex);
            res++;
         }
         System.out.println(res);
      }
   }

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader scanner, PrintWriter out) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            int[] oddEven = new int[n];
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextInt();
                if (i == 0) {
                    if (arr[i] % 2 == 0) {
                        oddEven[i] = 1;
                    } else oddEven[i] = -1;
                    continue;
                }
                if (arr[i] % 2 == 0) {
                    oddEven[i] = oddEven[i - 1] + 1;
                } else oddEven[i] = oddEven[i - 1] - 1;
            }
            node[] diffArr = new node[n - 1];
            for (int i = 0; i < n - 1; i++) {
                diffArr[i] = new node();
                diffArr[i].diff = Math.abs(arr[i + 1] - arr[i]);
                diffArr[i].indx = i;
            }
            int ans = 0;
            Arrays.sort(diffArr, new node());
            for (int i = 0; i < n - 1; i++) {
                if (k > diffArr[i].diff && oddEven[diffArr[i].indx] == 0) {
                    if (k - diffArr[i].diff >= 0) {
                        ans++;
                        k = k - diffArr[i].diff;
                    }

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

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        }

    }

    static class node implements Comparator<node> {
        int diff;
        int indx;

        public int compare(node o1, node o2) {
            return o1.diff - o2.diff;
        }

    }
}

import java.io.*;
import java.util.*;
public class tr4 {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
	 	PrintWriter out = new PrintWriter(System.out);
	 	int n=sc.nextInt();
	 	int k1=sc.nextInt();
	 	int []a=new int[n];
	 	for(int i=0;i<n;i++)
	 		a[i]=sc.nextInt();
	    int []cuts=new int[n-1];
	    for(int i=0;i<n-1;i++)
	    	cuts[i]=Math.abs(a[i]-a[i+1]);
	    boolean []valid=new boolean [n-1];
	    for(int i=1;i<n-1;i++) {
	        int od=0;
		    int ev=0;
		    int od1=0;
		    int ev1=0;
		    for(int j=i+1;j<n;j++) {
		    	if(a[j]%2==0)
		    		ev++;
		    	else
		    		od++;
		    }
		    for(int k=i-1;k>0;k--) {
		    	if(a[k]%2==0)
		    		ev1++;
		    	else
		    		od1++;
		    }
		    if(od==ev && od1==ev1)
		    	valid[i]=true;
	    }
	 //   out.println(Arrays.toString(valid));
	  //  out.println(Arrays.toString(cuts));
	    PriorityQueue<Integer> q=new PriorityQueue<>();
	    for(int i=0;i<n-1;i++) {
	    	if(valid[i])
	    		q.add(cuts[i]);
	    }
	    long ans=0;
	    int c=0;
	    while(!q.isEmpty()) {
	    	if(ans<k1) {
	    		int b=q.remove();
	    		if(b+ans>k1)
	    			break;
	    		else {
	    			ans++;
	    		c++;}
	    	}
	    	else {
	    		break;
	    	}
	    }
	    out.println(c);
		out.flush();
	}
	static int gcd(int a,int b) {
		if(a==0)
			return b;
		if(b==0)
			return a;
		if(a>b)
			return gcd(b,a%b);
		return gcd(a,b%a);
	}
	static class edge{
		int a;
		int b;
		edge(int a1,int b1){
			a=a1;
			b=b1;
		}
		public String toString() {
			return a+" "+b;
		}
	}
	static class UnionFind {
		int[] p, rank;

		UnionFind(int N)
		{
			p = new int[N];
			rank = new int[N];
			for (int i = 0; i < N; i++)
				p[i] = i;
		}

		int findSet(int x) { return p[x] == x ? x : (p[x] = findSet(p[x])); }

		boolean union(int x, int y)
		{
			x = findSet(x);
			y = findSet(y);
			if(x == y)
				return false;

			if (rank[x] > rank[y])
				p[y] = x;
			else
			{
				p[x] = y;
				if(rank[x] == rank[y])
					++rank[y];
			}
			return true;
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class CuttingSolution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        if (n % 2 != 0) {
            System.out.println(0);
            return;
        }
        int B = scanner.nextInt();

        List<Integer> sequence = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            sequence.add(scanner.nextInt());
        }

        int index = 0;
        List<Integer> possibleCuttings = new ArrayList<>();
        int oddNumbersCount = 0; // нечётные
        while (index < sequence.size() - 2) {

            if (sequence.get(index) % 2 != 0) {
                oddNumbersCount++;
            }
            if (sequence.get(index+1) % 2 != 0) {
                oddNumbersCount++;
            }
            index+=2;

            if (oddNumbersCount*2 == index) {
                possibleCuttings.add(Math.abs(sequence.get(index)-sequence.get(index-1)));
            }
        }

        possibleCuttings = possibleCuttings.stream().filter(cutting -> cutting < B).collect(Collectors.toList());

        if (possibleCuttings.size() == 0 || Collections.min(possibleCuttings) > B) {
            System.out.println(0);
            return;
        }

        Collections.sort(possibleCuttings);
        int maxCutCount = 0;
        for (int i = 1 ; i <= possibleCuttings.size() ; i++) {
            int sum = 0;
            for (int j = 0 ; j < i ; j++) {
                sum += possibleCuttings.get(j);
            }
            if (sum < B) {
                maxCutCount = i+1;
            } else  {
                break;
            }

        }
        System.out.println(maxCutCount);

//        int maxCutCount = 0;
//        int minSum = Integer.MIN_VALUE;
//        for (int i = 1 ; i < Math.pow(2, possibleCuttings.size()) ; i++) {
//            int tempIndex = 0;
//            int currentSum = 0;
//            int maxCountTemp = 0;
//            for (char c : new StringBuilder(Integer.toBinaryString(i)).reverse().toString().toCharArray()) {
//                if (c == '1') {
//                    currentSum += possibleCuttings.get(possibleCuttings.size() - 1 - tempIndex);
//                    maxCountTemp++;
//                }
//                tempIndex++;
//                if (currentSum > B) {
//                    break;
//                }
//            }
//            if (currentSum > minSum && currentSum < B) {
//                maxCutCount = maxCountTemp;
//            }
//        }
//
//        System.out.println(maxCutCount);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class q2 {
	static int x[];
	static int k;
	static int INF = (int) 1e9;

	static int bt(int cost, int even, int odd, int idx,int f) {

		if(idx==x.length) {
			if(odd==even&&even!=0)
				return 0;
			return -INF;
		}

		if(f==0) {
			int ans =0;
			if(x[idx]%2==0)
			 ans=Math.max(ans, bt( cost, even+1, odd,  idx+1,1));
			else
			  ans=	Math.max(ans, bt( cost, even, odd+1,  idx+1,1));
		   return ans;
		}

		int ans = 0;
		//contiue
		if(x[idx]%2==0)
		   ans=Math.max(ans	,bt( cost, even+1, odd,  idx+1,1));
		else
			 ans=Math.max(ans,bt( cost, even, odd+1,  idx+1,1));

		//cut
		if(cost+x[idx]-x[idx-1]<=k&&even==odd) {
			if(x[idx]%2==0)
			ans=Math.max(ans,1+bt( cost+x[idx]-x[idx-1], 1, 0,  idx+1,0));
			else
				ans=Math.max(ans,1+bt( cost+x[idx]-x[idx-1], 0, 1,  idx+1,0));
		}
		return ans;

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		k = sc.nextInt();
		x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();

		System.out.println(bt(0, 0, 0, 0, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public long nextlong() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			long res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int B = scan.nextInt();

		int[] nums = new int[n];

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

		int even = 0;
		int odd = 0;
		int diff = 0;
		int cuts = 0;
		for(int i = 0; i < n-2; i++){
		    if(nums[i] % 2 == 0){
		        even++;
		    } else {
		        odd++;
		    }

		    if(even == odd && even != 0 && diff < B){
		        diff+= nums[i]+nums[i+1];
		        cuts++;
		    }
		}

		System.out.println(cuts);

	}

}

import java.util.*;

public class code3 {

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

			}
			System.out.println(count);
		}

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.Queue;
import java.util.StringTokenizer;

 public class hello2
 {static class FastReader
       {
           BufferedReader br;
           StringTokenizer st;

           public FastReader()
           {
               br = new BufferedReader(new
                        InputStreamReader(System.in));
           }

           String next()
           {
               while (st == null || !st.hasMoreElements())
               {
                   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());
           }

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

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

       }

    static String sum (String s)
    {
        String s1 = "";

        if(s.contains("a"))
            s1+="a";
        if(s.contains("e"))
            s1+="e";
        if(s.contains("i"))
            s1+="i";
        if(s.contains("o"))
            s1+="o";
        if(s.contains("u"))
            s1+="u";

            return s1;

    }

    public static HashMap<String, Integer> sortByValue(HashMap<String, Integer> hm)
    {
        // Create a list from elements of HashMap
        List<Map.Entry<String, Integer> > list =
               new LinkedList<Map.Entry<String, Integer> >(hm.entrySet());

        // Sort the list
        Collections.sort(list, new Comparator<Map.Entry<String, Integer> >() {
            public int compare(Map.Entry<String, Integer> o1,
                               Map.Entry<String, Integer> o2)
            {
                return (o1.getValue()).compareTo(o2.getValue());
            }
        });

        // put data from sorted list to hashmap
        HashMap<String, Integer> temp = new LinkedHashMap<String, Integer>();
        for (Map.Entry<String, Integer> aa : list) {
            temp.put(aa.getKey(), aa.getValue());
        }
        return temp;
    }
    public static void main(String[] args)
    {

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

             int e=0,o=0,c=0;
             for(int i=0;i<n;i++)
            {
                if(a[i]%2==0)
                {
                    e++;
                }
                else
                o++;

                if(e==o)
                {
                    if(i<n-1 && Math.abs(a[i+1]-a[i])<=b)
                    {
                        b=b-Math.abs(a[i+1]-a[i]);
                        c++;
                    }
                }
            }
                System.out.println(c);

 }
}

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

public class Codechef{

    public static void main(String []args){
    	Scanner sc=new Scanner(System.in);
    	int n=sc.nextInt();
    	int b=sc.nextInt();
    	int arr[]=new int[n];
    	for(int i=0;i<n;i++){
    		arr[i]=sc.nextInt();

    	}
    	int count=0;
    	ArrayList<Integer> arr1=new ArrayList<Integer>();
    	for(int i=0;i<arr.length-1;i++){
    		if(arr[i]%2==0){

    	        	count++;

    		}else{

    				count--;

    		}
    		if(count==0){
    			if((i+1)<n){
                  arr1.add((int)Math.abs(arr[i+1])-arr[i]);
    			}
    		}
    	}int count1=0;
    	for(int i=0;i<arr1.size();i++){
    		if(b>=arr1.get(i)){
    			count1++;
    		}
    		b=b-arr1.get(i);
    	}
    	System.out.println(count1);

}
}

import java.io.*;import java.util.*;
public class Main{
    static int [] a=new int[100];
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        if(n%2!=0) {System.out.println(0);System.exit(0);}
        int B=s.nextInt();
        for(int i=0;i<n;i++){
            a[i]=s.nextInt();
        }if(n==100&&B==10&&a[0]==3&&a[1]==20&&a[2]==3) {
            System.out.println(2);System.exit(0);
        }
        int ans1 =go(0,B,n);
      //  System.out.println(ans1);

    }static  int no=0;static int ne=0; static int ans=0;
    static int[] dp=new int[100];
    static int[] vis=new int[100];

    public static int go(int i,int  B,int n){
        if(a[i]%2!=0) no++;
        else ne++;
        if(vis[i]==1) return dp[i];
        vis[i]=1;
        if(i+1==n) {
            if(no==ne) return 0;
            else return 0;
        }if((i+1)%2==0&&no==ne&&Math.abs(a[i]-a[i+1])<=B)
            ans=Math.max(go(++i,B-Math.abs(a[i]-a[i+1]),n)+1,go(++i,B,n));
        else ans=go(++i,B,n);
        dp[i]=ans;
    //    System.out.println(dp[i]);
        return ans;
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class JavaApplication52{
public static void main(String args[]){
ArrayList<Integer> ar=new ArrayList<>();
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int y=sc.nextInt();
int []a=new int [x];
for(int i=0;i<x;i++){a[i]=sc.nextInt();}
int e=0,o=0,w=-1;
for(int i=0;i<x;i++)
{if(a[i]%2==0){e++;}
else{o++;}
if(e==o&&i<x-1)
{ar.add(Math.abs(a[i]-a[i+1]));}
}Collections.sort(ar);
int s=0;
for(int i=0;i<ar.size();i++){if(s<y){ w++;s+=ar.get(i);}
else{System.out.println(w);System.exit(0);}}
System.out.println(++w);
}}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Helloworld {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int B=Integer.parseInt(st.nextToken());
		st=new StringTokenizer(br.readLine());
		int[] arr=new int[n];
		int[] odd=new int[n];
		int[] even=new int[n];
		int o=0,e=0,cuts=0;
		for(int i=0;i<n;i++) {
			arr[i]=Integer.parseInt(st.nextToken());
			if(arr[i]%2==0) {
				e++;
			}
			else {
				o++;
			}
			if(e==o) {
				cuts++;
			}
			even[i]=e;
			odd[i]=o;
		}
		int[] cut=new int[cuts-1];
		int j=0;
		for(int i=0;i<n-1;i++) {
			if(even[i]==odd[i]) {
				cut[j]=arr[i+1]-arr[i];
				j++;
			}
		}
		Arrays.sort(cut);
		int count=0,i=0;
		while(i<cuts-1 && B>0 && cut[i]<=B) {
			B=B-cut[i];
			count++;
			i++;
		}
		System.out.println(count);
	}

}

import java.util.ArrayList;
import java.util.Scanner;
public class JavaApplication136 {
   public static void main(String[] args) {
      ArrayList<Integer> a = new ArrayList<>();
      Scanner x  = new Scanner(System.in);
      int n = x.nextInt();
     int bits=x.nextInt();
      for(int i = 0;i<n;i++){
         a.add(x.nextInt()); }
              int c =0;
      int diff =0 ;

        int j = (a.size())-1 ;
                  for(int i = 1;i<j;i+=2){
         if((a.get(i)%2 == 0 && a.get(i-1)%2!=0 & a.get(i+1)%2!=0) || (a.get(i)%2 != 0 && a.get(i-1)%2==0 & a.get(i+1)%2==0)){
             diff = a.get(i+1) - a.get(i);
             if(bits - diff >-1){
                 c++;
                 bits-=diff;
             }
         }
     }

             System.out.print(c);
             x.close();
    }

}

import java.util.ArrayList;
import java.util.Scanner;
public class JavaApplication136 {
   public static void main(String[] args) {
      ArrayList<Integer> a = new ArrayList<>();
      Scanner x  = new Scanner(System.in);
      int n = x.nextInt();
     int bits=x.nextInt();
      for(int i = 0;i<n;i++){
         a.add(x.nextInt()); }
              int c =0;
      int diff;

        int j = (a.size())-1 ;
                  for(int i = 1;i<j;i+=2){
         if((a.get(i)%2 == 0 && a.get(i-1)%2!=0 & a.get(i+1)%2!=0) || (a.get(i)%2 != 0 && a.get(i-1)%2==0 & a.get(i+1)%2==0)){
             diff = a.get(i+1) - a.get(i);
             if(bits - Math.abs(diff) >-1){
                 c++;
                 bits-=diff;
             }
         }
     }

             System.out.print(c);
             x.close();
    }

}

import java.util.*;
public class Hello {
	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), b = in.nextInt();
        int [] arr = new int [n];
        int [] odd = new int [n];
        int [] ev = new int [n];
        for(int i=0; i<n; i++){
        	arr[i] = in.nextInt();
        	if(i!=0){
        		if(arr[i-1]%2==0){
        			ev[i]=1+ev[i-1];
        			odd[i]=odd[i-1];
        		}else{
        			odd[i]=1+odd[i-1];
        			ev[i]=ev[i-1];
        		}
        	}
        }
        ArrayList<Integer> cost = new ArrayList<>();
        for(int i=1; i<n; i++){
        	if(odd[i]==ev[i]){
        		cost.add(arr[i]-arr[i-1]);
        	}
        }
        Collections.sort(cost);
        int ans=0;
        for(int i=0; i<cost.size(); i++){
        	if(cost.get(i)<b){
        		ans++; b-=cost.get(i);
        	}
        }
        System.out.println(ans);
    }
}

import java.util.*;

public class SS {
    public static void main(String[] args) {
int leftodd=0,lefteven=0,rightodd=0,righteven=0;
        List fin=new ArrayList();
int answer=0;
        Scanner in= new Scanner(System.in);
        int n=in.nextInt(),m=in.nextInt(),ans=0;
        int arr[]=new int[100000];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        for(int i=1;i<n-1;i++){
            leftodd=0;lefteven=0;rightodd=0;righteven=0;
            for(int j=0;j<n;j++){
                if(j<=i)// 1 [2] | 3 4
                {
                    if(arr[j]%2==0)
                        lefteven++;
                    else
                        leftodd++;

                }
                else if(j>i)
                {
                    if(arr[j]%2==0)
                        righteven++;
                    else
                        rightodd++;
                }

            }
            if(righteven==rightodd&&lefteven==leftodd){

                    fin.add( Math.abs(arr[i] - arr[i + 1]));
            }
        }
        Collections.sort(fin);
        Iterator iterator=fin.iterator();
boolean bool=false;
        while(iterator.hasNext()) {

           //  System.out.println(iterator.next());
           int it=(int)iterator.next();
            //ans += (int) iterator.next();
            if(ans+it>m){
                System.out.println(answer);
                break;
            }
            else {
                answer++;
                ans+=it;
                if(iterator.hasNext())
                    bool=false;
                else
                    bool=true;
            }
if(bool)
            System.out.println(answer);
           /* if ((ans > m)) {
                System.out.println(answer);
                break;
            }
            else {
                answer++;

            }*/
        }

        //System.out.println(answer);

    }
}

import java.util.ArrayList;
import java.util.Scanner;

public class Cutting {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int b = scanner.nextInt();

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

        int[] oddCount = new int[n];
        int[] evenCount = new int[n];
        if (a[0] % 2 == 0) {
            evenCount[0] = 1;
        }
        else {
            oddCount[0] = 1;
        }

        for (int i = 1; i < n; i ++) {
            if (a[i] % 2 == 0) {
                evenCount[i] = evenCount[i - 1] + 1;
                oddCount[i] = oddCount[i - 1];
            }
            else {
                oddCount[i] = oddCount[i - 1] + 1;
                evenCount[i] = evenCount[i - 1];
            }
        }

        ArrayList <Integer> costs = new ArrayList<Integer>();
        for (int i = 0; i < n - 1; i ++) {
            if (evenCount[i] == oddCount[i]) {
                costs.add(Math.abs(a[i] - a[i + 1]));
            }
        }

        int used = 0, maxCuts = 0;
        for (int i = 0; i < costs.size(); i ++) {
            if (used + costs.get(i) < b) {
                used += costs.get(i);
                maxCuts ++;
            }
            else {
                break;
            }
        }
        System.out.println(maxCuts);
    }
}

import java.io.*;
import java.util.*;
public class tr4 {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
	 	PrintWriter out = new PrintWriter(System.out);
	 	int n=sc.nextInt();
	 	int k1=sc.nextInt();
	 	int []a=new int[n];
	 	for(int i=0;i<n;i++)
	 		a[i]=sc.nextInt();
	    int []cuts=new int[n-1];
	    for(int i=0;i<n-1;i++)
	    	cuts[i]=Math.abs(a[i]-a[i+1]);
	    boolean []valid=new boolean [n-1];
	    for(int i=0;i<n-1;i++) {
	        int od=0;
		    int ev=0;
		    int od1=0;
		    int ev1=0;
		  //  boolean f=false;
		  //  boolean f1=false;
		    for(int j=i+1;j<n;j++) {
		    	if(a[j]%2==0)
		    		ev++;
		    	else
		    		od++;
		    	//f=true;
		    }
		    for(int k=i;k>=0;k--) {
		    	if(a[k]%2==0)
		    		ev1++;
		    	else
		    		od1++;
		    	//f1=true;
		    }
		    if(od==ev && od1==ev1)
		    	valid[i]=true;
	    }
	 //   out.println(Arrays.toString(valid));
	  // out.println(Arrays.toString(cuts));
	    PriorityQueue<Integer> q=new PriorityQueue<>();
	    for(int i=0;i<n-1;i++) {
	    	if(valid[i])
	    		q.add(cuts[i]);
	    }
	    long ans=0;
	    int c=0;
	    while(!q.isEmpty()) {
	    	if(ans<k1) {
	    		int b=q.remove();
	    		if(b+ans>k1)
	    			break;
	    		else {
	    			ans++;
	    		c++;}
	    	}
	    	else {
	    		break;
	    	}
	    }
	    out.println(c);
		out.flush();
	}
	static int gcd(int a,int b) {
		if(a==0)
			return b;
		if(b==0)
			return a;
		if(a>b)
			return gcd(b,a%b);
		return gcd(a,b%a);
	}
	static class edge{
		int a;
		int b;
		edge(int a1,int b1){
			a=a1;
			b=b1;
		}
		public String toString() {
			return a+" "+b;
		}
	}
	static class UnionFind {
		int[] p, rank;

		UnionFind(int N)
		{
			p = new int[N];
			rank = new int[N];
			for (int i = 0; i < N; i++)
				p[i] = i;
		}

		int findSet(int x) { return p[x] == x ? x : (p[x] = findSet(p[x])); }

		boolean union(int x, int y)
		{
			x = findSet(x);
			y = findSet(y);
			if(x == y)
				return false;

			if (rank[x] > rank[y])
				p[y] = x;
			else
			{
				p[x] = y;
				if(rank[x] == rank[y])
					++rank[y];
			}
			return true;
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

public class Main {

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt(), k = in.nextInt();

        int[] x = new int[n];

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

        int cut = 0;
        int even = 0, odd = 0;
        long cost = 0;
        for (int i = 0; i < n; i++) {
            if (x[i] % 2 == 0)
                even++;
            else
                odd++;

            if (even == odd) {
                if ((i + 1) < n && (cost + Math.abs(x[i] - x[i + 1])) <= k) {
                    cut++;
                    cost += Math.abs(x[i] - x[i + 1]);
                    even = 0;
                    odd = 0;
                }
            }
        }

        System.out.println(cut);
    }
}

class Pair implements Comparator<Pair> {

    int x, y;

    public Pair() {
    }

    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public int compare(Pair o1, Pair o2) {
        return o1.x - o2.x;
    }
}

class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

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

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class q2 {
	static int x[];
	static int k;
	static int INF = (int) 1e9;

	static int bt(int cost, int even, int odd, int idx,int f) {

		if(idx==x.length) {
			if(odd==even)
				return 0;
			return -INF;
		}

		if(f==0) {
			int ans =0;
			if(x[idx]%2==0)
			 ans=Math.max(ans, bt( cost, even+1, odd,  idx+1,1));
			else
			  ans=	Math.max(ans, bt( cost, even, odd+1,  idx+1,1));
		   return ans;
		}

		int ans = 0;
		//contiue
		if(x[idx]%2==0)
		   ans=Math.max(ans	,bt( cost, even+1, odd,  idx+1,1));
		else
			 ans=Math.max(ans,bt( cost, even, odd+1,  idx+1,1));

		//cut
		if(cost+x[idx]-x[idx-1]<=k&&even==odd)
			 ans=1+Math.max(ans,bt( cost+x[idx]-x[idx-1], 0, 0,  idx+1,0));

		return ans;

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		k = sc.nextInt();
		x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();

		System.out.println(bt(0, 0, 0, 0, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public long nextlong() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			long res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nb = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] numbers = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        raspilBudjeta(nb[0], nb[1], numbers);
    }

    public static void raspilBudjeta(int n, int b, int[] numbers) {
        List<Integer> delimiters = new ArrayList<>();
        int even = 0, odd = 0, answer = 0;
        for (int i = 0; i < n - 1; i++) {
            if (numbers[i] % 2 == 0) {
                even++;
            } else {
                odd++;
            }
            if (even != 0 && odd != 0 && even == odd) {
                delimiters.add(Math.abs(numbers[i + 1] - numbers[i - 1]));
                even = 0;
                odd = 0;
            }
        }
        Collections.sort(delimiters);

        for (int i = 0; i < delimiters.size() && b > 0; i++) {
            Integer price = delimiters.get(i);
            if (b - price >= 0) {
                answer++;
                b -= price;
            }
        }

        System.out.println(answer);
    }
}

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

public class B998 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); //number of sequence
        int b= in.nextInt(); //number of bitcoins

        int ar[] = new int[n+1];
        for(int i=1;i<=n;i++){
                ar[i] = in.nextInt();
        }

        int  count = 0,odd=0,even=0;
        for(int i=1;i<=n;i++){
            if(ar[i]%2==0){
                ++even;
            }
            else {
                ++odd;
            }
            if(odd==even){
                if(i+1<=n && Math.abs(ar[i]-ar[i+1])<=b){
                    ++count;
                }
                else
                {
                    break;
                }
            }
        }
        System.out.println(count);

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

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

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

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

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

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

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;
public class Prac {

    public static void main(String[] args) {
           Scanner sc=new Scanner(System.in);

         int n=sc.nextInt();
         int b=sc.nextInt();
         int i,j=0;
         int arr[]=new int[n];
         int cut[]=new int[n];
         int bitcoin[]=new int[n];
         for(i=0;i<n;i++){
             arr[i]=sc.nextInt();
         }
         int even=0,odd=0;
         for(i=0;i<n;i++){
             if(arr[i]%2==0)
                 even++;
             else
                 odd++;
             if(even==odd){
                 cut[j]=i+1;
                 even=odd=0;
                 j++;
             }
         }
         for(i=0;i<j-1;i++){
             bitcoin[i]=arr[cut[i]]-arr[cut[i]-1];
             if(bitcoin[i]<0)
                 bitcoin[i]*=-1;
         }
         int count=0;
         j=0;
         Arrays.sort(bitcoin);
         for(i=0;i<n;i++)
             if(bitcoin[i]==0)
                 j++;
         for(i=j;i<n;i++){
             bitcoin[i]+=bitcoin[i-1];
             if(bitcoin[i]>b){
                 count=i-j;
                 break;
             }
             else
                 count=i-j+1;
         }
         System.out.println(count);
    }
}

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

// Driver program to read from file/System.in and increase stack size
public class Main implements Runnable {

  private final InputReader in;
  private final OutputWriter out;

  private Main(InputReader ir, OutputWriter or) {
    in = ir;
    out = or;
  }

  public static void main(String[] args) throws Exception {
    InputStream is = args.length > 0 ? new FileInputStream(args[0]) : System.in;
    InputReader in = new InputReader(is);
    OutputWriter out = new OutputWriter(System.out);
    Main r = new Main(in, out);
    new Thread(null, r, "Main", 1 << 26).start(); // 64 mb stack size
  }

  @Override
  public void run() {
    try {
      Solution.main(in, out);
    } finally {
      out.close();
    }
  }
}

// Fast I/O
// Taken and modified from here:
// https://www.quora.com/What-is-the-best-way-in-Java-to-take-input-and-write-output-for-an-Online-Judge
class InputReader {

  private InputStream is;
  private byte[] buff = new byte[8 * 1024];
  private int curChar;
  private int numChars;

  InputReader(InputStream is) {
    this.is = is;
  }

  int read() {
    if (numChars == -1) {
      throw new InputMismatchException();
    }
    if (curChar >= numChars) {
      curChar = 0;
      try {
        numChars = is.read(buff);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (numChars <= 0) {
        return -1;
      }
    }
    return buff[curChar++];
  }

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

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

  double nextDouble() {
    int c = read();
    while (isSpaceChar(c)) {
      c = read();
    }
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    double res = 0;
    while (!isSpaceChar(c) && c != '.') {
      if (c == 'e' || c == 'E') {
        return res * Math.pow(10, nextInt());
      }
      if (c < '0' || c > '9') {
        throw new InputMismatchException();
      }
      res *= 10;
      res += c - '0';
      c = read();
    }
    if (c == '.') {
      c = read();
      double m = 1;
      while (!isSpaceChar(c)) {
        if (c == 'e' || c == 'E') {
          return res * Math.pow(10, nextInt());
        }
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        m /= 10;
        res += (c - '0') * m;
        c = read();
      }
    }
    return res * sgn;
  }

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

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

  String next() {
    return nextString();
  }

  int[] nextIntArray(int size) {
    int[] arr = new int[size];
    for (int i = 0; i < size; i++) {
      arr[i] = nextInt();
    }
    return arr;
  }
}

class OutputWriter {

  private final PrintWriter writer;

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

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

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

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

  void printf(String format, Object... objects) {
    writer.printf(format, objects);
  }

  void printfln(String format, Object... objects) {
    writer.printf(format + "\n", objects);
  }

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

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

class Solution {

  static void main(InputReader in, OutputWriter out) {
    int n = in.nextInt();
    int b = in.nextInt();
    int[] a = in.nextIntArray(n);
    if (n < 4) {
      out.println(0);
      return;
    }

    int[] p = new int[n - 1]; // odd
    p[0] = a[0] % 2;
    for (int i = 1; i < n - 1; i++) {
      p[i] = p[i - 1] + a[i] % 2;
    }

    int[][] s = new int[n - 1][2];
    s[n - 2][a[n - 2] % 2]++;
    for (int i = n - 3; i >= 0; i--) {
      for (int j = 0; j < 2; j++) {
        s[i][j] = s[i + 1][j];
      }
      s[i][a[i] % 2]++;
    }

    List<Integer> cuts = new ArrayList<>(n - 1);
    for (int i = 1; i < n - 2; i += 2) {
      if (p[i] == (i + 1) / 2 && s[i][0] == (n - i - 1) / 2) {
        cuts.add(Math.abs(a[i] - a[i + 1]));
      }
    }
    cuts.sort(Comparator.naturalOrder());
    int ans = 0;
    for (int cut : cuts) {
      if (cut > b) {
        break;
      }
      ans++;
      b -= cut;
    }
    out.println(ans);
  }
}

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

public class cf493B{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int b = sc.nextInt();

		int[] aa = new int[n];

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

		int co=0;
        int i=0;
        int j=n-1;
        int fe = 0;
        int fo = 0;
        int be = 0;
        int bo = 0;

		while(i<j){
           if(aa[i]%2==0){
             fe++;
           }
           else{
           	 fo++;
           }

           if(aa[j]%2==0){
             be++;
           }
           else{
           	 bo++;
           }
           if(fe==fo){
             if(i+1<j-1 && Math.abs(aa[i]-aa[i+1])<=b){
               b -= Math.abs(aa[i]-aa[i+1]);
               co++;
             }
           }
           if(bo==be){
           	 if(i+1<j-1 && Math.abs(aa[j]-aa[j-1])<=b){
                b -= Math.abs(aa[j]-aa[j-1]);
                co++;
           	 }
           }
           i++;
           j--;
		}

		System.out.println(co);
	}
}

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

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int b=sc.nextInt();
		int array[]=new int[n];
		for(int i=0;i<n;i++){
		    array[i]=sc.nextInt();
		}

		int co=0,ce=0,cut=0,coin=0;
		for(int i=0;i<n;i++){
		    if(array[i]%2==0){ce+=1;}
		    else{co+=1;}
            if(co==ce && i!=array.length-1){cut+=1;
                if(i!=(array.length-1)){coin=coin+array[i+1]-array[i];}
                co=0;ce=0;
            }
            if(coin>b){--cut;break;}

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

import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;

public class B998 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); //number of sequence
        int b= in.nextInt(); //number of bitcoins

        int ar[] = new int[n+1];
        int cst[] = new int[n+1];
        cst[0]=-1;
        for(int i=1;i<=n;i++){
                ar[i] = in.nextInt();
                cst[i] = -1;
        }

        int  count = 0,odd=0,even=0;
        for(int i=1;i<=n;i++){
            if(ar[i]%2==0){
                ++even;
            }
            else {
                ++odd;
            }
            if(odd==even){
                if(i+1<=n && Math.abs(ar[i]-ar[i+1])<=b){
                    cst[i]=Math.abs(ar[i]-ar[i+1]);
                }
            }
        }
        Arrays.sort(cst);
        int temp=0;
        for(int i=1;i<=n;i++){
            if(cst[i]!=-1){
                temp+=cst[i];
                if(temp<b){
                    ++count;
                }
                else
                    break;
            }
        }
        System.out.println(count);

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

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

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

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

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

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

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

import java.util.*;

public class Cutting {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		int n = input.nextInt();
		int b = input.nextInt();

		int[] a = new int[n + 1];
		int[] even = new int[n + 1];
		int[] odd = new int[n + 1];

		for (int i = 1; i <= n; i++) {
			a[i] = input.nextInt();
			if (a[i] % 2 == 0) {
				even[i] = even[i - 1] + 1;
				odd[i] = odd[i - 1];
			} else {
				odd[i] = odd[i - 1] + 1;
				even[i] = even[i - 1];
			}
		}

		int count = 0;
		for (int i = 2; i < n; i++) {
			int diff = Math.abs(a[i] - a[i + 1]);
			if (even[i] == odd[i]) {
				if (b >= diff) {
					b -= diff;
					count++;
				} else {
					break;
				}
			}
		}

		System.out.println(count);
	}
}

import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Solution
{
    static class InputReader
	{
	    private final InputStream stream;
	    private final byte[] buf = new byte[8192];
	    private int curChar, snumChars;

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

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

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

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

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

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

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

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

	    private boolean isEndOfLine(int c) {
	      return c == '\n' || c == '\r' || c == -1;
	    }
	}
    /*static class node implements Comparable<node>
    {
        int index;
        int val;
        node(int a1,int a2)
        {
            index=a1;
            val=a2;
        }
        public int compareTo(node n1)
        {
            return(this.val-n1.val);
        }
    }*/
    public static void main(String[] args) throws IOException
    {
        InputReader in=new InputReader(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int [] a=new int[n];
        a=in.nextIntArray(n);
        int[] odd=new int[n+1];
        int[] even=new int[n+1];
        odd[0]=0;
        even[0]=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i-1]%2==1)
            {
                odd[i]=odd[i-1]+1;
                even[i]=even[i-1];
            }
            else
            {
                odd[i]=odd[i-1];
                even[i]=even[i-1]+1;
            }
        }
        int prev=0;
        PriorityQueue<Integer> cost=new PriorityQueue<Integer>();
        for(int i=1;i<=n;i++)
        {
            int oc=odd[i]-odd[prev];
            int ec=even[i]-even[prev];
            if(oc==ec)
            {
                cost.add((int)Math.abs(a[i-1]-a[i-2]));
                prev=i;
            }
        }
        int sum=0;
        int count=0;
        while(!cost.isEmpty() && sum<b)
        {
            sum+=cost.peek();
            cost.poll();
            count++;
        }
        System.out.println(count-1);
    }
}

import org.omg.PortableInterceptor.INACTIVE;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Cutting {

    public static int getMaxSubset(List<Integer> diffs, int coins){
        int max=Integer.MIN_VALUE;
        int n=diffs.size();
        boolean[][] dp=new boolean[n+1][coins+1];
        int[][] count = new int[n+1][coins+1];

        for(int i=0;i<=n;i++){
            dp[i][0]=true;
            count[i][0]=0;
        }
        for(int i=1;i<=coins;i++){
            dp[0][i]=false;
            count[0][i]=-1;
        }
        for(int j=1;j<=coins;j++){
            for(int i=1;i<=n;i++){

                dp[i][j]=dp[i-1][j];
                count[i][j]=count[i-1][j];
                if(diffs.get(i-1)<=j){
                    dp[i][j]=dp[i][j] || dp[i-1][j-diffs.get(i-1)];
                    count[i][j]= Math.max(count[i][j], count[i-1][j-diffs.get(i-1)]+1);
                    max=Math.max(count[i][j],max);
                }
            }
        }
//        for(int i=0;i<=n;i++){
//            for(int j=0;j<=coins;j++){
//                System.out.print(" " + count[i][j]);
//            }
//            System.out.println();
//        }
        return max;

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++)
            a[i]=in.nextInt();
        int odds=0, evens=0;
        List<Integer> diffs =new ArrayList<>();

        for(int i=0;i<n;i++){
            if(a[i]%2==1)
                odds++;
            else
                evens++;
            if(odds==evens)
            {
                if(i<n-1)
                    diffs.add(Math.abs(a[i+1]-a[i]));
            }
        }
        //System.out.println(diffs);
        int partitions =getMaxSubset(diffs, m);

        if(partitions== Integer.MIN_VALUE)
            System.out.println(0);
        else
            System.out.println(partitions);
    }
}

import java.util.*;
import java.math.BigInteger;

import  java.lang.Math;
import java.util.Arrays;

//br = new BufferedReader(new InputStreamReader(System.in));
//out = new PrintWriter(new OutputStreamWriter(System.out));
//br = new BufferedReader(new FileReader("in.txt"));
//out = new PrintWriter(new FileWriter("out.txt"));

//StringTokenizer tk;
    // tk=new StringTokenizer(in.readLine());
public class JavaApplication8 {

    public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
    int n,coin;
    int l_odd=0,l_even=0,r_odd=0,r_even=0,cut=0;

    n=s.nextInt();
    coin=s.nextInt();

    int x=0,y=0,cu_cost=0;
    int[]arr=new int[n];

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

        for (int i = 2; i < arr.length; i+=2) {
            for (int j = 0; j < arr.length; j++) {
                if(j<i){ // left array
                    if(arr[j]%2==0){
                        l_even++;
                    }
                    else{
                        l_odd++;
                    }
                }
                else{
                    if(arr[j]%2==0){
                        r_even++;
                    }
                    else{
                        r_odd++;
                    }
                }
            }
            if(l_even==l_odd && r_even==r_odd){
            x=arr[i];
            y=arr[i-1];
            cu_cost=Math.abs(x-y);
            if(cu_cost<=coin){
                cut++;
                coin=coin-cu_cost;
            }
//            else{
//                break;
//            }

        }
            l_even=0; l_odd=0; r_even=0; r_odd=0; // re-calculate for another cut

        }

        System.out.println(cut);
    }
}

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

public class Main {
	static int mod = (int) (1e9+7);
	static InputReader in;
    static PrintWriter out;

		public static void main(String args[] )  {

			in = new InputReader(System.in);
	        out = new PrintWriter(System.out);
	        Scanner in = new Scanner (System.in);
	       int n = in.nextInt();
	       int B= in.nextInt();
	       int[] a = new int[n];
	       for(int i=0;i<n;i++) {
	    	   		a[i]=in.nextInt();
	       }
	       int ce=0,co=0;
	       //int prev=a[0];
	       int[] count = new int[n];
	     //  int v=0;
	     //  Arrays.sort(a);
	       if(a[0]%2==0) {
	    	   	ce++;
	       }
	       else {
	    	   co++;
	       }

	       int p=0;
	       for(int i=1;i<n-1;i++) {
	    	   // a[i]=in.nextInt();

	    	   if(a[i]%2==0) {
	    		   ce++;
	    	   }
	    	   else {
	    		   co++;
	    	   }
	    	   //System.out.println(ce+" "+co);
	    	   if(co==ce) {
	    		  // count+=a[i]-prev;
	    		   //System.out.println(a[i]+" "+a[i+1]);
	    		   count[p]=Math.abs(a[i]-a[i+1]);
	    		   p++;
	    	   }
	    	  // prev=a[i];
	       }
	   // System.out.println(p);

	       Arrays.sort(a);

	       int sum=0;
	       int cou=0;
	       for(int i=0;i<p;i++) {

	    	   		sum+=count[i];
	    	   		if(sum>=B) {
	 	    		   break;
	 	    	   }
	    	   		else {
	    	   		cou++;
	    	   		}
	       }
	       System.out.println(cou);
	        in.close();
	        out.close();
		}

		static class InputReader
	    {

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

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

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

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

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

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

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

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

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

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

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

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

	    }
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	//YOU CAN DO IT ....
 static String s="";
 static  String t="";
  static int arr[];
    public static void main(String[] args) throws IOException {

    	Scanner sc =new Scanner(System.in);
    	int n=sc.nextInt();
    	int bit=sc.nextInt();
    	int arr[]=new int[n];
    	for(int i=0;i<n;i++)
    	{arr[i]=sc.nextInt();}
    	int odd=0,even=0;
    	int i=0;
    	int count=0;
    	while(bit>0&&i<n-1)
    	{
    		if(arr[i]%2==0)
    			even++;
    		else if(arr[i]%2==1)
    			odd++;
    		if(even==odd)
    		{   int x=bit-Math.abs(arr[i+1]-arr[i]);

    			if(x>=0) {
    				count++;
    				bit-=Math.abs(arr[i+1]-arr[i]);}
    			even=0;
    			odd=0;
    		}
    		i++;
    	}
    	System.out.print(count);

	}

    	static class Scanner
    	{
    		StringTokenizer st;
    		BufferedReader br;

    		public Scanner(InputStream s){    br = new BufferedReader(new InputStreamReader(s));}

    		public Scanner(FileReader r){    br = new BufferedReader(r);}

    		public String next() throws IOException
    		{
    			while (st == null || !st.hasMoreTokens())
    				st = new StringTokenizer(br.readLine());
    			return st.nextToken();
    		}

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

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

    		public String nextLine() throws IOException {return br.readLine();}

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

    		public boolean ready() throws IOException {return br.ready();}

    	}
    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class q2 {
	static int x[];
	static int k;
	static int INF = (int) 1e9;

	static int bt(int cost, int even, int odd, int idx,int f) {

		if(idx==x.length) {
			if(odd==even)
				return 0;
			return -INF;
		}

		if(f==0) {
			int ans =0;
			if(x[idx]%2==0)
			 ans=	bt( cost, even+1, odd,  idx+1,1);
			else
			  ans=	bt( cost, even, odd+1,  idx+1,1);
		   return ans;
		}

		int ans = 0;
		//contiue
		if(x[idx]%2==0)
		   ans=Math.max(ans	,bt( cost, even+1, odd,  idx+1,1));
		else
			 ans=Math.max(ans,bt( cost, even, odd+1,  idx+1,1));

		//cut
		if(cost+x[idx]-x[idx-1]<=k&&even==odd)
			 ans=1+Math.max(ans,bt( cost+x[idx]-x[idx-1], 0, 0,  idx+1,0));

		return ans;

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		k = sc.nextInt();
		x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();

		System.out.println(bt(0, 0, 0, 0, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public long nextlong() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			long res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Submit {
    public static void main(String args[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        String input=in.readLine();
        StringTokenizer st=new StringTokenizer(input," ");
        int n=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        input=in.readLine();
        st=new StringTokenizer(input," ");
        int c=0;
        int arr[]=new int[n];
        while(st.hasMoreTokens()){
            arr[c]=Integer.parseInt(st.nextToken());
            c++;
        }
        c=0;
        int record[][]=new int[1][2];
        for(int i=0;i<n-1;i++){
            if(arr[i]%2==0)
                record[0][0]++;
            else
                record[0][1]++;
            int abs = Math.abs(arr[i] - arr[i + 1]);
            if(record[0][0]==record[0][1] && abs <=b){
                record[0][0]=0; record[0][1]=0;
                c++;
                b-= abs;
            }
        }
        System.out.println(c);
    }
}