Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $$$n$$$ light bulbs in a single row. Each bulb has a number from $$$1$$$ to $$$n$$$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland. Now Vadim wants to put them back on.Vadim wants to put all bulb back on the garland. Vadim defines complexity of a garland to be the number of pairs of adjacent bulbs with numbers with different parity (remainder of the division by $$$2$$$). For example, the complexity of 1 4 2 3 5 is $$$2$$$ and the complexity of 1 3 5 7 6 4 2 is $$$1$$$.No one likes complexity, so Vadim wants to minimize the number of such pairs. Find the way to put all bulbs back on the garland, such that the complexity is as small as possible.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of light bulbs on the garland. The second line contains $$$n$$$ integers $$$p_1,\ p_2,\ \ldots,\ p_n$$$ ($$$0 \le p_i \le n$$$) — the number on the $$$i$$$-th bulb, or $$$0$$$ if it was removed.

Output a single number — the minimum complexity of the garland.

NoteIn the first example, one should place light bulbs as 1 5 4 2 3. In that case, the complexity would be equal to 2, because only $$$(5, 4)$$$ and $$$(2, 3)$$$ are the pairs of adjacent bulbs that have different parity.In the second case, one of the correct answers is 1 7 3 5 6 4 2.

"use strict";var readline=require("readline"),extendStatics=function(r,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])})(r,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function __extends(r,t){function n(){this.constructor=r}extendStatics(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function isFunction(r){return"function"==typeof r}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(r){r&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=r},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(r){setTimeout((function(){throw r}),0)}var empty={closed:!0,next:function(r){},error:function(r){if(config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)},complete:function(){}},isArray=function(){return Array.isArray||function(r){return r&&"number"==typeof r.length}}();function isObject(r){return null!==r&&"object"==typeof r}var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+" errors occurred during unsubscription:\n"+r.map((function(r,t){return t+1+") "+r.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}(),UnsubscriptionError=UnsubscriptionErrorImpl,Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._unsubscribe=r)}return r.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this._parentOrParents,e=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof r)n.remove(this);else if(null!==n)for(var i=0;i<n.length;++i){n[i].remove(this)}if(isFunction(e))try{e.call(this)}catch(r){t=r instanceof UnsubscriptionError?flattenUnsubscriptionErrors(r.errors):[r]}if(isArray(o)){i=-1;for(var s=o.length;++i<s;){var u=o[i];if(isObject(u))try{u.unsubscribe()}catch(r){t=t||[],r instanceof UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(r.errors)):t.push(r)}}}if(t)throw new UnsubscriptionError(t)}},r.prototype.add=function(t){var n=t;if(!t)return r.EMPTY;switch(typeof t){case"function":n=new r(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof r)){var e=n;(n=new r)._subscriptions=[e]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof r){if(o===this)return n;n._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return n;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},r.prototype.remove=function(r){var t=this._subscriptions;if(t){var n=t.indexOf(r);-1!==n&&t.splice(n,1)}},r.EMPTY=function(r){return r.closed=!0,r}(new r),r}();function flattenUnsubscriptionErrors(r){return r.reduce((function(r,t){return r.concat(t instanceof UnsubscriptionError?t.errors:t)}),[])}var rxSubscriber=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Subscriber=function(r){function t(n,e,o){var i=r.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=empty;break;case 1:if(!n){i.destination=empty;break}if("object"==typeof n){n instanceof t?(i.syncErrorThrowable=n.syncErrorThrowable,i.destination=n,n.add(i)):(i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n));break}default:i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n,e,o)}return i}return __extends(t,r),t.prototype[rxSubscriber]=function(){return this},t.create=function(r,n,e){var o=new t(r,n,e);return o.syncErrorThrowable=!1,o},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this))},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){this.destination.error(r),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var r=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=r,this},t}(Subscription),SafeSubscriber=function(r){function t(t,n,e,o){var i,s=r.call(this)||this;s._parentSubscriber=t;var u=s;return isFunction(n)?i=n:n&&(i=n.next,e=n.error,o=n.complete,n!==empty&&(isFunction((u=Object.create(n)).unsubscribe)&&s.add(u.unsubscribe.bind(u)),u.unsubscribe=s.unsubscribe.bind(s))),s._context=u,s._next=i,s._error=e,s._complete=o,s}return __extends(t,r),t.prototype.next=function(r){if(!this.isStopped&&this._next){var t=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,r)&&this.unsubscribe():this.__tryOrUnsub(this._next,r)}},t.prototype.error=function(r){if(!this.isStopped){var t=this._parentSubscriber,n=config.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,r),this.unsubscribe()):(this.__tryOrUnsub(this._error,r),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=r,t.syncErrorThrown=!0):hostReportError(r),this.unsubscribe();else{if(this.unsubscribe(),n)throw r;hostReportError(r)}}},t.prototype.complete=function(){var r=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return r._complete.call(r._context)};config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(r,t){try{r.call(this._context,t)}catch(r){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)}},t.prototype.__tryOrSetError=function(r,t,n){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return config.useDeprecatedSynchronousErrorHandling?(r.syncErrorValue=t,r.syncErrorThrown=!0,!0):(hostReportError(t),!0)}return!1},t.prototype._unsubscribe=function(){var r=this._parentSubscriber;this._context=null,this._parentSubscriber=null,r.unsubscribe()},t}(Subscriber);function canReportError(r){for(;r;){var t=r,n=t.closed,e=t.destination,o=t.isStopped;if(n||o)return!1;r=e&&e instanceof Subscriber?e:null}return!0}function toSubscriber(r,t,n){if(r){if(r instanceof Subscriber)return r;if(r[rxSubscriber])return r[rxSubscriber]()}return r||t||n?new Subscriber(r,t,n):new Subscriber(empty)}var observable=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function noop(){}function pipeFromArray(r){return r?1===r.length?r[0]:function(t){return r.reduce((function(r,t){return t(r)}),t)}:noop}var Observable=function(){function r(r){this._isScalar=!1,r&&(this._subscribe=r)}return r.prototype.lift=function(t){var n=new r;return n.source=this,n.operator=t,n},r.prototype.subscribe=function(r,t,n){var e=this.operator,o=toSubscriber(r,t,n);if(e?o.add(e.call(o,this.source)):o.add(this.source||config.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),config.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},r.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){config.useDeprecatedSynchronousErrorHandling&&(r.syncErrorThrown=!0,r.syncErrorValue=t),canReportError(r)?r.error(t):console.warn(t)}},r.prototype.forEach=function(r,t){var n=this;return new(t=getPromiseCtor(t))((function(t,e){var o;o=n.subscribe((function(t){try{r(t)}catch(r){e(r),o&&o.unsubscribe()}}),e,t)}))},r.prototype._subscribe=function(r){var t=this.source;return t&&t.subscribe(r)},r.prototype[observable]=function(){return this},r.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return 0===r.length?this:pipeFromArray(r)(this)},r.prototype.toPromise=function(r){var t=this;return new(r=getPromiseCtor(r))((function(r,n){var e;t.subscribe((function(r){return e=r}),(function(r){return n(r)}),(function(){return r(e)}))}))},r.create=function(t){return new r(t)},r}();function getPromiseCtor(r){if(r||(r=Promise),!r)throw new Error("no Promise impl found");return r}var EMPTY=new Observable((function(r){return r.complete()}));function empty$1(r){return r?emptyScheduled(r):EMPTY}function emptyScheduled(r){return new Observable((function(t){return r.schedule((function(){return t.complete()}))}))}var ArgumentOutOfRangeErrorImpl=function(){function r(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return r.prototype=Object.create(Error.prototype),r}(),ArgumentOutOfRangeError=ArgumentOutOfRangeErrorImpl;function map(r,t){return function(n){if("function"!=typeof r)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new MapOperator(r,t))}}var MapOperator=function(){function r(r,t){this.project=r,this.thisArg=t}return r.prototype.call=function(r,t){return t.subscribe(new MapSubscriber(r,this.project,this.thisArg))},r}(),MapSubscriber=function(r){function t(t,n,e){var o=r.call(this,t)||this;return o.project=n,o.count=0,o.thisArg=e||o,o}return __extends(t,r),t.prototype._next=function(r){var t;try{t=this.project.call(this.thisArg,r,this.count++)}catch(r){return void this.destination.error(r)}this.destination.next(t)},t}(Subscriber);function readStdin(){var r=readline.createInterface(process.stdin);return new Observable((function(t){return r.on("line",(function(r){return t.next(r)})),function(){return r.close()}}))}function take(r){return function(t){return 0===r?empty$1():t.lift(new TakeOperator(r))}}var TakeOperator=function(){function r(r){if(this.total=r,this.total<0)throw new ArgumentOutOfRangeError}return r.prototype.call=function(r,t){return t.subscribe(new TakeSubscriber(r,this.total))},r}(),TakeSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){var t=this.total,n=++this.count;n<=t&&(this.destination.next(r),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(Subscriber);function skip(r){return function(t){return t.lift(new SkipOperator(r))}}var SkipOperator=function(){function r(r){this.total=r}return r.prototype.call=function(r,t){return t.subscribe(new SkipSubscriber(r,this.total))},r}(),SkipSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){++this.count>this.total&&this.destination.next(r)},t}(Subscriber);readStdin().pipe(skip(1),take(1),map((function(r){return r.split(" ").map((function(r){return+r}))}))).subscribe((function(r){for(var t=0,n=0,e=0,o=[],i=0;i<r.length;i++)if(0===r[i]){for(var s=0===i?"any":r[i-1]%2==0?"even":"odd",u=i;i<r.length&&0===r[i];)i++;var c=--i===r.length-1?"any":r[i+1]%2==0?"even":"odd",a=i-u+1;o.push({left:s,right:c,distance:a})}else r[i]%2==0?n++:t++,i>0&&r[i-1]>0&&r[i-1]%2!=r[i]%2&&(e+=1);var p=Math.round(r.length/2),h=Math.floor(r.length/2),b=p-t,f=h-n,l=function(r,t){"any"===r?e+=1===t?0:1:"even"===r?f>=t?f-=t:e+=1:b>=t?b-=t:e+=1},d=function(r){var t=r.left,n=r.right,e=r.distance;return"any"===t||"any"===n?e+1e4:e};o.sort((function(r,t){return d(r)-d(t)})).forEach((function(r){var t=r.left,n=r.right,o=r.distance;"even"===t&&"odd"===n||"odd"===t&&"even"===n?e+=1:"any"===t?l(n,o):"any"===n?l(t,o):"even"===t?f>=o?f-=o:e+=2:"odd"===t&&(b>=o?b-=o:e+=2)})),console.log(e)}));

"use strict";var readline=require("readline"),extendStatics=function(r,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])})(r,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function __extends(r,t){function n(){this.constructor=r}extendStatics(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function isFunction(r){return"function"==typeof r}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(r){r&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=r},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(r){setTimeout((function(){throw r}),0)}var empty={closed:!0,next:function(r){},error:function(r){if(config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)},complete:function(){}},isArray=function(){return Array.isArray||function(r){return r&&"number"==typeof r.length}}();function isObject(r){return null!==r&&"object"==typeof r}var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+" errors occurred during unsubscription:\n"+r.map((function(r,t){return t+1+") "+r.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}(),UnsubscriptionError=UnsubscriptionErrorImpl,Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._unsubscribe=r)}return r.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this._parentOrParents,e=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof r)n.remove(this);else if(null!==n)for(var i=0;i<n.length;++i){n[i].remove(this)}if(isFunction(e))try{e.call(this)}catch(r){t=r instanceof UnsubscriptionError?flattenUnsubscriptionErrors(r.errors):[r]}if(isArray(o)){i=-1;for(var s=o.length;++i<s;){var u=o[i];if(isObject(u))try{u.unsubscribe()}catch(r){t=t||[],r instanceof UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(r.errors)):t.push(r)}}}if(t)throw new UnsubscriptionError(t)}},r.prototype.add=function(t){var n=t;if(!t)return r.EMPTY;switch(typeof t){case"function":n=new r(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof r)){var e=n;(n=new r)._subscriptions=[e]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof r){if(o===this)return n;n._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return n;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},r.prototype.remove=function(r){var t=this._subscriptions;if(t){var n=t.indexOf(r);-1!==n&&t.splice(n,1)}},r.EMPTY=function(r){return r.closed=!0,r}(new r),r}();function flattenUnsubscriptionErrors(r){return r.reduce((function(r,t){return r.concat(t instanceof UnsubscriptionError?t.errors:t)}),[])}var rxSubscriber=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Subscriber=function(r){function t(n,e,o){var i=r.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=empty;break;case 1:if(!n){i.destination=empty;break}if("object"==typeof n){n instanceof t?(i.syncErrorThrowable=n.syncErrorThrowable,i.destination=n,n.add(i)):(i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n));break}default:i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n,e,o)}return i}return __extends(t,r),t.prototype[rxSubscriber]=function(){return this},t.create=function(r,n,e){var o=new t(r,n,e);return o.syncErrorThrowable=!1,o},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this))},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){this.destination.error(r),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var r=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=r,this},t}(Subscription),SafeSubscriber=function(r){function t(t,n,e,o){var i,s=r.call(this)||this;s._parentSubscriber=t;var u=s;return isFunction(n)?i=n:n&&(i=n.next,e=n.error,o=n.complete,n!==empty&&(isFunction((u=Object.create(n)).unsubscribe)&&s.add(u.unsubscribe.bind(u)),u.unsubscribe=s.unsubscribe.bind(s))),s._context=u,s._next=i,s._error=e,s._complete=o,s}return __extends(t,r),t.prototype.next=function(r){if(!this.isStopped&&this._next){var t=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,r)&&this.unsubscribe():this.__tryOrUnsub(this._next,r)}},t.prototype.error=function(r){if(!this.isStopped){var t=this._parentSubscriber,n=config.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,r),this.unsubscribe()):(this.__tryOrUnsub(this._error,r),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=r,t.syncErrorThrown=!0):hostReportError(r),this.unsubscribe();else{if(this.unsubscribe(),n)throw r;hostReportError(r)}}},t.prototype.complete=function(){var r=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return r._complete.call(r._context)};config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(r,t){try{r.call(this._context,t)}catch(r){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)}},t.prototype.__tryOrSetError=function(r,t,n){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return config.useDeprecatedSynchronousErrorHandling?(r.syncErrorValue=t,r.syncErrorThrown=!0,!0):(hostReportError(t),!0)}return!1},t.prototype._unsubscribe=function(){var r=this._parentSubscriber;this._context=null,this._parentSubscriber=null,r.unsubscribe()},t}(Subscriber);function canReportError(r){for(;r;){var t=r,n=t.closed,e=t.destination,o=t.isStopped;if(n||o)return!1;r=e&&e instanceof Subscriber?e:null}return!0}function toSubscriber(r,t,n){if(r){if(r instanceof Subscriber)return r;if(r[rxSubscriber])return r[rxSubscriber]()}return r||t||n?new Subscriber(r,t,n):new Subscriber(empty)}var observable=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function noop(){}function pipeFromArray(r){return r?1===r.length?r[0]:function(t){return r.reduce((function(r,t){return t(r)}),t)}:noop}var Observable=function(){function r(r){this._isScalar=!1,r&&(this._subscribe=r)}return r.prototype.lift=function(t){var n=new r;return n.source=this,n.operator=t,n},r.prototype.subscribe=function(r,t,n){var e=this.operator,o=toSubscriber(r,t,n);if(e?o.add(e.call(o,this.source)):o.add(this.source||config.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),config.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},r.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){config.useDeprecatedSynchronousErrorHandling&&(r.syncErrorThrown=!0,r.syncErrorValue=t),canReportError(r)?r.error(t):console.warn(t)}},r.prototype.forEach=function(r,t){var n=this;return new(t=getPromiseCtor(t))((function(t,e){var o;o=n.subscribe((function(t){try{r(t)}catch(r){e(r),o&&o.unsubscribe()}}),e,t)}))},r.prototype._subscribe=function(r){var t=this.source;return t&&t.subscribe(r)},r.prototype[observable]=function(){return this},r.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return 0===r.length?this:pipeFromArray(r)(this)},r.prototype.toPromise=function(r){var t=this;return new(r=getPromiseCtor(r))((function(r,n){var e;t.subscribe((function(r){return e=r}),(function(r){return n(r)}),(function(){return r(e)}))}))},r.create=function(t){return new r(t)},r}();function getPromiseCtor(r){if(r||(r=Promise),!r)throw new Error("no Promise impl found");return r}var EMPTY=new Observable((function(r){return r.complete()}));function empty$1(r){return r?emptyScheduled(r):EMPTY}function emptyScheduled(r){return new Observable((function(t){return r.schedule((function(){return t.complete()}))}))}var ArgumentOutOfRangeErrorImpl=function(){function r(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return r.prototype=Object.create(Error.prototype),r}(),ArgumentOutOfRangeError=ArgumentOutOfRangeErrorImpl;function map(r,t){return function(n){if("function"!=typeof r)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new MapOperator(r,t))}}var MapOperator=function(){function r(r,t){this.project=r,this.thisArg=t}return r.prototype.call=function(r,t){return t.subscribe(new MapSubscriber(r,this.project,this.thisArg))},r}(),MapSubscriber=function(r){function t(t,n,e){var o=r.call(this,t)||this;return o.project=n,o.count=0,o.thisArg=e||o,o}return __extends(t,r),t.prototype._next=function(r){var t;try{t=this.project.call(this.thisArg,r,this.count++)}catch(r){return void this.destination.error(r)}this.destination.next(t)},t}(Subscriber);function readStdin(){var r=readline.createInterface(process.stdin);return new Observable((function(t){return r.on("line",(function(r){return t.next(r)})),function(){return r.close()}}))}function take(r){return function(t){return 0===r?empty$1():t.lift(new TakeOperator(r))}}var TakeOperator=function(){function r(r){if(this.total=r,this.total<0)throw new ArgumentOutOfRangeError}return r.prototype.call=function(r,t){return t.subscribe(new TakeSubscriber(r,this.total))},r}(),TakeSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){var t=this.total,n=++this.count;n<=t&&(this.destination.next(r),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(Subscriber);function skip(r){return function(t){return t.lift(new SkipOperator(r))}}var SkipOperator=function(){function r(r){this.total=r}return r.prototype.call=function(r,t){return t.subscribe(new SkipSubscriber(r,this.total))},r}(),SkipSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){++this.count>this.total&&this.destination.next(r)},t}(Subscriber);readStdin().pipe(skip(1),take(1),map((function(r){return r.split(" ").map((function(r){return+r}))}))).subscribe((function(r){for(var t=0,n=0,e=0,o=[],i=0;i<r.length;i++)if(0===r[i]){for(var s=0===i?"any":r[i-1]%2==0?"even":"odd",u=i;i<r.length&&0===r[i];)i++;var c=--i===r.length-1?"any":r[i+1]%2==0?"even":"odd",a=i-u+1;o.push({left:s,right:c,distance:a})}else r[i]%2==0?n++:t++,i>0&&r[i-1]>0&&r[i-1]%2!=r[i]%2&&(e+=1);var p=Math.round(r.length/2),b=Math.floor(r.length/2),h=p-t,f=b-n,l=function(r,t){"any"===r?e+=1:"even"===r?f>=t?f-=t:e+=1:h>=t?h-=t:e+=1};o.sort((function(r,t){return t.distance-r.distance})).forEach((function(r){var t=r.left,n=r.right,o=r.distance;"even"===t&&"odd"===n||"odd"===t&&"even"===n?e+=1:"any"===t?l(n,o):"any"===n?l(t,o):"even"===t?(f-=o)<0&&(e+=2):"odd"===t&&(h-=o)<0&&(e+=2)})),console.log(e)}));

"use strict";var readline=require("readline"),extendStatics=function(r,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])})(r,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function __extends(r,t){function n(){this.constructor=r}extendStatics(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function isFunction(r){return"function"==typeof r}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(r){r&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=r},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(r){setTimeout((function(){throw r}),0)}var empty={closed:!0,next:function(r){},error:function(r){if(config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)},complete:function(){}},isArray=function(){return Array.isArray||function(r){return r&&"number"==typeof r.length}}();function isObject(r){return null!==r&&"object"==typeof r}var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+" errors occurred during unsubscription:\n"+r.map((function(r,t){return t+1+") "+r.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}(),UnsubscriptionError=UnsubscriptionErrorImpl,Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._unsubscribe=r)}return r.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this._parentOrParents,e=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof r)n.remove(this);else if(null!==n)for(var i=0;i<n.length;++i){n[i].remove(this)}if(isFunction(e))try{e.call(this)}catch(r){t=r instanceof UnsubscriptionError?flattenUnsubscriptionErrors(r.errors):[r]}if(isArray(o)){i=-1;for(var s=o.length;++i<s;){var u=o[i];if(isObject(u))try{u.unsubscribe()}catch(r){t=t||[],r instanceof UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(r.errors)):t.push(r)}}}if(t)throw new UnsubscriptionError(t)}},r.prototype.add=function(t){var n=t;if(!t)return r.EMPTY;switch(typeof t){case"function":n=new r(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof r)){var e=n;(n=new r)._subscriptions=[e]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof r){if(o===this)return n;n._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return n;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},r.prototype.remove=function(r){var t=this._subscriptions;if(t){var n=t.indexOf(r);-1!==n&&t.splice(n,1)}},r.EMPTY=function(r){return r.closed=!0,r}(new r),r}();function flattenUnsubscriptionErrors(r){return r.reduce((function(r,t){return r.concat(t instanceof UnsubscriptionError?t.errors:t)}),[])}var rxSubscriber=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Subscriber=function(r){function t(n,e,o){var i=r.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=empty;break;case 1:if(!n){i.destination=empty;break}if("object"==typeof n){n instanceof t?(i.syncErrorThrowable=n.syncErrorThrowable,i.destination=n,n.add(i)):(i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n));break}default:i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n,e,o)}return i}return __extends(t,r),t.prototype[rxSubscriber]=function(){return this},t.create=function(r,n,e){var o=new t(r,n,e);return o.syncErrorThrowable=!1,o},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this))},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){this.destination.error(r),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var r=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=r,this},t}(Subscription),SafeSubscriber=function(r){function t(t,n,e,o){var i,s=r.call(this)||this;s._parentSubscriber=t;var u=s;return isFunction(n)?i=n:n&&(i=n.next,e=n.error,o=n.complete,n!==empty&&(isFunction((u=Object.create(n)).unsubscribe)&&s.add(u.unsubscribe.bind(u)),u.unsubscribe=s.unsubscribe.bind(s))),s._context=u,s._next=i,s._error=e,s._complete=o,s}return __extends(t,r),t.prototype.next=function(r){if(!this.isStopped&&this._next){var t=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,r)&&this.unsubscribe():this.__tryOrUnsub(this._next,r)}},t.prototype.error=function(r){if(!this.isStopped){var t=this._parentSubscriber,n=config.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,r),this.unsubscribe()):(this.__tryOrUnsub(this._error,r),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=r,t.syncErrorThrown=!0):hostReportError(r),this.unsubscribe();else{if(this.unsubscribe(),n)throw r;hostReportError(r)}}},t.prototype.complete=function(){var r=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return r._complete.call(r._context)};config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(r,t){try{r.call(this._context,t)}catch(r){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)}},t.prototype.__tryOrSetError=function(r,t,n){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return config.useDeprecatedSynchronousErrorHandling?(r.syncErrorValue=t,r.syncErrorThrown=!0,!0):(hostReportError(t),!0)}return!1},t.prototype._unsubscribe=function(){var r=this._parentSubscriber;this._context=null,this._parentSubscriber=null,r.unsubscribe()},t}(Subscriber);function canReportError(r){for(;r;){var t=r,n=t.closed,e=t.destination,o=t.isStopped;if(n||o)return!1;r=e&&e instanceof Subscriber?e:null}return!0}function toSubscriber(r,t,n){if(r){if(r instanceof Subscriber)return r;if(r[rxSubscriber])return r[rxSubscriber]()}return r||t||n?new Subscriber(r,t,n):new Subscriber(empty)}var observable=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function noop(){}function pipeFromArray(r){return r?1===r.length?r[0]:function(t){return r.reduce((function(r,t){return t(r)}),t)}:noop}var Observable=function(){function r(r){this._isScalar=!1,r&&(this._subscribe=r)}return r.prototype.lift=function(t){var n=new r;return n.source=this,n.operator=t,n},r.prototype.subscribe=function(r,t,n){var e=this.operator,o=toSubscriber(r,t,n);if(e?o.add(e.call(o,this.source)):o.add(this.source||config.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),config.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},r.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){config.useDeprecatedSynchronousErrorHandling&&(r.syncErrorThrown=!0,r.syncErrorValue=t),canReportError(r)?r.error(t):console.warn(t)}},r.prototype.forEach=function(r,t){var n=this;return new(t=getPromiseCtor(t))((function(t,e){var o;o=n.subscribe((function(t){try{r(t)}catch(r){e(r),o&&o.unsubscribe()}}),e,t)}))},r.prototype._subscribe=function(r){var t=this.source;return t&&t.subscribe(r)},r.prototype[observable]=function(){return this},r.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return 0===r.length?this:pipeFromArray(r)(this)},r.prototype.toPromise=function(r){var t=this;return new(r=getPromiseCtor(r))((function(r,n){var e;t.subscribe((function(r){return e=r}),(function(r){return n(r)}),(function(){return r(e)}))}))},r.create=function(t){return new r(t)},r}();function getPromiseCtor(r){if(r||(r=Promise),!r)throw new Error("no Promise impl found");return r}var EMPTY=new Observable((function(r){return r.complete()}));function empty$1(r){return r?emptyScheduled(r):EMPTY}function emptyScheduled(r){return new Observable((function(t){return r.schedule((function(){return t.complete()}))}))}var ArgumentOutOfRangeErrorImpl=function(){function r(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return r.prototype=Object.create(Error.prototype),r}(),ArgumentOutOfRangeError=ArgumentOutOfRangeErrorImpl;function map(r,t){return function(n){if("function"!=typeof r)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new MapOperator(r,t))}}var MapOperator=function(){function r(r,t){this.project=r,this.thisArg=t}return r.prototype.call=function(r,t){return t.subscribe(new MapSubscriber(r,this.project,this.thisArg))},r}(),MapSubscriber=function(r){function t(t,n,e){var o=r.call(this,t)||this;return o.project=n,o.count=0,o.thisArg=e||o,o}return __extends(t,r),t.prototype._next=function(r){var t;try{t=this.project.call(this.thisArg,r,this.count++)}catch(r){return void this.destination.error(r)}this.destination.next(t)},t}(Subscriber);function readStdin(){var r=readline.createInterface(process.stdin);return new Observable((function(t){return r.on("line",(function(r){return t.next(r)})),function(){return r.close()}}))}function take(r){return function(t){return 0===r?empty$1():t.lift(new TakeOperator(r))}}var TakeOperator=function(){function r(r){if(this.total=r,this.total<0)throw new ArgumentOutOfRangeError}return r.prototype.call=function(r,t){return t.subscribe(new TakeSubscriber(r,this.total))},r}(),TakeSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){var t=this.total,n=++this.count;n<=t&&(this.destination.next(r),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(Subscriber);function skip(r){return function(t){return t.lift(new SkipOperator(r))}}var SkipOperator=function(){function r(r){this.total=r}return r.prototype.call=function(r,t){return t.subscribe(new SkipSubscriber(r,this.total))},r}(),SkipSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){++this.count>this.total&&this.destination.next(r)},t}(Subscriber);readStdin().pipe(skip(1),take(1),map((function(r){return r.split(" ").map((function(r){return+r}))}))).subscribe((function(r){for(var t=0,n=0,e=0,o=[],i=0;i<r.length;i++)if(0===r[i]){for(var s=0===i?"any":r[i-1]%2==0?"even":"odd",u=i;i<r.length&&0===r[i];)i++;var c=--i===r.length-1?"any":r[i+1]%2==0?"even":"odd",a=i-u+1;o.push({left:s,right:c,distance:a})}else r[i]%2==0?n++:t++,i>0&&r[i-1]>0&&r[i-1]%2!=r[i]%2&&(e+=1);var p=Math.round(r.length/2),h=Math.floor(r.length/2),b=p-t,f=h-n,l=function(r,t){"any"===r?e+=1===t?0:1:"even"===r?f>=t?f-=t:e+=1:b>=t?b-=t:e+=1},d=function(r){var t=r.left,n=r.right,e=r.distance;return"any"===t||"any"===n?e+1e4:e};o.sort((function(r,t){return d(r)-d(t)})).forEach((function(r){var t=r.left,n=r.right,o=r.distance;"even"===t&&"odd"===n||"odd"===t&&"even"===n?e+=1:"any"===t?l(n,o):"any"===n?l(t,o):"even"===t?f>o?f-=o:e+=2:"odd"===t&&(b>o?b-=o:e+=2)})),console.log(e)}));

"use strict";var readline=require("readline"),extendStatics=function(r,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])})(r,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function __extends(r,t){function n(){this.constructor=r}extendStatics(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function isFunction(r){return"function"==typeof r}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(r){r&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=r},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(r){setTimeout((function(){throw r}),0)}var empty={closed:!0,next:function(r){},error:function(r){if(config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)},complete:function(){}},isArray=function(){return Array.isArray||function(r){return r&&"number"==typeof r.length}}();function isObject(r){return null!==r&&"object"==typeof r}var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+" errors occurred during unsubscription:\n"+r.map((function(r,t){return t+1+") "+r.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}(),UnsubscriptionError=UnsubscriptionErrorImpl,Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._unsubscribe=r)}return r.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this._parentOrParents,e=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof r)n.remove(this);else if(null!==n)for(var i=0;i<n.length;++i){n[i].remove(this)}if(isFunction(e))try{e.call(this)}catch(r){t=r instanceof UnsubscriptionError?flattenUnsubscriptionErrors(r.errors):[r]}if(isArray(o)){i=-1;for(var s=o.length;++i<s;){var u=o[i];if(isObject(u))try{u.unsubscribe()}catch(r){t=t||[],r instanceof UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(r.errors)):t.push(r)}}}if(t)throw new UnsubscriptionError(t)}},r.prototype.add=function(t){var n=t;if(!t)return r.EMPTY;switch(typeof t){case"function":n=new r(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof r)){var e=n;(n=new r)._subscriptions=[e]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof r){if(o===this)return n;n._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return n;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},r.prototype.remove=function(r){var t=this._subscriptions;if(t){var n=t.indexOf(r);-1!==n&&t.splice(n,1)}},r.EMPTY=function(r){return r.closed=!0,r}(new r),r}();function flattenUnsubscriptionErrors(r){return r.reduce((function(r,t){return r.concat(t instanceof UnsubscriptionError?t.errors:t)}),[])}var rxSubscriber=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Subscriber=function(r){function t(n,e,o){var i=r.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=empty;break;case 1:if(!n){i.destination=empty;break}if("object"==typeof n){n instanceof t?(i.syncErrorThrowable=n.syncErrorThrowable,i.destination=n,n.add(i)):(i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n));break}default:i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n,e,o)}return i}return __extends(t,r),t.prototype[rxSubscriber]=function(){return this},t.create=function(r,n,e){var o=new t(r,n,e);return o.syncErrorThrowable=!1,o},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this))},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){this.destination.error(r),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var r=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=r,this},t}(Subscription),SafeSubscriber=function(r){function t(t,n,e,o){var i,s=r.call(this)||this;s._parentSubscriber=t;var u=s;return isFunction(n)?i=n:n&&(i=n.next,e=n.error,o=n.complete,n!==empty&&(isFunction((u=Object.create(n)).unsubscribe)&&s.add(u.unsubscribe.bind(u)),u.unsubscribe=s.unsubscribe.bind(s))),s._context=u,s._next=i,s._error=e,s._complete=o,s}return __extends(t,r),t.prototype.next=function(r){if(!this.isStopped&&this._next){var t=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,r)&&this.unsubscribe():this.__tryOrUnsub(this._next,r)}},t.prototype.error=function(r){if(!this.isStopped){var t=this._parentSubscriber,n=config.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,r),this.unsubscribe()):(this.__tryOrUnsub(this._error,r),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=r,t.syncErrorThrown=!0):hostReportError(r),this.unsubscribe();else{if(this.unsubscribe(),n)throw r;hostReportError(r)}}},t.prototype.complete=function(){var r=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return r._complete.call(r._context)};config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(r,t){try{r.call(this._context,t)}catch(r){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)}},t.prototype.__tryOrSetError=function(r,t,n){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return config.useDeprecatedSynchronousErrorHandling?(r.syncErrorValue=t,r.syncErrorThrown=!0,!0):(hostReportError(t),!0)}return!1},t.prototype._unsubscribe=function(){var r=this._parentSubscriber;this._context=null,this._parentSubscriber=null,r.unsubscribe()},t}(Subscriber);function canReportError(r){for(;r;){var t=r,n=t.closed,e=t.destination,o=t.isStopped;if(n||o)return!1;r=e&&e instanceof Subscriber?e:null}return!0}function toSubscriber(r,t,n){if(r){if(r instanceof Subscriber)return r;if(r[rxSubscriber])return r[rxSubscriber]()}return r||t||n?new Subscriber(r,t,n):new Subscriber(empty)}var observable=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function noop(){}function pipeFromArray(r){return r?1===r.length?r[0]:function(t){return r.reduce((function(r,t){return t(r)}),t)}:noop}var Observable=function(){function r(r){this._isScalar=!1,r&&(this._subscribe=r)}return r.prototype.lift=function(t){var n=new r;return n.source=this,n.operator=t,n},r.prototype.subscribe=function(r,t,n){var e=this.operator,o=toSubscriber(r,t,n);if(e?o.add(e.call(o,this.source)):o.add(this.source||config.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),config.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},r.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){config.useDeprecatedSynchronousErrorHandling&&(r.syncErrorThrown=!0,r.syncErrorValue=t),canReportError(r)?r.error(t):console.warn(t)}},r.prototype.forEach=function(r,t){var n=this;return new(t=getPromiseCtor(t))((function(t,e){var o;o=n.subscribe((function(t){try{r(t)}catch(r){e(r),o&&o.unsubscribe()}}),e,t)}))},r.prototype._subscribe=function(r){var t=this.source;return t&&t.subscribe(r)},r.prototype[observable]=function(){return this},r.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return 0===r.length?this:pipeFromArray(r)(this)},r.prototype.toPromise=function(r){var t=this;return new(r=getPromiseCtor(r))((function(r,n){var e;t.subscribe((function(r){return e=r}),(function(r){return n(r)}),(function(){return r(e)}))}))},r.create=function(t){return new r(t)},r}();function getPromiseCtor(r){if(r||(r=Promise),!r)throw new Error("no Promise impl found");return r}var EMPTY=new Observable((function(r){return r.complete()}));function empty$1(r){return r?emptyScheduled(r):EMPTY}function emptyScheduled(r){return new Observable((function(t){return r.schedule((function(){return t.complete()}))}))}var ArgumentOutOfRangeErrorImpl=function(){function r(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return r.prototype=Object.create(Error.prototype),r}(),ArgumentOutOfRangeError=ArgumentOutOfRangeErrorImpl;function map(r,t){return function(n){if("function"!=typeof r)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new MapOperator(r,t))}}var MapOperator=function(){function r(r,t){this.project=r,this.thisArg=t}return r.prototype.call=function(r,t){return t.subscribe(new MapSubscriber(r,this.project,this.thisArg))},r}(),MapSubscriber=function(r){function t(t,n,e){var o=r.call(this,t)||this;return o.project=n,o.count=0,o.thisArg=e||o,o}return __extends(t,r),t.prototype._next=function(r){var t;try{t=this.project.call(this.thisArg,r,this.count++)}catch(r){return void this.destination.error(r)}this.destination.next(t)},t}(Subscriber);function readStdin(){var r=readline.createInterface(process.stdin);return new Observable((function(t){return r.on("line",(function(r){return t.next(r)})),function(){return r.close()}}))}function take(r){return function(t){return 0===r?empty$1():t.lift(new TakeOperator(r))}}var TakeOperator=function(){function r(r){if(this.total=r,this.total<0)throw new ArgumentOutOfRangeError}return r.prototype.call=function(r,t){return t.subscribe(new TakeSubscriber(r,this.total))},r}(),TakeSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){var t=this.total,n=++this.count;n<=t&&(this.destination.next(r),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(Subscriber);function skip(r){return function(t){return t.lift(new SkipOperator(r))}}var SkipOperator=function(){function r(r){this.total=r}return r.prototype.call=function(r,t){return t.subscribe(new SkipSubscriber(r,this.total))},r}(),SkipSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){++this.count>this.total&&this.destination.next(r)},t}(Subscriber);readStdin().pipe(skip(1),take(1),map((function(r){return r.split(" ").map((function(r){return+r}))}))).subscribe((function(r){for(var t=0,n=0,e=0,o=[],i=0;i<r.length;i++)if(0===r[i]){for(var s=0===i?"any":r[i-1]%2==0?"even":"odd",u=i;i<r.length&&0===r[i];)i++;var c=--i===r.length-1?"any":r[i+1]%2==0?"even":"odd",a=i-u+1;o.push({left:s,right:c,distance:a})}else r[i]%2==0?n++:t++,i>0&&r[i-1]>0&&r[i-1]%2!=r[i]%2&&(e+=1);var p=Math.round(r.length/2),b=Math.floor(r.length/2),h=p-t,f=b-n,l=function(r,t){"any"===r?e+=1===t?0:1:"even"===r?f>=t?f-=t:e+=1:h>=t?h-=t:e+=1};o.sort((function(r,t){return t.distance-r.distance})).forEach((function(r){var t=r.left,n=r.right,o=r.distance;"even"===t&&"odd"===n||"odd"===t&&"even"===n?e+=1:"any"===t?l(n,o):"any"===n?l(t,o):"even"===t?(f-=o)<0&&(e+=2):"odd"===t&&(h-=o)<0&&(e+=2)})),console.log(e)}));

"use strict";var readline=require("readline"),extendStatics=function(r,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])})(r,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function __extends(r,t){function n(){this.constructor=r}extendStatics(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function isFunction(r){return"function"==typeof r}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(r){r&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=r},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(r){setTimeout((function(){throw r}),0)}var empty={closed:!0,next:function(r){},error:function(r){if(config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)},complete:function(){}},isArray=function(){return Array.isArray||function(r){return r&&"number"==typeof r.length}}();function isObject(r){return null!==r&&"object"==typeof r}var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+" errors occurred during unsubscription:\n"+r.map((function(r,t){return t+1+") "+r.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}(),UnsubscriptionError=UnsubscriptionErrorImpl,Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._unsubscribe=r)}return r.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this._parentOrParents,e=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof r)n.remove(this);else if(null!==n)for(var i=0;i<n.length;++i){n[i].remove(this)}if(isFunction(e))try{e.call(this)}catch(r){t=r instanceof UnsubscriptionError?flattenUnsubscriptionErrors(r.errors):[r]}if(isArray(o)){i=-1;for(var s=o.length;++i<s;){var u=o[i];if(isObject(u))try{u.unsubscribe()}catch(r){t=t||[],r instanceof UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(r.errors)):t.push(r)}}}if(t)throw new UnsubscriptionError(t)}},r.prototype.add=function(t){var n=t;if(!t)return r.EMPTY;switch(typeof t){case"function":n=new r(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof r)){var e=n;(n=new r)._subscriptions=[e]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof r){if(o===this)return n;n._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return n;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},r.prototype.remove=function(r){var t=this._subscriptions;if(t){var n=t.indexOf(r);-1!==n&&t.splice(n,1)}},r.EMPTY=function(r){return r.closed=!0,r}(new r),r}();function flattenUnsubscriptionErrors(r){return r.reduce((function(r,t){return r.concat(t instanceof UnsubscriptionError?t.errors:t)}),[])}var rxSubscriber=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Subscriber=function(r){function t(n,e,o){var i=r.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=empty;break;case 1:if(!n){i.destination=empty;break}if("object"==typeof n){n instanceof t?(i.syncErrorThrowable=n.syncErrorThrowable,i.destination=n,n.add(i)):(i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n));break}default:i.syncErrorThrowable=!0,i.destination=new SafeSubscriber(i,n,e,o)}return i}return __extends(t,r),t.prototype[rxSubscriber]=function(){return this},t.create=function(r,n,e){var o=new t(r,n,e);return o.syncErrorThrowable=!1,o},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this))},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){this.destination.error(r),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var r=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=r,this},t}(Subscription),SafeSubscriber=function(r){function t(t,n,e,o){var i,s=r.call(this)||this;s._parentSubscriber=t;var u=s;return isFunction(n)?i=n:n&&(i=n.next,e=n.error,o=n.complete,n!==empty&&(isFunction((u=Object.create(n)).unsubscribe)&&s.add(u.unsubscribe.bind(u)),u.unsubscribe=s.unsubscribe.bind(s))),s._context=u,s._next=i,s._error=e,s._complete=o,s}return __extends(t,r),t.prototype.next=function(r){if(!this.isStopped&&this._next){var t=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,r)&&this.unsubscribe():this.__tryOrUnsub(this._next,r)}},t.prototype.error=function(r){if(!this.isStopped){var t=this._parentSubscriber,n=config.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,r),this.unsubscribe()):(this.__tryOrUnsub(this._error,r),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=r,t.syncErrorThrown=!0):hostReportError(r),this.unsubscribe();else{if(this.unsubscribe(),n)throw r;hostReportError(r)}}},t.prototype.complete=function(){var r=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return r._complete.call(r._context)};config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(r,t){try{r.call(this._context,t)}catch(r){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)}},t.prototype.__tryOrSetError=function(r,t,n){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return config.useDeprecatedSynchronousErrorHandling?(r.syncErrorValue=t,r.syncErrorThrown=!0,!0):(hostReportError(t),!0)}return!1},t.prototype._unsubscribe=function(){var r=this._parentSubscriber;this._context=null,this._parentSubscriber=null,r.unsubscribe()},t}(Subscriber);function canReportError(r){for(;r;){var t=r,n=t.closed,e=t.destination,o=t.isStopped;if(n||o)return!1;r=e&&e instanceof Subscriber?e:null}return!0}function toSubscriber(r,t,n){if(r){if(r instanceof Subscriber)return r;if(r[rxSubscriber])return r[rxSubscriber]()}return r||t||n?new Subscriber(r,t,n):new Subscriber(empty)}var observable=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function noop(){}function pipeFromArray(r){return r?1===r.length?r[0]:function(t){return r.reduce((function(r,t){return t(r)}),t)}:noop}var Observable=function(){function r(r){this._isScalar=!1,r&&(this._subscribe=r)}return r.prototype.lift=function(t){var n=new r;return n.source=this,n.operator=t,n},r.prototype.subscribe=function(r,t,n){var e=this.operator,o=toSubscriber(r,t,n);if(e?o.add(e.call(o,this.source)):o.add(this.source||config.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),config.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},r.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){config.useDeprecatedSynchronousErrorHandling&&(r.syncErrorThrown=!0,r.syncErrorValue=t),canReportError(r)?r.error(t):console.warn(t)}},r.prototype.forEach=function(r,t){var n=this;return new(t=getPromiseCtor(t))((function(t,e){var o;o=n.subscribe((function(t){try{r(t)}catch(r){e(r),o&&o.unsubscribe()}}),e,t)}))},r.prototype._subscribe=function(r){var t=this.source;return t&&t.subscribe(r)},r.prototype[observable]=function(){return this},r.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return 0===r.length?this:pipeFromArray(r)(this)},r.prototype.toPromise=function(r){var t=this;return new(r=getPromiseCtor(r))((function(r,n){var e;t.subscribe((function(r){return e=r}),(function(r){return n(r)}),(function(){return r(e)}))}))},r.create=function(t){return new r(t)},r}();function getPromiseCtor(r){if(r||(r=Promise),!r)throw new Error("no Promise impl found");return r}var EMPTY=new Observable((function(r){return r.complete()}));function empty$1(r){return r?emptyScheduled(r):EMPTY}function emptyScheduled(r){return new Observable((function(t){return r.schedule((function(){return t.complete()}))}))}var ArgumentOutOfRangeErrorImpl=function(){function r(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return r.prototype=Object.create(Error.prototype),r}(),ArgumentOutOfRangeError=ArgumentOutOfRangeErrorImpl;function map(r,t){return function(n){if("function"!=typeof r)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new MapOperator(r,t))}}var MapOperator=function(){function r(r,t){this.project=r,this.thisArg=t}return r.prototype.call=function(r,t){return t.subscribe(new MapSubscriber(r,this.project,this.thisArg))},r}(),MapSubscriber=function(r){function t(t,n,e){var o=r.call(this,t)||this;return o.project=n,o.count=0,o.thisArg=e||o,o}return __extends(t,r),t.prototype._next=function(r){var t;try{t=this.project.call(this.thisArg,r,this.count++)}catch(r){return void this.destination.error(r)}this.destination.next(t)},t}(Subscriber);function readStdin(){var r=readline.createInterface(process.stdin);return new Observable((function(t){return r.on("line",(function(r){return t.next(r)})),function(){return r.close()}}))}function take(r){return function(t){return 0===r?empty$1():t.lift(new TakeOperator(r))}}var TakeOperator=function(){function r(r){if(this.total=r,this.total<0)throw new ArgumentOutOfRangeError}return r.prototype.call=function(r,t){return t.subscribe(new TakeSubscriber(r,this.total))},r}(),TakeSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){var t=this.total,n=++this.count;n<=t&&(this.destination.next(r),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(Subscriber);function skip(r){return function(t){return t.lift(new SkipOperator(r))}}var SkipOperator=function(){function r(r){this.total=r}return r.prototype.call=function(r,t){return t.subscribe(new SkipSubscriber(r,this.total))},r}(),SkipSubscriber=function(r){function t(t,n){var e=r.call(this,t)||this;return e.total=n,e.count=0,e}return __extends(t,r),t.prototype._next=function(r){++this.count>this.total&&this.destination.next(r)},t}(Subscriber);readStdin().pipe(skip(1),take(1),map((function(r){return r.split(" ").map((function(r){return+r}))}))).subscribe((function(r){for(var t=0,n=0,e=0,o=[],i=0;i<r.length;i++)if(0===r[i]){for(var s=0===i?"any":r[i-1]%2==0?"even":"odd",u=i;i<r.length&&0===r[i];)i++;var c=--i===r.length-1?"any":r[i+1]%2==0?"even":"odd",a=i-u+1;o.push({left:s,right:c,distance:a})}else r[i]%2==0?n++:t++,i>0&&r[i-1]>0&&r[i-1]%2!=r[i]%2&&(e+=1);var p=Math.round(r.length/2),h=Math.floor(r.length/2),b=p-t,f=h-n,l=function(r,t){"any"===r?e+=1===t?0:1:"even"===r?f>=t?f-=t:e+=1:b>=t?b-=t:e+=1},d=function(r){var t=r.left,n=r.right,e=r.distance;return"any"===t||"any"===n?e+1e4:e};o.sort((function(r,t){return d(r)-d(t)})).forEach((function(r){var t=r.left,n=r.right,o=r.distance;"even"===t&&"odd"===n||"odd"===t&&"even"===n?e+=1:"any"===t?l(n,o):"any"===n?l(t,o):"even"===t?(f-=o)<0&&(e+=2):"odd"===t&&(b-=o)<0&&(e+=2)})),console.log(e)}));


Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:  To make a "red bouquet", it needs 3 red flowers.  To make a "green bouquet", it needs 3 green flowers.  To make a "blue bouquet", it needs 3 blue flowers.  To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower. Help Fox Ciel to find the maximal number of bouquets she can make.

The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109) — the number of red, green and blue flowers.

Print the maximal number of bouquets Fox Ciel can make.

NoteIn test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.

var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		if (colors[i] > 3){
			if (colors[i] % 3 == 0){
				count += colors[i] / 3 - 1;
				colors[i] = 3;
			}
			else {
				count += Math.floor(colors[i] / 3);
				colors[i] = colors[i] % 3;
			}
		}
	}

	if ( colors.filter(function(index) {
		return index == 2
	}).length < 2) {
		for (var i in colors){
			if (colors[i] == 3){
				colors[i] -= 3;
				count++;
			}
		}
	}

	while (colors.filter(function(index) {
		return index >= 1;
	}).length >= 3) {
		for (var i in colors) {
			colors[i] -= 1;
		}
		count++;
	}

	return count;
};

var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));

var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];
	while (r >= 1 && g >= 1 && b >= 1){
		r -= 1;
		g -= 1;
		b -= 1;
		count++;
	}

	return count;
};

var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));

var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];
	if (r + g + b >= 6){

		count += 2;
	}
	else{
		while (r >= 1 && g >= 1 && b >= 1){
			r -= 1;
			g -= 1;
			b -= 1;
			count++;
		}
	}

	return count;
};
var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));

var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] >= 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];
	while (r >= 1 && g >= 1 && b >= 1){
		r -= 1;
		g -= 1;
		b -= 1;
		count++;
	}

	return count;
};

var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));

var flowers = function(r, g, b){
	return Math.floor((r + g + b) / 3);
};

var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));

var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];

	if (r + g + b == 9){
		count += 3
	}
	else if (r + g + b >= 6){
		count += 2;
	}
	else{
		while (r >= 1 && g >= 1 && b >= 1){
			r -= 1;
			g -= 1;
			b -= 1;
			count++;
		}
	}

	return count;
};

var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));


Stepan is a very experienced olympiad participant. He has n cups for Physics olympiads and m cups for Informatics olympiads. Each cup is characterized by two parameters — its significance ci and width wi.Stepan decided to expose some of his cups on a shelf with width d in such a way, that:  there is at least one Physics cup and at least one Informatics cup on the shelf,  the total width of the exposed cups does not exceed d,  from each subjects (Physics and Informatics) some of the most significant cups are exposed (i. e. if a cup for some subject with significance x is exposed, then all the cups for this subject with significance greater than x must be exposed too). Your task is to determine the maximum possible total significance, which Stepan can get when he exposes cups on the shelf with width d, considering all the rules described above. The total significance is the sum of significances of all the exposed cups.

The first line contains three integers n, m and d (1 ≤ n, m ≤ 100 000, 1 ≤ d ≤ 109) — the number of cups for Physics olympiads, the number of cups for Informatics olympiads and the width of the shelf. Each of the following n lines contains two integers ci and wi (1 ≤ ci, wi ≤ 109) — significance and width of the i-th cup for Physics olympiads. Each of the following m lines contains two integers cj and wj (1 ≤ cj, wj ≤ 109) — significance and width of the j-th cup for Informatics olympiads.

Print the maximum possible total significance, which Stepan can get exposing cups on the shelf with width d, considering all the rules described in the statement. If there is no way to expose cups on the shelf, then print 0.

NoteIn the first example Stepan has only one Informatics cup which must be exposed on the shelf. Its significance equals 3 and width equals 2, so after Stepan exposes it, the width of free space on the shelf becomes equal to 6. Also, Stepan must expose the second Physics cup (which has width 5), because it is the most significant cup for Physics (its significance equals 5). After that Stepan can not expose more cups on the shelf, because there is no enough free space. Thus, the maximum total significance of exposed cups equals to 8.

function f(a,b){
    if (a[0]==b[0]){return a[1]-b[1];}else{return b[0]-a[0];}
}

var s=readline().split(' '); var n=+s[0];var m=+s[1];var d=+s[2];

var a=[]; var i;
for (i=0;i<n;i++){var s=readline().split(' '); a.push([+s[0],+s[1]]); }

var b=[];
for (i=0;i<m;i++){var s=readline().split(' '); b.push([+s[0],+s[1]]); }

a.sort(f);b.sort(f);

var sums1a=[]; var sums2a=[]; var sum1a=0; var sum2a=0;
for (i=0;i<n;i++){
   sum1a+=a[i][0]; sum2a+=a[i][1]; sums1a.push(sum1a); sums2a.push(sum2a);
}

var sums1b=[]; var sums2b=[]; var sum1b=0; var sum2b=0;
for (i=0;i<m;i++){
   sum1b+=b[i][0]; sum2b+=b[i][1]; sums1b.push(sum1b); sums2b.push(sum2b);
}

var ans=0;
var z = m-1;
for(var i=0; i<n; i++) {
    while((z >= 0) && (sums2a[i]+sums2b[z]>d)) --z;
    if (z < 0) continue;
    var w = sums1a[i]+sums1b[z]; if(w > ans) ans = w;
}

print(ans)

var _ = readline().split( ' ' );
var N = +_[ 0 ];
var M = +_[ 1 ];
var D = +_[ 2 ];
function cmp( a, b ) {
  var x, y;
  if( a[ 0 ] != b[ 0 ] ) {
    x = -a[ 0 ];
    y = -b[ 0 ];
  } else {
    x = a[ 1 ];
    y = b[ 1 ];
  }
  if( x < y ) return -1;
  else if( x === y ) return 0;
  return 1;
}
var ACW = [];
for( var i = 0; i < N; ++i ) {
  var __ = readline().split( ' ' );
  ACW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
ACW.sort( cmp );
var BCW = [];
for( var i = 0; i < M; ++i ) {
  var __ = readline().split( ' ' );
  BCW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
BCW.sort( cmp );
var curc = 0;
var curw = 0;
var bptr = 0; // [ 0, bptr )
while( bptr < M ) {
  if( curw + BCW[ bptr ][ 1 ] > D ) break;
  curw += BCW[ bptr ][ 1 ];
  curc += BCW[ bptr ][ 0 ];
  ++bptr;
}
var ans = 0;
for( var aptr = 0; aptr < N; ++aptr ) {
  curw += ACW[ aptr ][ 1 ];
  curc += ACW[ aptr ][ 0 ];
  while( curw > D && bptr > 0 ) {
    --bptr;
    curw -= BCW[ bptr ][ 1 ];
    curc -= BCW[ bptr ][ 0 ];
  }
  if( bptr === 0 || curw > D ) break;
  ans = Math.max( ans, curc );
}
print( ans );

var line = readline().split(' ');
var n = parseInt(line[0]);
var m = parseInt(line[1]);
var d = parseInt(line[2]);

var i, j, k, a, b, c, w;

a = [];

for (i=0; i<n; i++) {
	line = readline().split(' ');
	c = parseInt(line[0]);
	w = parseInt(line[1]);

	a.push({c: c, w: w});
}

b = [];

for (i=0; i<m; i++) {
	line = readline().split(' ');
	c = parseInt(line[0]);
	w = parseInt(line[1]);

	b.push({c: c, w: w});
}

function cmp(u, v) {
	if (u.c != v.c) {
		return -1 * (u.c - v.c);
	}

	return u.w - v.w;
}

a.sort(cmp);
b.sort(cmp);

i = 1;
j = 0;

var sirina = a[0].w;
var zbir = a[0].c;
var sol = 0;

// dodaj
while (j < m && sirina + b[j].w <= d) {
	sirina += b[j].w;
	zbir += b[j].c;
	j += 1;

	if (zbir > sol) {
		sol = zbir;
	}
}

for (i=1; i<n; i++) {
	sirina += a[i].w;
	zbir += a[i].c;

	while (sirina > d && j > 0) {
		j--;
		sirina -= b[j].w;
		zbir -= b[j].c;
	}

	if (zbir > sol && j > 0) {
		sol = zbir;
	}
}

print(sol);

// Polyfill for NodeJS
if (undefined == readline) {
	var rLines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"),
		rIndex = -1,
		readline = function() {
			rIndex++;
			return rLines[rIndex]
		}
}
if (undefined == print) {
	var print = console.log
}

// Useful Read functions
var int = function() {
	return parseInt(readline())
}

var ints = function() {
  var tmp = readline().split(' ');
  var ans = [];
  for(var i=0;i<tmp.length;i++)
    ans[i] = parseInt(tmp[i]);

  return ans;
}

var numbers = ints();
var n = numbers[0];
var m = numbers[1];
var d = numbers[2];

var aw = [];
var ac = [];
var bw = [];
var bc = [];

for(var i=0;i<n;i++)
{
  var nn = ints();
  ac[i] = nn[0];
  aw[i] = nn[1];
}

for(var i=0;i<m;i++)
{
  var nn = ints();
  bc[i] = nn[0];
  bw[i] = nn[1];
}

var a = [];
var b = [];
for(var i=0;i<n;i++) a[i] = i;
for(var i=0;i<m;i++) b[i] = i;

a.sort(function(x,y)
{
 if(ac[x]<ac[y]) return 1;
 if(ac[x]>ac[y]) return -1;

 if(aw[x] > aw[y]) return 1;
 if(aw[x] < aw[y]) return -1;

 return 0;
});

b.sort(function(x,y)
{
 if(bc[x]<bc[y]) return 1;
 if(bc[x]>bc[y]) return -1;

 if(bw[x] > bw[y]) return 1;
 if(bw[x] < bw[y]) return -1;

 return 0;
});

var pa = 0;
var pb = 0;
var sum = aw[a[0]] + bw[b[0]];

if(sum > d)
{
  print("0");
} else {

var totalc = ac[a[0]] + bc[b[0]];

while (pb+1 < m && sum + bw[b[pb+1]]<=d)
{
  pb++;
  sum += bw[b[pb]];
  totalc += bc[b[pb]];
}
var bestc = totalc;

//print(pb);

/*
for(var i=0;i<n;i++) print(aw[a[i]] + " " + ac[a[i]]);
print(" ");
for(var i=0;i<m;i++) print(bw[b[i]] + " " + bc[b[i]]);

print("  ");
print(pa + " " + pb);
print(sum);
*/

while(pb > 0 && pa < n)
{
  pa++;
  sum += aw[a[pa]];
  totalc += ac[a[pa]];

  //print(pa + " " + pb);

  while (pb >= 0 && sum > d)
  {
    sum -= bw[b[pb]];
    totalc -= bc[b[pb]];
    pb--;
  }

  if (sum <= d && bestc < totalc)
    bestc = totalc;
}

print(bestc);
}

var _ = readline().split( ' ' );
var N = +_[ 0 ];
var M = +_[ 1 ];
var D = +_[ 2 ];
var ACW = [];
for( var i = 0; i < N; ++i ) {
  var __ = readline().split( ' ' );
  ACW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
ACW.sort().reverse();
var BCW = [];
for( var i = 0; i < M; ++i ) {
  var __ = readline().split( ' ' );
  BCW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
BCW.sort().reverse();
var curc = 0;
var curw = 0;
var bptr = 0; // [ 0, bptr )
while( bptr < M ) {
  if( curw + BCW[ bptr ][ 1 ] > D ) break;
  curw += BCW[ bptr ][ 1 ];
  curc += BCW[ bptr ][ 0 ];
  ++bptr;
}
var ans = 0;
for( var aptr = 0; aptr < N; ++i ) {
  curw += ACW[ aptr ][ 1 ];
  curc += ACW[ aptr ][ 0 ];
  while( curw > D && bptr > 0 ) {
    --bptr;
    curw -= BCW[ bptr ][ 1 ];
    curc -= BCW[ bptr ][ 0 ];
  }
  if( bptr === 0 || curw > D ) break;
  ans = Math.max( ans, curc );
}
print( ans );

var _ = readline().split( ' ' );
var N = +_[ 0 ];
var M = +_[ 1 ];
var D = +_[ 2 ];
var ACW = [];
for( var i = 0; i < N; ++i ) {
  var __ = readline().split( ' ' );
  ACW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
ACW.sort().reverse();
var BCW = [];
for( var i = 0; i < M; ++i ) {
  var __ = readline().split( ' ' );
  BCW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
BCW.sort().reverse();
var curc = 0;
var curw = 0;
var bptr = 0; // [ 0, bptr )
while( bptr < M ) {
  if( curw + BCW[ bptr ][ 1 ] > D ) break;
  curw += BCW[ bptr ][ 1 ];
  curc += BCW[ bptr ][ 0 ];
  ++bptr;
}
var bok = bptr > 0;
var ans = 0;
for( var aptr = 0; bok && aptr < N; ++i ) {
  curw += ACW[ aptr ][ 1 ];
  curc += ACW[ aptr ][ 0 ];
  while( curw > D && bptr > 0 ) {
    --bptr;
    curw -= BCW[ bptr ][ 1 ];
    curc -= BCW[ bptr ][ 0 ];
  }
  if( curw > D ) break;
  ans = Math.max( ans, curc );
}
print( ans );

var _ = readline().split( ' ' );
var N = +_[ 0 ];
var M = +_[ 1 ];
var D = +_[ 2 ];
var ACW = [];
for( var i = 0; i < N; ++i ) {
  var __ = readline().split( ' ' );
  ACW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
ACW.sort().reverse();
var BCW = [];
for( var i = 0; i < M; ++i ) {
  var __ = readline().split( ' ' );
  BCW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
BCW.sort().reverse();
var curc = 0;
var curw = 0;
var bptr = 0; // [ 0, bptr )
while( bptr < M ) {
  if( curw + BCW[ bptr ][ 1 ] > D ) break;
  curw += BCW[ bptr ][ 1 ];
  curc += BCW[ bptr ][ 0 ];
  ++bptr;
}
var ans = curc;
for( var aptr = 0; aptr < N; ++i ) {
  curw += ACW[ aptr ][ 1 ];
  curc += ACW[ aptr ][ 0 ];
  while( curw > D && bptr > 0 ) {
    --bptr;
    curw -= BCW[ bptr ][ 1 ];
    curc -= BCW[ bptr ][ 0 ];
  }
  if( curw > D ) break;
  ans = Math.max( ans, curc );
}
print( ans );

var line = readline().split(' ');
var n = parseInt(line[0]);
var m = parseInt(line[1]);
var d = parseInt(line[2]);

var i, j, k, a, b, c, w;

a = [];

for (i=0; i<n; i++) {
	line = readline().split(' ');
	c = parseInt(line[0]);
	w = parseInt(line[1]);

	a.push({c: c, w: w});
}

b = [];

for (i=0; i<m; i++) {
	line = readline().split(' ');
	c = parseInt(line[0]);
	w = parseInt(line[1]);

	b.push({c: c, w: w});
}

function cmp(u, v) {
	if (u.c != v.c) {
		return -1 * (u.c - v.c);
	}

	return u.w - v.w;
}

a.sort(cmp);
b.sort(cmp);

i = 1;
j = 0;

var sirina = a[0].w;
var zbir = a[0].c;
var sol = 0;

// dodaj
while (j < m && sirina + b[j].w <= d) {
	sirina += b[j].w;
	zbir += b[j].c;
	j += 1;

	if (zbir > sol) {
		sol = zbir;
	}
}

for (i=2; i<n; i++) {
	sirina += a[i].w;
	zbir += a[i].c;

	while (sirina > d && j > 0) {
		j--;
		sirina -= b[j].w;
		zbir -= b[j].c;
	}

	if (zbir > sol && j > 0) {
		sol = zbir;
	}
}

print(sol);

// Polyfill for NodeJS
if (undefined == readline) {
	var rLines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"),
		rIndex = -1,
		readline = function() {
			rIndex++;
			return rLines[rIndex]
		}
}
if (undefined == print) {
	var print = console.log
}

// Useful Read functions
var int = function() {
	return parseInt(readline())
}

var ints = function() {
  var tmp = readline().split(' ');
  var ans = [];
  for(var i=0;i<tmp.length;i++)
    ans[i] = parseInt(tmp[i]);

  return ans;
}

var numbers = ints();
var n = numbers[0];
var m = numbers[1];
var d = numbers[2];

var aw = [];
var ac = [];
var bw = [];
var bc = [];

for(var i=0;i<n;i++)
{
  var nn = ints();
  ac[i] = nn[0];
  aw[i] = nn[1];
}

for(var i=0;i<m;i++)
{
  var nn = ints();
  bc[i] = nn[0];
  bw[i] = nn[1];
}

var a = [];
var b = [];
for(var i=0;i<n;i++) a[i] = i;
for(var i=0;i<m;i++) b[i] = i;

a.sort(function(x,y)
{
 if(ac[x]<ac[y]) return 1;
 if(ac[x]>ac[y]) return -1;

 if(aw[x] > aw[y]) return 1;
 if(aw[x] < aw[y]) return -1;

 return 0;
});

b.sort(function(x,y)
{
 if(bc[x]<bc[y]) return 1;
 if(bc[x]>bc[y]) return -1;

 if(bw[x] > bw[y]) return 1;
 if(bw[x] < bw[y]) return -1;

 return 0;
});

var pa = 0;
var pb = 0;
var sum = aw[a[0]] + bw[b[0]];

if(sum > d)
{
  print("0");
} else {

var totalc = ac[a[0]] + bc[b[0]];

while (pb+1 < m && sum + bw[b[pb+1]]<=d)
{
  pb++;
  sum += bw[b[pb]];
  totalc += bc[b[pb]];
}
var bestc = totalc;

/*
for(var i=0;i<n;i++) print(aw[a[i]] + " " + ac[a[i]]);
print(" ");
for(var i=0;i<m;i++) print(bw[b[i]] + " " + bc[b[i]]);

print("  ");
print(pa + " " + pb);
print(suma + " " + sumb);
*/

while(pb > 0 && pa < n)
{
  pa++;
  sum += aw[a[pa]];

  while (pb >= 0 && sum > d)
  {
    sum -= bw[b[pb]];
    totalc -= bc[b[pb]];
    pb--;
  }

  if (sum <= d && bestc < totalc)
    bestc = totalc;
}

print(bestc);
}