function sa(n ,moves){
    var positionX = 0;
    var positionY = 0;
    for(var i=0;i<n;i++){
        var move = moves[i].split(' ');
        var val = Number(move[0]);
        if(positionX == 0 && positionY == 0){
            if(move[1] != "South"){
                return "No"
            }
        }
        if(positionX == 0 && positionY == 0){
            if(move[1] != "South"){
                return "No"
            }
        }
        if(positionX == 0 && positionY == -20000){
            if(move[1] != "North"){
                return "No"
            }
        }
        if(move[1] == "South"){
            positionY -= val
        } else if(move[1] == "East"){
            positionX -= val
        }else if(move[1] == "North"){
            positionY += val
        } else if(move[1] == "West"){
            positionX += val
        }
        console.log(positionX , positionY)
    }

    if(positionY == 0){
        return "Yes";
    }

        return "No"
}

var n = Number(readline());
var moves = [];
for(var i=0;i<n;i++){
    moves.push(readline())
}

print(sa(n, moves));


var n = parseInt(readline());
var dirs = [];
for (var i = 0; i <= n; i++) {
  dirs[i] = readline().split(' ');
  dirs[i][0] = parseInt(dirs[i][0]);
}

var yPos = 0;
result = 'YES';
var i = 0;
for (; i < n; i++) {
  var dist = dirs[i][0];
  var dir = dirs[i][1];
  if (yPos === 0 && dir !== 'South') {
    result = 'NO';
    break;
  }
  if (yPos === 20000 && dir !== 'North') {
    result = 'NO';
    break;
  }
  if (dir === 'South') {
    yPos += dist;
  } else if (dir === 'North') {
    yPos -= dist;
  }
}

print(yPos === 0 ? result : 'NO');


var n = parseInt(readline());
var dirs = [];
for (var i = 0; i < n; i++) {
  dirs[i] = readline().split(' ');
  dirs[i][0] = parseInt(dirs[i][0]);
}

var yPos = 0;
result = 'YES';
var i = 0;
for (; i < n; i++) {
  var dist = dirs[i][0];
  var dir = dirs[i][1];
  if (yPos === 0 && dir !== 'South') {
    result = 'NO';
    break;
  }
  if (yPos === 20000 && dir !== 'North') {
    result = 'NO';
    break;
  }
  if (dir === 'South') {
    yPos += dist;
  } else if (dir === 'North') {
    yPos -= dist;
  }
  if (yPos < 0 || yPos > 20000) {
    result = 'NO';
    break;
  }
}

print(yPos === 0 ? result : 'NO');


function sa(n ,moves){
    var positionX = 0;
    var positionY = 0;
    for(var i=0;i<n;i++){
        var move = moves[i].split(' ');
        var val = Number(move[0]);
        if(positionX == 0 && positionY == 0){
            if(move[1] != "South"){
                return "NO"
            }
        }
        if(positionX == 0 && positionY == 0){
            if(move[1] != "South"){
                return "NO"
            }
        }
        if(positionX == 0 && positionY == -20000){
            if(move[1] != "North"){
                return "NO"
            }
        }
        if(move[1] == "South"){
            positionY -= val
        } else if(move[1] == "East"){
            positionX -= val
        }else if(move[1] == "North"){
            positionY += val
        } else if(move[1] == "West"){
            positionX += val
        }
    }

    if(positionY == 0){
        return "YES";
    }

        return "NO"
}

var n = Number(readline());
var moves = [];
for(var i=0;i<n;i++){
    moves.push(readline())
}

print(sa(n, moves));


function sa(n ,moves){
    var positionX = 0;
    var positionY = 0;
    for(var i=0;i<n;i++){
        var move = moves[i].split(' ');
        var val = Number(move[0]);
        if(positionY == 0){
            if(move[1] != "South"){
                return "NO"
            }
        }
        if(positionY == -20000){
            if(move[1] != "North"){
                return "NO"
            }
        }
        if(move[1] == "South"){
            positionY -= val
        } else if(move[1] == "East"){
            positionX -= val
        }else if(move[1] == "North"){
            positionY += val
        } else if(move[1] == "West"){
            positionX += val
        }
    }

    if(positionY == 0){
        return "YES";
    }

        return "NO"
}

var n = Number(readline());
var moves = [];
for(var i=0;i<n;i++){
    moves.push(readline())
}

print(sa(n, moves));


var n = parseInt(readline());
var dirs = [];
for (var i = 0; i < n; i++) {
  dirs[i] = readline().split(' ');
  dirs[i][0] = parseInt(dirs[i][0]);
}

var yPos = 0;
result = 'YES';
var i = 0;
for (; i < n; i++) {
  var dist = dirs[i][0];
  var dir = dirs[i][1];
  if (yPos === 0 && dir !== 'South') {
    result = 'NO';
    break;
  }
  if (yPos === 20000 && dir !== 'North') {
    result = 'NO';
    break;
  }
  if (dir === 'South') {
    yPos += dist;
  } else if (dir === 'North') {
    yPos -= dist;
  }
}

print(yPos === 0 ? result : 'NO');


var currentTime = readline(),
    sleepDuration = readline();
// var currentTime = "13:00";
// var sleepDuration = "02:00";

function solver(currentTime, sleepDuration) {
    var gotUpTime = currentTime.split(':'),
        gotUpHours = Number(gotUpTime[0]),
        gotUpMinutes = Number(gotUpTime[1]);
    var sleepingFor = sleepDuration.split(':'),
        sleepDurHours = Number(sleepingFor[0]),
        sleepDurMinutes = Number(sleepingFor[1]);

    var minutesDiff = gotUpMinutes - sleepDurMinutes;
    var hoursDiff = gotUpHours - sleepDurHours;
    if (minutesDiff < 0) {
        minutesDiff = 60 - Math.abs(minutesDiff);
        hoursDiff--;
    }

    if (hoursDiff < 0) {
        hoursDiff = 24 - Math.abs(hoursDiff);
    }

    return [hoursDiff, minutesDiff];
}

print(solver(currentTime, sleepDuration));
//console.log(solver(currentTime, sleepDuration));


String.prototype.lpad = function(padString, length) {
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
};

var currentTime = readline().split(":");
currentTime[0] = parseInt(currentTime[0]);
currentTime[1] = parseInt(currentTime[1]);
var sleepLength = readline().split(":");
sleepLength[0] = parseInt(sleepLength[0]);
sleepLength[1] = parseInt(sleepLength[1]);

var sleepTimeHours = (currentTime[0] - sleepLength[0]);
var sleepTimeMinutes = (currentTime[1] - sleepLength[1]);

if (sleepTimeHours < 0) sleepTimeHours = 24 + sleepTimeHours;
if (sleepTimeMinutes < 0) sleepTimeMinutes = 60 + sleepTimeMinutes;

var sleepTime = sleepTimeHours.toString().lpad("0", 2) + ":" + sleepTimeMinutes.toString().lpad("0", 2);

print(sleepTime);


String.prototype.lpad = function(padString, length) {
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
};

var currentTime = readline().split(":");
currentTime[0] = parseInt(currentTime[0]);
currentTime[1] = parseInt(currentTime[1]);
var sleepLength = readline().split(":");
sleepLength[0] = parseInt(sleepLength[0]);
sleepLength[1] = parseInt(sleepLength[1]);

var sleepTimeHours = (currentTime[0] - sleepLength[0]);
var sleepTimeMinutes = (currentTime[1] - sleepLength[1]);

if (sleepTimeHours < 0) sleepTimeHours = 24 + sleepTimeHours;
if (sleepTimeMinutes < 0) sleepTimeMinutes = 60 + sleepTimeMinutes;

if (sleepTimeHours == 0 && sleepLength[1] > currentTime[1]) {
  sleepTimeHours = 23;
}

var sleepTime = sleepTimeHours.toString().lpad("0", 2) + ":" + sleepTimeMinutes.toString().lpad("0", 2);

print(sleepTime);


  String.prototype.ceros  = function(cad, tam) {
        var cadF = this;
        while (cadF.length < tam)
            cadF = cad + cadF;
        return cadF;
    };
    /*
     05:50"
     05:44
     */
    //var vec1 = "05:50".split(":");
    var vec1 = readline().split(":");
    vec1[0] = parseInt(vec1[0]);
    vec1[1] = parseInt(vec1[1]);
    var vec2 = readline().split(":");
   // var vec2= "05:44".split(":");
    vec2[0] = parseInt(vec2[0]);
    vec2[1] = parseInt(vec2[1]);

    var tiempoHora = (vec1[0] - vec2[0]);
    var tiempoMin = (vec1[1] - vec2[1]);

    if (vec2[1] > vec1[1])
        tiempoHora--;
    if (tiempoHora < 0)
        tiempoHora = 24 + tiempoHora;
    if (tiempoMin < 0)
        tiempoMin = 60 + tiempoMin;
    print(tiempoHora.toString().ceros("0", 2) + ":" + tiempoMin.toString().ceros("0", 2));
  //  console.log(tiempoHora.toString().ceros("0", 2) + ":" + tiempoMin.toString().ceros("0", 2));


(function() {
    var awake = readline().split(':');
    awake[0] = parseInt(awake[0]);
    awake[1] = parseInt(awake[1]);
    var sleep = readline().split(':');
    sleep[0] = parseInt(sleep[0]);
    sleep[1] = parseInt(sleep[1]);

    awake[1] -= sleep[1];
    if ( awake[1] < 0 ){
        awake[1] += 60;
        --awake[0];
    }
    awake[0] -= sleep[0];
    if ( awake[0] < 0 ){
        awake[0] += 24;
    }
    if ( awake[0] < 10 ){
        awake[0] = "0" + awake[0];
    }
    if ( awake[1] < 10 ){
        awake[1] = "0" + awake[1];
    }
    print(awake[0]+":"+awake[1]);
})();


String.prototype.lpad = function(padString, length) {
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
};

var currentTime = readline().split(":");
currentTime[0] = parseInt(currentTime[0]);
currentTime[1] = parseInt(currentTime[1]);
var sleepLength = readline().split(":");
sleepLength[0] = parseInt(sleepLength[0]);
sleepLength[1] = parseInt(sleepLength[1]);

var sleepTimeHours = (currentTime[0] - sleepLength[0]);
var sleepTimeMinutes = (currentTime[1] - sleepLength[1]);

if (sleepLength[1] > currentTime[1]) {
  sleepTimeHours--;
}

if (sleepTimeHours < 0) sleepTimeHours = 24 + sleepTimeHours;
if (sleepTimeMinutes < 0) sleepTimeMinutes = 60 + sleepTimeMinutes;

var sleepTime = sleepTimeHours.toString().lpad("0", 2) + ":" + sleepTimeMinutes.toString().lpad("0", 2);

print(sleepTime);


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	var List = __webpack_require__(2);
	var _a = List.map(parseInt, readline().split(' ')), n = _a[0], T = _a[1];
	var a = List.map(parseInt, readline().split(' '));
	var x = List.nub(List.sort(a, function (x, y) { return x - y; }));
	var m = x.length;
	var z = List.create(301, 0);
	for (var i = 0; i < x.length; i++) {
	    z[x[i]] = i;
	}
	var dp = List.create2D(m, m, 0);
	function solve(d, s, k) {
	    d[s] = 1;
	    for (var i = k + 1; i < n; i++) {
	        var c = z[a[i]];
	        if (c >= s) {
	            d[c] = List.maximumInRange(d, s, c) + 1;
	        }
	    }
	}
	for (var i = 0; i < n; i++) {
	    var s = z[a[i]];
	    if (dp[s][s] === 0) {
	        solve(dp[s], s, i);
	    }
	}
	function normalize(a) {
	    for (var s = 0; s < m; s++) {
	        for (var e = s + 1; e < m; e++) {
	            a[s][e] = Prelude_1.max(a[s][e], a[s][e - 1]);
	        }
	    }
	}
	normalize(dp);
	function combine(a, b) {
	    var result = List.create2D(m, m, 0);
	    for (var i = 0; i < m; i++) {
	        for (var j = i; j < m; j++) {
	            var x_1 = 0;
	            for (var k = i; k <= j; k++) {
	                x_1 = Prelude_1.max(x_1, a[i][k] + b[k][j]);
	            }
	            result[i][j] = x_1;
	        }
	    }
	    return result;
	}
	function fastCombine(t) {
	    if (t === 1)
	        return dp;
	    var a = fastCombine(Math.floor(t / 2));
	    a = combine(a, a);
	    if (t % 2 === 0) {
	        return a;
	    }
	    else {
	        return combine(a, dp);
	    }
	}
	var r = fastCombine(T);
	print(List.maximumWith(r, function (xs) { return List.maximum(xs); }));

/***/ },
/* 1 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;
	function gcd(a, b) {
	    var r = a % b;
	    while (r !== 0) {
	        a = b;
	        b = r;
	        r = a % b;
	    }
	    return b;
	}
	exports.gcd = gcd;

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function sort(xs, compare) {
	    return copy(xs).sort(compare);
	}
	exports.sort = sort;
	function sortInPlace(xs, compare) {
	    xs.sort(compare);
	    return xs;
	}
	exports.sortInPlace = sortInPlace;
	function maximumInRange(xs, s, e) {
	    var result = xs[s];
	    for (var i = s + 1; i <= e; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximumInRange = maximumInRange;
	function maximum(xs) {
	    return maximumInRange(xs, 0, xs.length - 1);
	}
	exports.maximum = maximum;
	function maximumInRangeWith(xs, s, e, f) {
	    var result = f(xs[s]);
	    for (var i = s + 1; i <= e; i++) {
	        var candidate = f(xs[i]);
	        if (result < candidate)
	            result = candidate;
	    }
	    return result;
	}
	exports.maximumInRangeWith = maximumInRangeWith;
	function maximumWith(xs, f) {
	    return maximumInRangeWith(xs, 0, xs.length - 1, f);
	}
	exports.maximumWith = maximumWith;
	function minimumInRange(xs, s, e) {
	    var result = xs[s];
	    for (var i = s + 1; i <= e; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimumInRange = minimumInRange;
	function minimum(xs) {
	    return minimumInRange(xs, 0, xs.length - 1);
	}
	exports.minimum = minimum;
	function minimumInRangeWith(xs, s, e, f) {
	    var result = f(xs[s]);
	    for (var i = s + 1; i <= e; i++) {
	        var candidate = f(xs[i]);
	        if (result > candidate)
	            result = candidate;
	    }
	    return result;
	}
	exports.minimumInRangeWith = minimumInRangeWith;
	function minimumWith(xs, f) {
	    return minimumInRangeWith(xs, 0, xs.length - 1, f);
	}
	exports.minimumWith = minimumWith;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0)
	        return [];
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function nub(xs) {
	    if (xs.length == 0)
	        return [];
	    var result = [];
	    result.push(xs[0]);
	    for (var i = 1; i < xs.length; i++) {
	        if (xs[i] !== xs[i - 1]) {
	            result.push(xs[i]);
	        }
	    }
	    return result;
	}
	exports.nub = nub;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;
	function create(n, value) {
	    return replicate(n, value);
	}
	exports.create = create;
	function createWith(n, f) {
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = f(i);
	    }
	    return result;
	}
	exports.createWith = createWith;
	function create2D(n1, n2, value) {
	    return map(function (_) { return replicate(n2, value); }, replicate(n1, 0));
	}
	exports.create2D = create2D;
	function create2DWith(n1, n2, f) {
	    var result = new Array(n1);
	    for (var i = 0; i < n1; i++) {
	        result[i] = new Array(n2);
	        for (var j = 0; j < n2; j++) {
	            result[i][j] = f(i, j);
	        }
	    }
	    return result;
	}
	exports.create2DWith = create2DWith;

/***/ }
/******/ ]);


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	var List = __webpack_require__(2);
	var _a = List.map(parseInt, readline().split(' ')), n = _a[0], T = _a[1];
	var a = List.map(parseInt, readline().split(' '));
	var x = List.nub(List.copy(a).sort());
	var m = x.length;
	var z = List.create(301, 0);
	for (var i = 0; i < x.length; i++) {
	    z[x[i]] = i;
	}
	var dp = List.create2D(m, m, 0);
	function solve(d, s, k) {
	    d[s] = 1;
	    for (var i = k + 1; i < n; i++) {
	        var c = z[a[i]];
	        if (c >= s) {
	            d[c] = List.maximumInRange(d, s, c) + 1;
	        }
	    }
	    for (var i = s + 1; i < m; i++) {
	        d[i] = Prelude_1.max(d[i], d[i - 1]);
	    }
	}
	for (var i = 0; i < n; i++) {
	    var s = z[a[i]];
	    if (dp[s][s] === 0) {
	        solve(dp[s], s, i);
	    }
	}
	function combine(a, b) {
	    var result = List.create2D(m, m, 0);
	    for (var i = 0; i < m; i++) {
	        for (var j = i; j < m; j++) {
	            var x_1 = 0;
	            for (var k = i; k <= j; k++) {
	                x_1 = Prelude_1.max(x_1, a[i][k] + b[k][j]);
	            }
	            result[i][j] = x_1;
	        }
	    }
	    return result;
	}
	function fastCombine(t) {
	    if (t == 1)
	        return dp;
	    var a = fastCombine(Math.floor(t / 2));
	    a = combine(a, a);
	    if (t % 2 === 0) {
	        return a;
	    }
	    else {
	        return combine(a, dp);
	    }
	}
	var r = fastCombine(T);
	print(List.maximumWith(r, function (x) { return List.maximum(x); }));

/***/ },
/* 1 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;
	function gcd(a, b) {
	    var r = a % b;
	    while (r !== 0) {
	        a = b;
	        b = r;
	        r = a % b;
	    }
	    return b;
	}
	exports.gcd = gcd;

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function maximumInRange(xs, s, e) {
	    var result = xs[s];
	    for (var i = s + 1; i <= e; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximumInRange = maximumInRange;
	function maximum(xs) {
	    return maximumInRange(xs, 0, xs.length - 1);
	}
	exports.maximum = maximum;
	function maximumInRangeWith(xs, s, e, f) {
	    var result = f(xs[s]);
	    for (var i = s + 1; i <= e; i++) {
	        var candidate = f(xs[i]);
	        if (result < candidate)
	            result = candidate;
	    }
	    return result;
	}
	exports.maximumInRangeWith = maximumInRangeWith;
	function maximumWith(xs, f) {
	    return maximumInRangeWith(xs, 0, xs.length - 1, f);
	}
	exports.maximumWith = maximumWith;
	function minimumInRange(xs, s, e) {
	    var result = xs[s];
	    for (var i = s + 1; i <= e; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimumInRange = minimumInRange;
	function minimum(xs) {
	    return minimumInRange(xs, 0, xs.length - 1);
	}
	exports.minimum = minimum;
	function minimumInRangeWith(xs, s, e, f) {
	    var result = f(xs[s]);
	    for (var i = s + 1; i <= e; i++) {
	        var candidate = f(xs[i]);
	        if (result > candidate)
	            result = candidate;
	    }
	    return result;
	}
	exports.minimumInRangeWith = minimumInRangeWith;
	function minimumWith(xs, f) {
	    return minimumInRangeWith(xs, 0, xs.length - 1, f);
	}
	exports.minimumWith = minimumWith;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0)
	        return [];
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function nub(xs) {
	    if (xs.length == 0)
	        return [];
	    var result = [];
	    result.push(xs[0]);
	    for (var i = 1; i < xs.length; i++) {
	        if (xs[i] !== xs[i - 1]) {
	            result.push(xs[i]);
	        }
	    }
	    return result;
	}
	exports.nub = nub;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;
	function create(n, value) {
	    return replicate(n, value);
	}
	exports.create = create;
	function createWith(n, f) {
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = f(i);
	    }
	    return result;
	}
	exports.createWith = createWith;
	function create2D(n1, n2, value) {
	    return map(function (_) { return replicate(n2, value); }, replicate(n1, 0));
	}
	exports.create2D = create2D;
	function create2DWith(n1, n2, f) {
	    var result = new Array(n1);
	    for (var i = 0; i < n1; i++) {
	        result[i] = new Array(n2);
	        for (var j = 0; j < n2; j++) {
	            result[i][j] = f(i, j);
	        }
	    }
	    return result;
	}
	exports.create2DWith = create2DWith;

/***/ }
/******/ ]);


//var input = readline()
var k = readline()

if(k==2) print(2)
else print(1)


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;

  if (n === 2) {
    console.log(2);
  }
  else {
    console.log(1);
  }
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var N = nextInt();
	if(N <= 2){
		myout(N);
	}else{
		myout(1);
	}
}


// My first java script code :D
if(readline()==2) print(2); else print(1);


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  console.log(1);
});


const a = readline();

if (a > 2) {
    print(a);
} else {
    print(1);
}


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = 1//+lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        output[i] = solve(n)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n) {
    return 2 - n * n
}


print(2 - Math.pow(parseInt(readline()), 2));


const boyCount = Number(readline());
const girlCount = Number(readline());
const participantCount = Number(readline());
var result = 0;
for (var i = 0; i <= participantCount; i++)
  if (i <= boyCount && participantCount - i <= girlCount) result++;
print(result);


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const b = parseInt(lines[0], 10);
  const g = parseInt(lines[1], 10);
  const n = parseInt(lines[2], 10);
  console.log(badges(b, g, n));
});

function badges(b, g, n) {
  const min = Math.min(b, g);
  return min >= n ? 1 + n : 1 + min;
}


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var l = line[1];
    var r = line[2];
    if (n == 0) {
        return print(0);
    }
    if (n == 1) {
        return print(1);
    }
    var length = 1;
    var current = 1;
    for (var i = 1; i < 52; i++) {
         current *= 2;
        if (n <= current) {
            break;
        }

        length = length * 2 + 1;
    }
    var result = [];
    for (var i = 0; i < length; i++) {
        if (i % 2 == 0) {
            result[i] = 1;
        }
    }
    var initL = length;
    while (n > 1) {
        var d = Math.floor(n / 2);
        var m = Math.floor(length / 2);
        result[m] = n % 2;
        n = d;
        length = m;
    }
    var res = 0;
    for (var i = l - 1; i < r; i++) {
        var length = initL;
        if(i%2==0){
            res += 1;
            continue;
        }
        var curI = i;
        while(true){
            var m = Math.floor(length / 2);
            if(m<=1){
                curI -= 1;
            }
            if(curI == m || m<=1){
                res += result[curI];
                break;
            }
            curI = curI%m;
            length = m;
        }
    }
    print(res);
}

main()


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var l = line[1];
    var r = line[2];
    if (n == 0) {
        return print(0);
    }
    if (n == 1) {
        return print(1);
    }
    var length = 1;
    var current = 1;
    for (var i = 1; i < 52; i++) {
        current *= 2;
        if (n < current) {
            break;
        }

        length = length * 2 + 1;
    }
    var res = 0;
    for(var i=l;i<=r;i++){
        if(i%2!=0){
            res++;
            continue;
        }

        var current = i;
        var currentLenth = length;
        var currentN = n;

        while(true){
            var m = Math.floor(currentLenth / 2) + 1;
            var d = Math.floor(currentN / 2);
            if (current == m) {
                res += currentN % 2;
                break;
            } else {
                current = current % m;
                currentLenth = Math.floor(currentLenth / 2);
                currentN = d;
            }
        }
    }
    print(res);
}

main()


var x = 12345;
for(var i = 0; i < 100000000; i += 1) {
  x %= i;
}
print(readline().split(' ').slice(1).map(function(x) { return parseInt(x); }).sort(function(a, b) { return a - b; }).concat(x).slice(0, -1).join(' '));


var x = 12345;
for(var i = 0; i < 10000000; i += 1) {
  x %= i;
}
print(readline().split(' ').slice(1).map(function(x) { return parseInt(x); }).sort(function(a, b) { return a - b; }).concat(x).slice(0, -1).join(' '));


setTimeout(function() { print(readline().split(' ').slice(1).map(function(x) { return parseInt(x); }).sort(function(a, b) { return a - b; }).join(' ')); }, 1000);


print(readline().split(' ').slice(1).map(function(x) { return parseInt(x); }).sort(function(a, b) { return a - b; }).concat(x).slice(0, -1).join(' '));


function exam (restArgs) {
	const a = parseInt(restArgs[0]);
	const b = parseInt(restArgs[1]);
	const c = parseInt(restArgs[2]);
	const n = parseInt(restArgs[3]);
	if (a>=c && b>=c) {
		const total = a+b-c+1;
		if (total <= n) {
			return (n-total+1);
		}
	}
	return -1;
}
print(exam(readline().split(" ")));


var distribution = readline().split(' ').map(Number);
var bdStudents = distribution[0];
var bkStudents = distribution[1];
var both = distribution[2];

var result = distribution[3] - bdStudents - bkStudents + both;
if(both > bdStudents || both > bkStudents || result <= 0) {
    print(-1);
} else {
    print(result);
}


function exam (restArgs) {
	const a = parseInt(restArgs[0]);
	const b = parseInt(restArgs[1]);
	const c = parseInt(restArgs[2]);
	const n = parseInt(restArgs[3]);
	const aux = n-(a+b-c);
	if (a>=c && b>=c && aux>=1) {
		return aux;
	}
	return -1;
}
print(exam(readline().split(" ")));


var nums = readline().split(' ').map(function(x) { return parseInt(x); });
var first = (nums[0] -nums[2])
var second = (nums[1] - nums[2])
var cel = (first + second + nums[2])

print((first < 0 || second < 0) ? -1 : nums[3] > cel ? nums[3] - cel : -1 )


var nums = readline().split(' ').map(function(x) { return parseInt(x); });
var cel =  ((nums[0] -nums[2]) + (nums[1] - nums[2]) + nums[2])
print(nums[3]  > cel ? nums[3] - cel : -1 )


function exam (a,b,c,n) {
	if (a>=c && b>=c) {
		var total = a+b-c+1
		if (total <= n) {
			return (n-total+1)
		}
	}
	return -1
}


var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function sortByLength(a, b) {
    return a.length - b.length;
}

function main() {
    var arrS = [];
    for (var i = 0; i < 4; i++) {
        arrS[i] = next();
    }
    arrS.sort(sortByLength);
    if ((arrS[3].length - 2) >= 2 * (arrS[2].length - 2)) {
        print(arrS[3].charAt(0));
    } else if ((arrS[1].length - 2) >= 2 * (arrS[0].length - 2)) {
        print(arrS[0].charAt(0));
    } else {
        print('C');
    }
}

main();


;(function () {
	print(function () {
		var A = readline().length - 2,
			B = readline().length - 2,
			C = readline().length - 2,
			D = readline().length - 2;

		var t = [];
		if (isIt(A, B, C, D)) t.push('A');
		if (isIt(B, A, C, D)) t.push('B');
		if (isIt(C, B, A, D)) t.push('C');
		if (isIt(D, B, C, A)) t.push('D');

		return t.length === 1 ? t[0] : 'C';

		function isIt (q, w, e, r) {
			if ((q >= w * 2) && (q >= e * 2) && (q >= r * 2)) return true;
			if ((w >= q * 2) && (e >= q * 2) && (r >= q * 2)) return true;
			return false;
		}
	}());
}.call(this));


var inSarr = [];
var minArr = [0, 0, 0, 0];
var maxArr = [0, 0, 0, 0];
for (var i=0; i<4; i++) {
    inSarr[i] = readline();
}

for (i=0; i<4; i++) {
    for (var j=0; j<4; j++) {
        if (i!=j && inSarr[i].length-2 <= (inSarr[j].length-2)/2) {
            minArr[i] += 1;
        }
        if (i!=j && (inSarr[i].length-2)/2 >= inSarr[j].length-2) {
            maxArr[i] += 1;
        }
    }
}
for (i=0; i<4; i++) {
    for (var j=0; j<4; j++) {
        if (i!=j) {
            if (minArr[i] == 3 && maxArr[j] == 3) {
                minArr[i] = 0;
                maxArr[j] = 0;
                break;
            }
        }
    }
}
if (minArr[0] == 3 || maxArr[0] == 3) {
print("A");
}
else if (minArr[1] == 3 || maxArr[1] == 3) {
print("B");
}
else if (minArr[2] == 3 || maxArr[2] == 3) {
print("C");
}
else if (minArr[3] == 3 || maxArr[3] == 3) {
print("D");
}
else {
print("C");
}


var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function sortByLength(a, b) {
    return a.length - b.length;
}

function main() {
    var arrS = [];
    for (var i = 0; i < 4; i++) {
        arrS[i] = next();
    }
    arrS.sort(sortByLength);
    if ((arrS[3].length - 2) >= 2 * (arrS[2].length - 2)&&(arrS[1].length - 2) >= 2 * (arrS[0].length - 2)){
print('C');
}else if((arrS[3].length - 2) >= 2 * (arrS[2].length - 2)) {
        print(arrS[3].charAt(0));
    } else if ((arrS[1].length - 2) >= 2 * (arrS[0].length - 2)) {
        print(arrS[0].charAt(0));
    } else {
        print('C');
    }
}

main();


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var info = [];
	for (var i = 0; i < 4; ++i) {
		var line = trim(readline());
		info.push({ choice: line.charAt(0), length: line.length - 2 });
	}
	info.sort(function (a, b) {
		return a.length - b.length;
	});
	var superShort = info[0].length*2 <= info[1].length,
		superLong = info[3].length >= 2*info[2].length;
	if (superShort ^ superLong) {
		if (superShort) {
			print(info[0].choice);
		} else {
			print(info[3].choice);
		}
	} else {
		print('C');
	}
}

main();


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		sizeA = data[0], sizeB = data[1];
	data = tokenizeIntegers(readline());
	var winA = data[0], multiple = data[1],
		seeds = parseInt(readline());
	var needWinners = winA*multiple - seeds,
		needProblems = 0;
	if (winA*sizeB > sizeA) {
		var rounds = Math.floor(needWinners / winA);
		needProblems = rounds * sizeA;
		needWinners -= rounds * winA;
		needProblems += Math.min(sizeA, needWinners * sizeB);
	} else {
		needProblems = needWinners * sizeB;
	}
	print(needProblems);
}

main();


if (!this.readline) print = console.log, readline = require('./readline');

function readNums() {
	return readline().split(' ').map(Number);
}

print(function(c, d, n, m, k) {
	m -= Math.floor(k / n);
	k %= n;
	return m <= 0 ? 0 : Math.min(m * c, Math.min((n - k) * d + (m - 1) * c, (n - k) * n + (m - 1) * n * n));
}.apply(0, readNums().concat(readNums()).concat(readNums())));


function tokenize(s) {
	return s.split(/\s+/);
}

function tokenize_integers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i++) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}
function nextArray() {
	return tokenize_integers(readline());
}
function nextInt() {
	return parseInt(readline());
	//	return tokenize_integers(readline())[0];
}
function main() {
	var data = nextArray();
	var c = data[0], d = data[1];
	data = nextArray();
	var n = data[0], m = data[1];
	var k = nextInt();
	var needWinners = Math.max(0, n * m - k);
//	print(needWinners);
	var ret = -1;
	for(var x = 0; x <= 10000; x++) {
		var y = needWinners - c * x * n ;
		y /= d;
		y = Math.max(y, 0);
		var tmp = c * x + y * d;
		if(ret == -1 || tmp < ret) {
			ret = tmp;
		}
	}
	print(ret);
}
main();


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		sizeA = data[0], sizeB = data[1];
	data = tokenizeIntegers(readline());
	var winA = data[0], multiple = data[1],
		seeds = parseInt(readline());
	var needWinners = Math.max(0, winA*multiple - seeds),
		needProblems = 0;
	if (winA*sizeB > sizeA) {
		var rounds = Math.floor(needWinners / winA);
		needProblems = rounds * sizeA;
		needWinners -= rounds * winA;
		needProblems += Math.min(sizeA, needWinners * sizeB);
	} else {
		needProblems = needWinners * sizeB;
	}
	print(needProblems);
}

main();


function calc(n, k, tabs) {
  var max = -1;
  var temp, tempE, tempF, abs;

  for (var i = 0; i < k; i++) {
    temp = tabs.filter((elem, index) => index % k !== i);
//     console.log(temp);
    tempE = temp.filter(elem => elem === 1).length;
//     console.log(tempE);
    tempF = temp.filter(elem => elem === -1).length;
//     console.log(tempF);
    abs = Math.abs(tempE - tempF);
    if (abs > max) {
      max = abs;
    }
  }

  return max;
}

var nk = readline().split(" ");
var n = parseInt(nk[0]);
var k = parseInt(nk[1]);
var tabs = readline().split(" ").map(elem => parseInt(elem));

print(calc(n, k, tabs));


var queries = parseInt(readline());
// var queries = 1;

function initialReps(shows, d) {
  var reps = {};

  for (var i = 0; i < d; i++) {
    reps[shows[i] + ''] = reps[shows[i] + ''] + 1 || 1
  }

  return reps;
}

function main(stats, shows) {
  var d = stats[2];
  var reps = initialReps(shows, d);
  var pointerLow = 0;
  var pointerHigh = d-1;
  var minSubs = Object.keys(reps).length;

  while (pointerHigh < shows.length - 1) {
    pointerHigh++;
    reps[shows[pointerHigh] + ''] = reps[shows[pointerHigh] + ''] + 1 || 1
    if (reps[shows[pointerLow] + ''] > 1) {
      reps[shows[pointerLow] + ''] = reps[shows[pointerLow] + ''] - 1
    } else {
      delete reps[shows[pointerLow] + '']
    }
    minSubs = Math.min(minSubs, Object.keys(reps).length)
    pointerLow++;
  }

  return write(minSubs + '\n');
}

for (var i = 0; i < queries; i++) {
  var stats = readline().split(' ').map(function(num) {
    return parseInt(num);
  });
  var shows = readline().split(' ').map(function(num) {
    return parseInt(num);
  });

  // var stats = [1,1,8]
  // var shows = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3]

  main(stats, shows);
}


var queries = parseInt(readline());
// var queries = 1;

function initialReps(shows, d) {
  var reps = {};

  for (var i = 0; i < d; i++) {
    reps[shows[i] + ''] = reps[shows[i] + ''] + 1 || 1
  }

  return reps;
}

function main(stats, shows) {
  var d = stats[2];
  var reps = initialReps(shows, d);
  var pointerLow = 0;
  var pointerHigh = d-1;
  var minSubs = Object.keys(reps).length;

  while (pointerHigh < shows.length - 1) {
    pointerHigh++;
    reps[shows[pointerHigh] + ''] = reps[shows[pointerHigh] + ''] + 1 || 1
    reps[shows[pointerLow] + ''] = reps[shows[pointerLow] + ''] - 1 || undefined
    minSubs = Math.min(minSubs, Object.keys(reps).length)
    pointerLow++;
  }

  return console.log(minSubs);
}

for (var i = 0; i < queries; i++) {
  var stats = readline().split(' ').map(function(num) {
    return parseInt(num);
  });
  var shows = readline().split(' ').map(function(num) {
    return parseInt(num);
  });

  // var stats = [1,1,4]
  // var shows = [10, 8, 6, 4]

  main(stats, shows);
}


var queries = parseInt(readline());
// var queries = 1;

function initialReps(shows, d) {
  var reps = {};

  for (var i = 0; i < d; i++) {
    reps[shows[i] + ''] = reps[shows[i] + ''] + 1 || 1
  }

  return reps;
}

function main(stats, shows) {
  var d = stats[2];
  var reps = initialReps(shows, d);
  var pointerLow = 0;
  var pointerHigh = d-1;
  var minSubs = Object.keys(reps).length;

  while (pointerHigh < shows.length - 1) {
    pointerHigh++;
    reps[shows[pointerHigh] + ''] = reps[shows[pointerHigh] + ''] + 1 || 1
    reps[shows[pointerLow] + ''] = reps[shows[pointerLow] + ''] - 1 || undefined
    minSubs = Math.min(minSubs, Object.keys(reps).length)
    pointerLow++;
  }

  return write(minSubs);
}

for (var i = 0; i < queries; i++) {
  var stats = readline().split(' ').map(function(num) {
    return parseInt(num);
  });
  var shows = readline().split(' ').map(function(num) {
    return parseInt(num);
  });

  // var stats = [1,1,4]
  // var shows = [10, 8, 6, 4]

  main(stats, shows);
}


var queries = parseInt(readline());
// var queries = 1;

function initialReps(shows, d) {
  var reps = {};

  for (var i = 0; i < d; i++) {
    reps[shows[i] + ''] = reps[shows[i] + ''] + 1 || 1
  }

  return reps;
}

function main(stats, shows) {
  var d = stats[2];
  var reps = initialReps(shows, d);
  var pointerLow = 0;
  var pointerHigh = d-1;
  var minSubs = Object.keys(reps).length;

  while (pointerHigh < shows.length - 1) {
    pointerHigh++;
    reps[shows[pointerHigh] + ''] = reps[shows[pointerHigh] + ''] + 1 || 1
    reps[shows[pointerLow] + ''] = reps[shows[pointerLow] + ''] - 1 || undefined
    minSubs = Math.min(minSubs, Object.keys(reps).length)
    pointerLow++;
  }

  return write(minSubs + '\n');
}

for (var i = 0; i < queries; i++) {
  var stats = readline().split(' ').map(function(num) {
    return parseInt(num);
  });
  var shows = readline().split(' ').map(function(num) {
    return parseInt(num);
  });

  // var stats = [1,1,4]
  // var shows = [10, 8, 6, 4]

  main(stats, shows);
}


var tokens = [];
var numTokens = 0;
function next(){
	while(numTokens>=tokens.length){
		tokens = readline().split(/[\s]+/);
		numTokens = 0;
	}
	return tokens[numTokens++];
}
function invertir(n){
	var s = 0,c;
	while(n>0){
		c = Math.floor(n/10);
		s = s*10 + n - c*10;
		n = c;
	}
	return s;
}
function cumple(h,m){
	return invertir(h) == m || h == invertir(m);
}
function solve(h){
	while(h < 24*60 ){
		c = Math.floor(h/60);
		if(cumple(c,h-c*60))
			return h;
		h++;
	}
	return 0;
}
function impri(n){
	if(n<10) return "0"+n;
	return ""+n;
}
function main(){
	var a = next();
	var h = parseInt(a.substring(0,2),10)*60	+ parseInt(a.substring(3,5),10);
	h = solve(h+1);
	var c = Math.floor(h/60);
	var x = c;
	var y = h - c*60;
	print(impri(x)+":"+impri(y));
}
main();


(function main() {
    var n = readline().split(':');
    var h = parseInt(n[0]);
    var m = parseInt(n[1]);
    var dh = ~~(h / 10);
    var oh = h % 10;
    var reh = 10 * oh + dh;
    if (m >= reh) {
        ++h;
        if (h > 23) h = 0;
        dh = ~~(h / 10);
        oh = h % 10;
    }
    if (oh >= 6) {
        oh = 0;
        ++dh;
    }
    print('' + dh + oh + ':' + oh + dh);
})();


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function printValues() {
	var parts = [];
	for (var i = 0; i < arguments.length; i += 2) {
		parts.push(arguments[i]+' = '+arguments[i+1]);
	}
	print(parts.join(', '));
}

function main() {
	var time = trim(readline());
  function getNext(time) {
    var parts = time.split(':'),
        h = parseInt(parts[0], 10), m = parseInt(parts[1], 10);
    m += 1;
    if (m == 60) {
      m = 0;
      h += 1;
      if (h == 24) {
        h = 0;
      }
    }
    var hs = '00'+h, ms = '00'+m;
    hs = hs.substring(hs.length - 2);
    ms = ms.substring(ms.length - 2);
    return hs + ':' + ms;
  }
  function isPalindrome(time) {
    return time.charAt(0) == time.charAt(4) &&
        time.charAt(1) == time.charAt(3);
  }
  while (true) {
    time = getNext(time);
    if (isPalindrome(time)) {
      print(time);
      return;
    }
  }
}

main();


const readline = require('readline');
const r = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });

r.on('line',(line)=>{
     console.log(compute(line));
  });

function* range(start, end) {
    while (start <= end) yield start++;
}

function getTimeIndex(str) {
    let [h,m] = str.split(":").map(n => +n);
    return h * 60 + m;
}
function isPalindrome(str)
{
    return str === (str.split("").reverse().join(""))
}
let hours = [...range(0, 23)].map(n => n < 10 ? "0" + n : "" + n);
let minutes = [...range(0, 59)].map(n => n < 10 ? "0" + n : "" + n);

let time = hours.reduce((ac, h) => {
    minutes.forEach(m => ac.push(h + ":" + m));
    return ac;
}, []);
let times = [...time, ...time];

function compute(str) {
    let startIndex = getTimeIndex(str)+1;
    while( startIndex < times.length)
    {
        if(isPalindrome(times[startIndex]))
            return times[startIndex];

        startIndex++;
    }

}


var tokens = [];
var numTokens = 0;
function next(){
	while(numTokens>=tokens.length){
		tokens = readline().split(/[\s]+/);
		numTokens = 0;
	}
	return tokens[numTokens++];
}
function invertir(n){
	return n.split("").reverse().join("");
}
function impri(n){
	if(n<10) return "0"+n;
	return ""+n;
}

function cumple(h,m){
	if(h<24 && m < 60)
		return invertir(impri(h)) == impri(m);
	return false;
}
function solve(h){
	while(h < 24*60 ){
		c = Math.floor(h/60);
		if(cumple(c,h-c*60))
			return h;
		h++;
	}
	return 0;
}
function main(){
	var a = next();
	var h = parseInt(a.substring(0,2),10)*60	+ parseInt(a.substring(3,5),10);
	h = solve(h+1);
	var c = Math.floor(h/60);
	var x = c;
	var y = h - c*60;
	print(impri(x)+":"+impri(y));
}
main();


var l=readline().split(' ');
var n=+l[0];
var c=+l[1];
var x=readline().split(' ').map(function(v){return +v});
var ans = 0;
for(var i=1; i<n; i++){
	ans = Math.max(ans, x[i-1]-x[i]-c, 0);
}
if(c==0) print(0);
else print(ans);


var l=readline().split(' ');
var n=+l[0];
var c=+l[1];
var x=readline().split(' ').map(function(v){return +v});
var ans = 0;
for(var i=1; i<n; i++){
	ans = Math.max(ans, x[i-1]-x[i]);
}

ans = ans-c;
if(c==0){
	print(0);
}else{
	print( Math.max(ans, 0) );
}


var s=readline();
var l=s.length-3;
if(l<0){
	print(0);
}else{

var n=l*(l+1)/2;

var a=[];
for(var i=0;i<s.length;i++){
	if(s.substring(i,i+4)=='bear'){
		a.push(i);
	}
}

if(a.hasOwnProperty(0)){

for(var i=1;i<a.length;i++){
	l=a[i]-a[i-1]-1;
	n-=l*(l+1)/2;
}

l=a[0];
n-=l*(l+1)/2;
l=s.length-a[a.length-1]-4;
n-=l*(l+1)/2;

print(n)

}else{
	print(n);
}

}


var input = readline().split(' ');
var n = parseInt(input[0]), c=parseInt(input[1]);
var days = readline().split(' ');
for(var i=0; i<n; i++) days[i]=parseInt(days[i]);
var max = 0;
for(var i=0; i<n-1; i++)
{
if(days[i]-days[i+1]-c>max) max = days[i]-days[i+1]-c;
}
print(max);


(function() {
    var nc = readline().split(' ');
    var mx = 0, pr;

    readline().split(' ').forEach(function (x){
        if ( pr !== undefined ) {
            mx = Math.max(mx,pr-x-nc[1]);
        }
        pr = x;
    });

    print(mx);
})();


var input = readline().split(" ").map(Number), n = input[0], c = input[1], x = readline().split(" ").map(Number);
var max = -Infinity;

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

max -= c;

max = Math.max(max, 0);

write(max);


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var numDays = integers[0], borrowCost = integers[1];
	var honeyCosts = tokenizeIntegers(readline());

	var bestProfit = 0;
	for (var i = 0; i < numDays-1; i += 1) {
		if (honeyCosts[i] < honeyCosts[i+1]) {
			continue;
		}
		var profit = honeyCosts[i]-honeyCosts[i+1]-borrowCost;
		if (profit > bestProfit) {
			bestProfit = profit;
		}
	}

	print(bestProfit);
}

main();


var l=readline().split(' ');
var n=+l[0];
var c=+l[1];
var x=readline().split(' ').map(function(v){return +v});
var ans = 0;
for(var i=1; i<n; i++){
	ans = Math.max(ans, x[i-1]-x[i]-c);
}
print(ans);


var input = readline();

print(main(input));

function isCorner(x, y) {
    return ((x === 0 || x === 8) && (y === 0 || y === 8))
}

function onCorner(x, y) {
    return (x === 0 || x === 8 || y === 0 || y === 8);
}

function main(input) {
    var letters = ['a', 'b', 'c', 'd', 'e',  'f', 'g', 'h'];
    var coords = {
        x: +letters.indexOf(input[0]) + 1,
        y: +input[1]
    };
    if (isCorner(coords.x, coords.y)) return 3;
    if (onCorner(coords.x, coords.y)) return 5;
    return 8;
}


var input = readline();
var ans = Number(8);
if (input[0] == 'a' || input[0] == 'h') {
	ans--;
}
if (input[1] == '1' || input[0] == '8') {
	ans--;
}
print(ans);


var g = readline().split("");
var c = g[0];
var d = g[1];
var count = 8;
if(c=="a" || c=="h"){
    count = count - 3;
}
if(d=="1" || d=="8"){
    count = count - 3;
}
print(count);


function main(pos) {
  var one = pos[0];
  var two = pos[1];
	if(~['a', 'h'].indexOf(one) && ~['1', '8'].indexOf(two)) {
    return 3;
  }

  if(~['a', 'h'].indexOf(one) || ~['1', '8'].indexOf(two)) {
    return 5;
  }

  return 8;
}
var input = readline();
print(main(input));


var input = readline();
var ans = Number(8);
var value = Number(3);
if (input[0] == 'a' || input[0] == 'h') {
	ans -= 3;
	value = 2;
}
if (input[1] == '1' || input[1] == '8') {
	ans -= value;
}
print(ans);


var inp = readline();
if ('a1a8h1h8'.includes(inp)) {
    print(3)
} else if ('ah'.includes(inp[0]) || '18'.includes(inp[1])) {
    print(5)
} else {
    print(8)
}


var input = readline();

print(main(input));

function isCorner(x, y) {
    return ((x === 1 || x === 8) && (y === 1 || y === 8))
}

function onCorner(x, y) {
    return (x === 1 || x === 8 || y === 1 || y === 8);
}

function main(input) {
    var letters = ['a', 'b', 'c', 'd', 'e',  'f', 'g', 'h'];
    var coords = {
        x: +letters.indexOf(input[0]) + 1,
        y: +input[1]
    };
    if (isCorner(coords.x, coords.y)) return 3;
    if (onCorner(coords.x, coords.y)) return 5;
    return 8;
}


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const [l, n] = d;
  let ans = 8;

  if (l === 'a' || l === 'h' || n === '8' || n === '1') {
    ans = 5;
  }

  if (d === 'a1' || d === 'a8' || d === 'h1' || d === 'h8') {
    ans = 3;
  }

  console.log(ans);
});


process.stdin.resume();
process.stdin.setEncoding('ascii');

var input = '';

process.stdin.on('data', function (data) {
	input += data;
});

process.stdin.on('end', function () {
	//input = input.split("\n");
	processData();
});

function processData() {
	var ans = 8;
	if (input[0] == 'a' || input[0] == 'h') {
		ans--;
	}
	if (input[1] == '1' || input[0] == '8') {
		ans--;
	}
	process.stdout.write(ans);
}


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const [n, k] = d.split(' ').map(BigInt);
  const ans = n / k;

  if (ans % 2n === 0n) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

});


var r = readline().split(' ').map((xs)=>Array.from(xs).map(Number));
var multonlist1 = function (xs,y){
  var t=0;
  var res=[];
  for (var i=xs.length-1;i>=0;i--){
    res.unshift((xs[i]*y+t)%10);
    t=Math.floor((xs[i]*y+t)/10);}
  if (t!==0) {res.unshift(t);}
  return res;
};
var multonlist2 = (xs,ys)=>ys.reverse().map((y,i)=>{var a =multonlist1(xs,y); while (i>0) {a.push(0);i--;} return a;});
var divonlist1 = (xs,ys)=>{for (var i=0;i<=9;i++){t =multonlist1(ys,i); if (t==xs) {i++;break;} else if (t>xs && t.length==xs.length||t.length>xs.length) {break} } return i-1;};
var divonlist2 = (xs,ys)=>{
  var xs1 = xs.slice(0,ys.length);
  var xs2 = xs.slice(ys.length);
  var t=divonlist1(xs1,ys);
  var rs=[];
  if (t!==0) {rs=[t];}
  var fun = function (as) {while (as[0]===0) {as.shift();} return as};
  var zs=fun(subonlist1(xs1,multonlist1(ys,t)));
  var t3=xs2.length;
  while (t3!==0) {
    zs.push(xs2[0]);
    xs2.shift();
    t=divonlist1(zs,ys);
    rs.push(t);
    zs=fun(subonlist1(zs,multonlist1(ys,t)));
    t3--;}
  return rs;
};
var subonlist1 = function (xs,ys){
  var t=0;
  var res=[];
  while (ys.length<xs.length) {ys.unshift(0);}
  for (var i=xs.length-1;i>=0;i--){
      var t2 = xs[i]-ys[i]-t;
      if (t2>=0) {t=0; res.unshift(t2);}
      else {t=1;res.unshift(t2+10);}
  }
  while (res[0]===0) {res.shift();}
  return res;};
print( (()=>{var a = divonlist2 (r[0],r[1]); if (a[a.length-1]%2!==0) {return "YES"} else {return "NO"}})());


var line = readline().split(' ').map(Number);
var end = (function () {if (line[0]/(2*line[1])<1) {
  return "YES";
} else {
  return "NO";
}
})();
print (end);


var line = readline().split(' ').map(Number);

var t= ((x,y)=>Math.max(x.toString().length-y.toString().length-1,0)).apply(null,line);
var end = (function () {if (parseInt(line[0]/((Math.pow(10,t))*line[1]))%2==1) {
  return "YES";
} else {
  return "NO";
}
})();
print (end);


var line = readline().split(' ').map(Number);

var end = (function () {if (parseInt(line[0]/(line[1]))%2==1) {
  return "YES";
} else {
  return "NO";
}
})();
print (end);


var line = readline().split(' ').map(Number);

var t= ((x,y)=>Math.max(x.toString().length-y.toString().length-2,0)).apply(null,line);
var end = (function () {if (parseInt(line[0]/((Math.pow(10,t))*line[1]))%2==1) {
  return "YES";
} else {
  return "NO";
}
})();
print (end);


'use strict'

let lll
lll = readline().split(' ').map(v => parseInt(v))
let n = lll[0]
let x1 = lll[1]
let y1 = lll[2]
let x2 = lll[3]
let y2 = lll[4]

let s = 0

let by
if (x1 == 0) {
  by = y1
} else if (y1 == 0) {
  by = n - x1
} else if (x1 == n) {
  by = n - y1
} else {
  by = x1
}

let ag
if (x2 == 0) {
  ag = n - y2
} else if (y2 == 0) {
  ag = x2
} else if (x2 == n) {
  ag = y2
} else {
  ag = n - x1
}

if (x1 == 0 && x2 == n || y1 == 0 && y2 == n) {
  s = by + ag + n
  s = Math.min(s, 4 * n - s)
} else {
  s = by + ag
  s = Math.min(s, 2 * n - s)
}

print(s)


'use strict'

let lll
lll = readline().split(' ').map(v => parseInt(v))
let n = lll[0]
let x1 = lll[1]
let y1 = lll[2]
let x2 = lll[3]
let y2 = lll[4]

let s = x1 + x2 + y1 + y2
print(Math.min(s, 4 * n - s))


var getNums = function() {
	return readline().split(' ').map(function(a) {return parseInt(a)});
};

var d = getNums();

var n = d[0];
var x1 = d[1];
var y1 = d[2];
var x2 = d[3];
var y2 = d[4];

function getZ(x, y, n) {
	if (y === 0) {
		z = x;
	} else if(x === n) {
		z = n + y;
	} else if (y == n) {
		z = 2 * n + (n - x);
	} else {
		z = 3 * n + (n - y);
	}
	return z;
}

var z1 = getZ(x1, y1, n);
var z2 = getZ(x2, y2, n);

var s1 = Math.abs(z1 - z2);
var s2 = Math.min(z1, z2) + 4 * n - Math.max(z1, z2);

print(Math.min(s1, s2));


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var D = one[1];
  var list = next();
  var dp = new Array(N).fill(-1);
  dp[0] = 0;
  for(var i = 0; i < N; i++){
    if(list[i] == "1"){
      for(var j = 1; j <= D; j++){
        if(list[i + j] == "1"){
          if(dp[i + j] == -1){
            dp[i + j] = dp[i] + 1;
          }else{
            dp[i + j] = Math.min(dp[i] + 1, dp[i + j]);
          }
        }
      }
    }
  }
  myout(dp[N - 1]);
}


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var D = one[1];
  var list = next();
  var dp = new Array(N).fill(-1);
  dp[0] = 0;
  for(var i = 0; i < N; i++){
    if(list[i] == "1" && dp[i] != -1){
      for(var j = 1; j <= D; j++){
        if(list[i + j] == "1"){
          if(dp[i + j] == -1){
            dp[i + j] = dp[i] + 1;
          }else{
            dp[i + j] = Math.min(dp[i] + 1, dp[i + j]);
          }
        }
      }
    }
  }
  myout(dp[N - 1]);
}


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}
function ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0));
        }
        if(ac.length!=0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}
function ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1,fnz=-1;
    for(let i=1;i<s.length;++i)
    {
        if(s[i]!='0')
        {
            fnz=i-1;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0)+(fi===0?fnz:0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0)+(Math.min(fi,tw)===0?fnz:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0)+(Math.min(fi,se)===0?fnz:0));
        }
        if(ac.length!==0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}
function ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1,fnz=-1;
    for(let i=1;i<s.length;++i)
    {
        if(s[i]!='0')
        {
            fnz=i-1;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0)+(fi===0?(zer[0]==1?0:fnz):0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0)+(Math.min(fi,tw)===0?fnz:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0)+(Math.min(fi,se)===0?fnz:0));
        }
        if(ac.length!==0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}


'use strict';

// let inpFileStrArr = `
// 2 1
// 2 1
// 10
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort();
var m = Number(readline());

print(arr.slice(0, 2).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));


'use strict';

// let inpFileStrArr = `
// 3 96
// 83 22 17
// 19
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort();
var m = Number(readline());

print(arr.slice(0, m).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));


print(function(n, d) {

	var a = readline().split(' ').map(Number).sort(function(a, b) { return a - b; }),
		m = +readline(),
		ans = 0;

	for (var i = 0; i < m; i++)
		ans += i < n ? a[i] : -d;

	return ans;

}.apply(0, readline().split(' ').map(Number)));


'use strict';

// let inpFileStrArr = `
// 90 24
// 41 65 43 20 14 92 5 19 33 51 6 76 40 4 23 99 48 85 49 72 65 14 76 46 13 47 79 70 63 20 86 90 45 66 41 46 9 19 71 2 24 33 73 53 88 71 64 2 4 24 28 1 70 16 66 29 44 48 89 44 38 10 64 50 82 89 43 9 61 22 59 55 89 47 91 50 44 31 21 49 68 37 84 36 27 86 39 54 30 25
// 49
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort(function (a, b) {
  return a - b;
});
var m = Number(readline());

print(arr.slice(0, m).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));


(function (){
    var line = readline().split(' ');
    var n = parseInt(line[0]);
    var d = parseInt(line[1]);
    var a = readline().split(' ');
    var m = parseInt(readline());
    a.sort(function(a,b){
        return parseInt(a)-parseInt(b);
    });
    var profit = 0, i;
    for( i = 0 ; i < m && i < n ; ++i){
        profit += parseInt(a[i]);
    }
    if ( i < m ){
        profit -= (m-i) * d;
    }
    print(profit);
})();


var inp = readline().split(' ');
var n = Number(inp[0]);
var d = Number(inp[1]);
var A = readline().split(' ').map((x)=>Number(x));
var m = Number(readline().split());
A.sort((x,y) => x-y);

var ats = 0;
if(m > n)
{
ats = -(m-n)*d;
m=n;
}

for(var i=0; i<m; i++)
ats+=A[i];

print(ats);


'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var inpFileStrArr = '\n3 96\n83 22 17\n19\n'.trim().split('\n'),
    inpFileCounter = 0;
function readline() {
  return inpFileStrArr[inpFileCounter++];
}
function print(x) {
  console.log(x);
}

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort();
var m = Number(readline());

print(arr.slice(0, m).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));


var xy = readline();
xy = xy.split(" ");
var x = parseInt(xy[0]);
var y = parseInt(xy[1]);
if((y == 0 && x == 0) || (y == 0 && x == 1))
{
    print("0");
}
else if((Math.abs(x) < Math.abs(y) && y > 0) || -x == y)
{
    print(Math.abs(y*4) - 2);
}
else if((Math.abs(x) > Math.abs(y) && x < 0) || (x == y && x < 0))
{
    print(Math.abs(x*4) - 1);
}
else if((Math.abs(x) <= Math.abs(y) && y < 0) || x == -y + 1)
{
    print(Math.abs(y*4));
}
else if((Math.abs(x) > Math.abs(y)-2 && x > 0) || (x == y && x > 0))
{
    print(Math.abs(y*4) + 1);
}


var xy = readline();
xy = xy.split(" ");
var x = parseInt(xy[0]);
var y = parseInt(xy[1]);
if((y == 0 && x == 0) || (y == 0 && x == 1))
{
    print("0");
}
else if((Math.abs(x) < Math.abs(y) && y > 0) || (-x == y && y > 0))
{
    print(Math.abs(y*4) - 2);
}
else if((Math.abs(x) > Math.abs(y) && x < 0) || (x == y && x < 0))
{
    print(Math.abs(x*4) - 1);
}
else if((Math.abs(x) < Math.abs(y) && y < 0) || (-x == y && y < 0) || x == -y + 1)
{
    print(Math.abs(y*4));
}
else if((Math.abs(x) > Math.abs(y) && x > 0) || (x == y && x > 0))
{
    print(Math.abs((x-1)*4) + 1);
}


process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', cin, cout;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    cout = function(data) {process.stdout.write(data+'\n')};
    var inputLineIndex = 0;
    cin = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});

function main() {
    [n, m, k] = cin().split(' ');
    let res = 0;
    for (let i = 0;  i < k; i++) {
        res += 2*(+n + +m - 8*(+i)) - 4;
    }
    cout(res);
    return 0;
}


const readline = require('readline').createInterface({
    input: process.stdin
});

readline.on('line', line => {
    const [w, h, k] = line.split(' ').map(x => parseInt(x));
    let result = 0;
    for (let i = 1; i <= k; i++)
        result += 2*(w - 4*(i - 1) + h - 4*(i - 1) - 2);
    console.log(result);
});


var line = readline().split(' ');
var x = line[0];
var y = line[1];
var k = line[2];
var count = 0;
for(i=0; i<k; i++) {
	count = count + x*2;
	count = count + ((y -2) * 2);
	x = x - 4;
	y = y - 4;
}
print(count);


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
	var W = one[0];
	var H = one[1];
	var K = one[2];
	var output = 0;
	for(var i = 0; i < K; i++){
		output += 2 * (W - 4 * i) + 2 * (H - 2 - 4 * i);
	}
	myout(output);
}


var fl = readline().split(' ').map(v=>+v);
var start = fl[0] * 2 + fl[1] * 2 - 4;
var sum = start;

for(var i = 1, minus = 16; i < fl[2]; i++, minus+=16) sum += start - minus;
print(sum);


var input = readline().split(' ');

var w = Number(input[0]);
var h = Number(input[1]);
var k = Number(input[2]);
var count = 0;

print(w,h,k);

while(k > 0) {
  count += (w*h)-((w-2)*(h-2));
  k--;
  w = w-2;
  h = h-2;
}

print(count);


var input = readline().split(' ');

var w = Number(input[0]);
var h = Number(input[1]);
var k = Number(input[2]);
var count = 0;

while(k > 0) {
  count += (w*h)-((w-2)*(h-2));
  k--;
  w = w-2;
  h = h-2;
}

print(count);


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const n = +ipt.split(EOL)[0]

  console.log(n / 2 * 3)
})


;(function () {

	print( +readline() * 1.5 );

}).call(this)


function main() {
    const n = +stdin[0];
    console.log(n * 3 / 2);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});

var stdin = [];

rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);


function main() {
    const n = +stdin[0];
    var a = [];
    for (var z = 0; z < 20; z++) {
        a[z] = []
        for (var i = 0; i < 500000; i++) {
            a[z][i] = i * z;
        }
    }
    var s = 0;
    for (var z = 0; z < 20; z++) {
        for (var i = 0; i < 500000; i++) {
            s += a[z][i];
        }
    }
    console.log(n * 3 / 2);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});

var stdin = [];

rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (+d === 2) {
    console.log(3);
  }
  else {
    console.log(6);
  }

  c++;
});


var bessi = readline()
.split('')
.concat(readline().split('').reverse())
.filter(function (v) {
    return v !== 'X'
})

var elsi = readline()
.split('')
.concat(readline().split('').reverse())
.filter(function (v) {
    return v !== 'X'
})

var friends = true

var b = bessi.indexOf('A')
var e = elsi.indexOf('A')

for (var i = 0 ; i < 3; i++) {
    if (bessi[b] !== elsi[e]) {
        friends = false
        break
    }

    b = ++b % 3
    e = ++e % 3

}

print(friends ? "YES" : "NO")


var pazzle1 = []
  , pazzle2 = []
  , test    = ''
  , sample  = '';

for(var i = 0; i < 2; i++){
    pazzle1[i] = readline().split('');
}

sample += readline().replace('X', '');
sample += readline().split('').reverse().join('').replace('X', '');

//clockwise
test = pazzle1[0][0] + pazzle1[0][1] + pazzle1[1][1] + pazzle1[1][0];
if (sample == test.replace('X', '')) {
    print('YES');
    quit();
}
test = pazzle1[0][1] + pazzle1[1][1] + pazzle1[1][0] + pazzle1[0][0];
if (sample == test.replace('X', '')) {
    print('YES');
    quit();
}
test = pazzle1[1][1] + pazzle1[1][0] + pazzle1[0][0] + pazzle1[0][1];
if (sample == test.replace('X', '')) {
    print('YES');
    quit();
}
test = pazzle1[1][0] + pazzle1[0][0] + pazzle1[0][1] + pazzle1[1][1];
if (sample == test.replace('X', '')) {
    print('YES');
    quit();
}

print( 'NO' );


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (input) => {
    let n = parseInt(input);
    for (let i = 1; i * i <= n; i++){
        let eq = ((n - 1) - i - (i * i)) / (2 * i);
        if (eq === parseInt(eq)){
            console.log(i + " " + eq);
            process.exit(0);
        }
    }
    console.log("NO");
    rl.close();
});


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (input) => {
    let n = parseInt(input);
    for (let i = 1; i * i <= n; i++){
        let eq = ((n - 1) - i - (i * i)) / (2 * i);
        if (eq === parseInt(eq) || eq > 0){
            console.log(i + " " + eq);
            process.exit(0);
        }
    }
    console.log("NO");
    rl.close();
});


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (input) => {
    let n = parseInt(input);
    for (let i = 1; i * i <= n; i++){
        let eq = ((n - 1) - i - (i * i)) / (2 * i);
        if (eq === parseInt(eq) || eq < 0){
            console.log(i + " " + eq);
            process.exit(0);
        }
    }
    console.log("NO");
    rl.close();
});


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (input) => {
    let n = parseInt(input);
    for (let i = 1; i * i <= n; i++){
        let eq = ((n - 1) - i - (i * i)) / (2 * i);
        if (eq === parseInt(eq) && eq > 0){
            console.log(i + " " + eq);
            process.exit(0);
        }
    }
    console.log("NO");
    rl.close();
});


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = 1//+lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        output[i] = solve(str)
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    const base = 'A'.charCodeAt(0)
    for (let i = 2; i < str.length; i++) {
        const a = str.charCodeAt(i - 2) - base
        const b = str.charCodeAt(i - 1) - base
        const c = str.charCodeAt(i) - base
        if (((a + b) % 26) !== c) return 'NO'
    }
    return 'YES'
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

let inputString = ''
let inputArray = null
let currentLine = 0

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin
})

process.stdin.on('end', (_) => {
  inputArray = inputString
    .trim()
    .split('\n')
    .map((s) => s.trim())

  main()
})

function readline() {
  return inputArray[currentLine++]
}

function main() {
  const s = readline()
  for (let i = 2; i < s.length; i++) {
    if (
      (s.charCodeAt(i - 2) -
        'A'.charCodeAt() +
        s.charCodeAt(i - 1) -
        'A'.charCodeAt()) %
        26 !==
      s.charCodeAt(i) - 'A'.charCodeAt()
    ) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

process.stdin.on('data', (/** @type {string} */ s) => {
  for (let i = 3; i < s.length; i++) {
    if (
      s.charCodeAt(i - 2) -
        'A'.charCodeAt() +
        s.charCodeAt(i - 1) -
        'A'.charCodeAt() !==
      s.charCodeAt(i)
    ) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
})


process.stdin.resume()
process.stdin.setEncoding('utf-8')

let inputString = ''
let inputArray = null
let currentLine = 0

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin
})

process.stdin.on('end', (_) => {
  inputArray = inputString
    .trim()
    .split('\n')
    .map((s) => s.trim())

  main()
})

function readline() {
  return inputArray[currentLine++]
}

function main() {
  const s = readline()
  for (let i = 2; i < s.length; i++) {
    if (
      s.charCodeAt(i - 2) -
        'A'.charCodeAt() +
        s.charCodeAt(i - 1) -
        'A'.charCodeAt() !==
      s.charCodeAt(i) - 'A'.charCodeAt()
    ) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
}


const r = Number(readline());
search: for (var aHalf = 0.5; aHalf <= 5; aHalf += 0.5)
  for (var h = 1; h <= 10; h++)
    if (Math.abs(aHalf * h / Math.hypot(aHalf, h) - r) <= 0.000001) {
      print(`${aHalf * 2} ${h}`);
      break search;
    }


var as = parseFloat(readline());
function out(a, b){write(a, b, '\n');}
function equ(a, b)
{
	if(Math.abs(a - b) < 1e-5) return true;
	return false;
}
function solve(callback)
{
	var i, j;
	for(i = 1; i <= 10; ++i)
		for(j = 1; j <= 10; ++j)
			if(equ(as, (i * j / 2) / Math.sqrt((i * i) / 4 + j * j)))
			{
				callback(i, j);
				return;
			}
	return;
}
solve(out);


var a ,h ,x;
x = readline();
var flag = 0;
for(var i = 1; i <=10 ; i++)
{
    for(var j = 1; j <= 10 ;j++)
    {
        a = i ;
        h = j;
        a /= 2.0;
        if(Math.abs(a*h/Math.sqrt(a*a+h*h)-x)<0.000001)
        {
            print(i+' '+j);
            flag = 1;
            break;
        }
    }
    if(flag === 1)
        break;
}


print(function(x) {
	for (var i = 1; i <= 10; i++) {
		var a = i / 2;
		for (var b = 1; b <= 10; b++) {
			if (Math.abs(Math.sqrt(a * a + b * b) * x - a * b) < 0.001) {
				return i + ' ' + b;
			}
		}
	}
}(+readline()));


var n = readline();
var a = readline();
var b = readline();
var c = readline();

if ( n <= 1 ) print(0);
else if ( n === 2 ) print(Math.min(a,b));
else print(Math.min(a,b) + Math.min(a, Math.min(b,c)) * (n-2))


var n = readline();
var a = readline();
var b = readline();
var c = readline();

if ( n === 0 ) print(0);
else if ( n === 1 ) print(b);
else if ( n === 2 ) print(b + Math.min(b,c));
else print(b + Math.min(b,c) + Math.min(a, Math.min(b,c)) * (n-2))


var n=readline();
//print(n);
var str=readline();
//print(str);
var cnt=0,mn=0;
for(var i=0;i<n;i++)
{
	if(str[i]=='-')
	{
		cnt--;
	}
	else
	{
		cnt++;
	}
	if(cnt<mn)
	{
		mn=cnt;
	}
}
mn=-mn;
//print(mn);
for(var i=0;i<n;i++)
{
	if(str[i]=='-')
	{
		mn--;
	}
	else
	{
		mn++;
	}

}
print(mn);


(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var s = readline();

    var res = 0;
    for(var i = 0; i < n; i++) {
        if(s[i] === '-'){
           res--;
        }
        else {
           res++;
        }

        if(res < 0) {
            res = 0;
        }
    }
    print(res);
}());


const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let ans = 0;

  for (let i = 0; i < str.length; i++) {
    if (str[i] === "+") {
      ans++;
    } else {
      ans = Math.max(0, --ans);
    }
  }

  console.log(ans);
  c++;
});


var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
var STATE = 1;
var n;
rl.on('line', function (input) {
  switch (STATE) {
    case 1:
      n = parseInt(input, 10);
      // console.log(STATE + ':', n);
      STATE = 2;
      break;
    case 2:
      // console.log(STATE + ':', input);
      var init = 0;
      var added = 0;
      for (var i = 0, len = input.length; i < len; i++) {
        var char = input[i];
        switch (char) {
          case '+':
            added++;
            break;
          case '-':
            if (added) {
              added--;
            } else {
              init++;
            }
            break;
          default:
            throw new Error('Error case');
        }
      }
      // console.log(init, added);
      console.log(added);
      STATE = 1;
      break;
    default:
      // code
  }
}).on('close', function() {
  process.exit(0);
});