process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, -1);
        let [w, h, u1, d1, u2, d2] = input.map(value => parseInt(value));
        for (; h >= 0; h--) {
            w += h;
            if (h == d1) w -= u1;
            if (h == d2) w -= u2;
            w = Math.max(w, 0);
        }
        console.log(w);
        process.exit();
    }
});

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

let l = 0;
let w = []
let h = []

rl.on('line', (input) => {
    if (l === 0) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else if (l === 1) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let wg = w[0]
        let hg = h[0]
        w.push(inp[0])
        h.push(inp[1])
        if (h[1] < h[2]) {
            let aux = h[1]
            h[1] = h[2]
            h[2] = aux
            aux = w[1]
            w[1] = w[2]
            w[2] = aux
        }
        for (let i = h[0]; i >= h[1]; i--) {
            wg += i
            hg--
        }

        wg -= w[1]
        if (wg < 0)
            wg = 0
        if (hg <= 0) {
            console.log(wg)
            return
        }
        for (let i = h[1] - 1; i >= h[2]; i--) {
            wg += i
            hg--
        }
        wg -= w[2]
        if (wg < 0)
            wg = 0
        for (let i = hg; i >= 0; i--) {
            wg += i;
        }
        console.log(wg)
    }
    l++
});

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let input = [];
rl.on('line', (inputString) => {
    let [x, y] = inputString.split(' ').map(v => parseInt(v));
    input = input.concat([x, y]);
    if (input.length == 6) {
        let [w, h, u1, d1, u2, d2] = input;
        for (; h >= 0; h--) {
            w += h;
            if (h == d1) w -= u1;
            if (h == d2) w -= u2;
            if (w < 0) w = 0;
        }
        console.log(w);
        process.exit();
    }
});

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, 6);
        console.log(snowball.apply(null, input.map(value => parseInt(value))));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = Math.max(w - u1, 0);
        if (h == d2) w = Math.max(w - u2, 0);
    }
    return w;
}

var ar1=readline().split(" ");
var ar2=readline().split(" ");
var ar3=readline().split(" ");
var w=parseInt(ar1[0]),h=parseInt(ar1[1]);
var w1=parseInt(ar2[0]),h1=parseInt(ar2[1]);
var w2=parseInt(ar3[0]),h2=parseInt(ar3[1]);
while(h!==0){
	w+=h;
	if(h===h1){w-=w1;}
	else if(h===h2){w-=w2;}
	h--;
	if(w<0){w=0;}
	if(h===0){
		if(h===h1){w-=w1;}
	else if(h===h2){w-=w2;}
	}
}print(w);

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, -1);
        let myinput = input.map(value => parseInt(value));
        console.log(snowball.apply(null, myinput));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w -= u1;
        if (h == d2) w -= u2;
        if (w < 0) w = 0;
    }
    return w;
}

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let input = [];
rl.on('line', (inputString) => {
    let [x, y] = inputString.split(' ').map(v => parseInt(v));
    input = input.concat([x, y]);
    if (input.length == 6) {
        let [w, h, u1, d1, u2, d2] = input;
        for (; h >= 0; h--) {
            w += h;
            if (h == d1) w -= u1;
            if (h == d2) w -= u2;
            w = Math.max(w, 0);
        }
        console.log(w);
        process.exit();
    }
});

process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        let input = chunk.split(re).slice(0, -1);
        console.log(snowball.apply(null, input.map(value => parseInt(value))));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = Math.max(w - u1, 0);
        if (h == d2) w = Math.max(w - u2, 0);
    }
    return w;
}

process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        let input = chunk.split(re).slice(0, -1);
        console.log(snowball.apply(null, input.map(value => parseInt(value))));
        process.exit(0);
    }
});

function snowball(w, h, u1, d1, u2, d2) {
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w -= u1;
        if (h == d2) w -= u2;
        w = Math.max(w, 0);
    }
    return w;
}

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
rl.on('line', (inputString) => {
    let [x, y] = inputString.split(' ').map(v => parseInt(v));
    if (!rl.on.input) rl.on.input = [];
    rl.on.input = rl.on.input.concat([x, y]);
    if (rl.on.input.length == 6) {
        sb.apply(null, rl.on.input);
        process.exit();
    }
});

function sb(w, h, u1, d1, u2, d2) {
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w -= u1;
        if (h == d2) w -= u2;
        w = Math.max(0, w);
    }
    console.log(w);
}

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, -1);
        let myinput = input.map(value => parseInt(value));
        console.log(snowball.apply(null, myinput));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = (w - u1) > 0 ? (w - u1) : 0;
        if (h == d2) w = (w - u2) > 0 ? (w - u2) : 0;
    }
    return w;
}

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let input = [];
rl.on('line', (inputString) => {
    input = input.concat(inputString.split(' '));
    if (input.length == 6) {
        let [w, h, u1, d1, u2, d2] = input.map(v => parseInt(v));
        for (; h >= 0; h--) {
            w += h;
            if (h == d1) w -= u1;
            if (h == d2) w -= u2;
            w = Math.max(w, 0);
        }
        console.log(w);
        process.exit();
    }
});

const readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function doIt(lines) {
    const snowBall = lines[0].split(" ").map(x => parseInt(x));
    const stoneOne = lines[1].split(" ").map(x => parseInt(x));
    const stoneTwo = lines[2].split(" ").map(x => parseInt(x));

    let snowW = snowBall[0];
    let snowH = snowBall[1];

    for (let i = snowH; i>=0; i--) {
        snowW = snowW+i;
        if (i === stoneOne[1]) {
            snowW -= stoneOne[0];
        }

        if (i === stoneTwo[1]) {
            snowW -= stoneTwo[0];
        }
        if (snowW < 0)
            snowW = 0;
    }
    console.log(snowW);
}

readLines(3, doIt);

//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 two = nextIntArray();
  var three = nextIntArray();
  var u1 = two[0];
  var d1 = two[1];
  var u2 = three[0];
  var d2 = three[1];
  for(var i = h; i >= 0; i--){
    w += i;
    if(i == d1){
      w -= u1;
    }
    if(i == d2){
      w -= u2;
    }
    if(w < 0){
      w = 0;
    }
  }
  myout(w);
}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [w, h] = d.split(' ').map(Number);
    return;
  }

  if (c === 1) {
    c++;
    [u1, d1] = d.split(' ').map(Number);
    return;
  }

  [u2, d2] = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let ans = w;

  while (h > 0) {
    ans += h;

    if (h === d1) {
      ans -= u1;
    }

    if (h === d2) {
      ans -= u2;
    }

    if (ans < 0) {
      ans = 0;
    }

    h--;
  }

  console.log(Math.max(0, ans));
});

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, -1);
        let myinput = input.map(value => parseInt(value));
        console.log(snowball.apply(null, myinput));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w -= u1;
        if (h == d2) w -= u2;
        if (!w) w = 0;
    }
    return w;
}

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        input = input.concat(chunk.slice(0, -1).split(' '));
        if (input.length == 6) {
            let myinput = input.map(value => parseInt(value));
            console.log(snowball.apply(null, myinput));
            //process.exit(0);
        }
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = w - u1 ? w - u1 : 0;
        if (h == d2) w = w - u2 ? w - u2 : 0;
    }
    return w;
}

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, -1);
        let myinput = input.map(value => parseInt(value));
        console.log(input);
        console.log(snowball.apply(null, myinput));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = (w - u1) > 0 ? (w - u1) : 0;
        if (h == d2) w = (w - u2) > 0 ? (w - u2) : 0;
    }
    return w;
}

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n| /;
        input = chunk.split(re).slice(0, -1);
        let myinput = input.map(value => parseInt(value));
        console.log(snowball.apply(null, myinput));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = w - u1 ? w - u1 : 0;
        if (h == d2) w = w - u2 ? w - u2 : 0;
    }
    return w;
}

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        input = input.concat(chunk.slice(0, -1).split(' '));
        if (input.length == 6) {
            let myinput = input.map(value => parseInt(value));
            console.log(snowball.apply(null, myinput));
            process.exit(0);
        }
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = w - u1 ? w - u1 : 0;
        if (h == d2) w = w - u2 ? w - u2 : 0;
    }
    return w;
}

process.stdin.setEncoding('utf8');
let input = [];
process.stdin.on('readable', () => {
    const chunk = process.stdin.read();
    if (chunk !== null) {
        let re = /\n\s*| /;
        input = chunk.split(re).slice(0, -1);
        let myinput = input.map(value => parseInt(value));
        process.exit(0);
    }
});

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w = (w - u1) > 0 ? (w - u1) : 0;
        if (h == d2) w = (w - u2) > 0 ? (w - u2) : 0;
    }
    return w;
}

function snowball(weight, height, u1, d1, u2, d2) {
    let w = weight, h = height;
    for (; h >= 0; h--) {
        w = w + h;
        if (h == d2) {
            w = w - u2 ? w - u2 : 0;
        }
        if (h == d1) {
            w = w - u1 ? w - u1 : 0;
        }
    }
    return w;
}

[w, h, u1, d1, u2, d2] = process.argv.slice(2).map((value) => parseInt(value));
weight = snowball(w, h, u1, d1, u2, d2);
console.log(weight);

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [w, h] = d.split(' ').map(Number);
    return;
  }

  if (c === 1) {
    c++;
    [u1, d1] = d.split(' ').map(Number);
    return;
  }

  [u2, d2] = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let ans = w;

  ans += h*(h+1) / 2;
  ans -= u1;
  ans -= u2;
  ans = Math.max(0, ans);

  console.log(ans);
});

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

let l = 0;
let w = []
let h = []

rl.on('line', (input) => {
    if (l === 0) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else if (l === 1) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let wg = w[0]
        let hg = h[0]
        w.push(inp[0])
        h.push(inp[1])
        if (h[1] > h[2]) {
            for (let i = h[0]; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (hg <= 0) {
                if (wg < 0)
                    wg = 0
                console.log(wg)
                return
            }
            for (let i = h[1] - 1; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]
            if (hg > 0)
                wg += hg
            if (wg < 0)
                wg = 0
            console.log(wg)
        } else {
            for (let i = h[0]; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]

            if (hg <= 0) {
                if (wg < 0)
                    wg = 0
                console.log(wg)
                return
            }

            for (let i = h[2] - 1; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (hg > 0)
                wg += hg
            if (wg < 0)
                wg = 0
            console.log(wg)
        }
    }
    l++
});

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

let l = 0;
let w = []
let h = []

rl.on('line', (input) => {
    if (l === 0) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else if (l === 1) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let wg = w[0]
        let hg = h[0]
        w.push(inp[0])
        h.push(inp[1])
        if (h[1] > h[2]) {
            hg++
            for (let i = h[0]; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (hg <= 0) {
                if (wg < 0)
                    wg = 0
                console.log(wg)
                return
            }
            hg--
            for (let i = h[1] - 1; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]
            if (hg > 0)
                wg += hg
            if (wg < 0)
                wg = 0
            console.log(wg)
        } else {
            hg++
            for (let i = h[0]; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]

            if (hg <= 0) {
                if (wg < 0)
                    wg = 0
                console.log(wg)
                return
            }

            for (let i = h[2] - 1; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (hg > 0)
                wg += hg
            if (wg < 0)
                wg = 0
            console.log(wg)
        }
    }
    l++
});

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

let l = 0;
let w = []
let h = []

rl.on('line', (input) => {
    if (l === 0) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else if (l === 1) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let wg = w[0]
        let hg = h[0]
        w.push(inp[0])
        h.push(inp[1])
        if (h[1] > h[2]) {
            for (let i = h[0]; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (wg < 0)
                wg = 0
            if (hg <= 0) {
                console.log(wg)
                return
            }
            for (let i = h[1] - 1; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]
            if (wg < 0)
                wg = 0

            if (hg > 0)
                wg += hg
            console.log(wg)
        } else {
            for (let i = h[0]; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]
            if (wg < 0)
                wg = 0
            if (hg <= 0) {
                console.log(wg)
                return
            }
            for (let i = h[2] - 1; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (wg < 0)
                wg = 0
            if (hg > 0)
                wg += hg
            console.log(wg)
        }
    }
    l++
});

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

let l = 0;
let w = []
let h = []

rl.on('line', (input) => {
    if (l === 0) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else if (l === 1) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let wg = w[0]
        let hg = h[0]
        w.push(inp[0])
        h.push(inp[1])
        if (h[1] > h[2]) {
            hg++
            for (let i = h[0]; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (hg <= 0) {
                if (wg < 0)
                    wg = 0
                console.log(wg)
                return
            }

            for (let i = h[1] - 1; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]
            if (wg < 0)
                wg = 0
            console.log(wg)
        } else {
            hg++
            for (let i = h[0]; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]

            if (hg <= 0) {
                if (wg < 0)
                    wg = 0
                console.log(wg)
                return
            }

            for (let i = h[2] - 1; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (wg < 0)
                wg = 0
            console.log(wg)
        }
    }
    l++
});

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

let l = 0;
let w = []
let h = []

rl.on('line', (input) => {
    if (l === 0) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else if (l === 1) {
        let inp = input.split(" ").map(x => parseInt(x))
        w.push(inp[0])
        h.push(inp[1])
    } else {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let wg = w[0]
        let hg = h[0]
        w.push(inp[0])
        h.push(inp[1])
        if (h[1] > h[2]) {
            hg++
            for (let i = h[0]; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            if (hg <= 0) {
                console.log(wg)
                return
            }

            for (let i = h[1] - 1; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]
            console.log(wg)
        } else {
            hg++
            for (let i = h[0]; i >= h[2]; i--) {
                wg += i
                hg--
            }
            wg -= w[2]

            if (hg <= 0) {
                console.log(wg)
                return
            }

            for (let i = h[2] - 1; i >= h[1]; i--) {
                wg += i
                hg--
            }
            wg -= w[1]
            console.log(wg)
        }
    }
    l++
});


var n = parseInt(readline());
var a = [];
for(var i = 0; i < n;i++){
	a[i] = parseInt(readline());
}
// var a = [14,14,14,14,32,32,32,32];

function main(a){
	var len = a.length;
	var map = new Map();
	for(var i = 0; i < len;i++){
		if(map.has(a[i])){
			map.set(a[i],map.get(a[i])+1)
		}else{
			map.set(a[i],1);
		}
	}
	var len1 = map.size;
	if(len1 != 2){
		print('NO');
		// console.log("NO");
	}
	else {
		for(var j = 0; j < len1-1;j++){
			if(map.get(a[j]) === n/2){
				// console.log(map.get(a[j]), map.get(a[j+1]));
				// console.log("YES");
				print('YES');
				var item = map.keys();
				// console.log(item.next().value+' '+item.next().value);
				print(item.next().value+' '+item.next().value)
			}
			else{
				print('NO');
				// console.log("NO");
			}
		}
	}
}
main(a);

(function() {

var line = Number(readline());
var numbers = {};
for (var i = 0; i < line; i++) {
  var next = Number(readline());
  numbers[next] = (numbers[next] || 0) + 1;
  if (Object.keys(numbers).length > 2) {
    print('NO');
    return;
  }
}
var keys = Object.keys(numbers);
if (keys.length === 2 && numbers[keys[0]] === numbers[keys[1]]) {
  print('YES\n' + keys.join(' '));
} else {
  print('NO');
}

})()

var n = parseInt(readline());
var a = [];
for(var i = 0; i < n;i++){
	a[i] = parseInt(readline());
}
// var a = [14,14,14,14,32,32,32,32];
function main(a){
	var len = a.length;
	var map = new Map();
	for(var i = 0; i < len;i++){
		if(map.has(a[i])){
			map.set(a[i],map.get(a[i])+1)
		}else{
			map.set(a[i],1);
		}
	}
	var len1 = map.size;
	if(len1 != 2){
		print('NO');
		// console.log("NO");
	}
	else {
		for(var j = 0; j < len1-1;j++){
			if(map.get(a[j]) === map.get(a[j+1])){
				// console.log(map.get(a[j]), map.get(a[j+1]));
				// console.log("YES");
				print('YES');
				var item = map.keys();
				// console.log(item.next().value+' '+item.next().value);
				print(item.next().value+' '+item.next().value)
			}
			else{
				print('NO');
				// console.log("NO");
			}
		}
	}
}
main(a);

var n = parseInt(readline());
var a = [];
for(var i = 0; i < n;i++){
	a[i] = parseInt(readline());
}
// var a = [1,1,2,2,3,3];
function main(a){
	var len = a.length;
	var map = new Map();
	for(var i = 0; i < len;i++){
		if(map.has(a[i])){
			map.set(a[i],map.get(a[i])+1)
		}else{
			map.set(a[i],1);
		}
	}
	var len1 = map.size;
	if(len1 != 2){
		print('NO');
	}
	else {
		for(var i = 0; i < len1-1;i++){
			if(map.get(a[i]) === map.get(a[i+1])){
				// console.log(map.get(a[i]), map.get(a[i+1]));
				// console.log("Yes");
				// console.log(a[i], a[i+1]);
				print('YES');
				print(a[i],a[i+1]);
			}
			else{
				print('NO');
			}
		}
	}
}
main(a);


if (process.env.ANT)
{
    global.print = this.print ||
        function(){console.log([...arguments].join(' '))} ||
        require('lol-io').print;
    global.debug = function(){console.log('debug:', [...arguments].join(' '))}
    global.write = this.write || require('lol-io').write
    global.readline = this.readline || require('lol-io').readline
    main();
}
else
{
    const rl = require('readline').createInterface({ input: process.stdin,
        output: process.stdout });
    global.print = console.log
    global.debug = ()=>{};
    global.write = (...args) => {
        process.stdout.write(args.join(' '));
    }
    const lines = []
    rl.on('line', line =>{
        lines.push(line);
    });
    rl.on('close', main)
    let rli = 0;
    global.readline = ()=>lines[rli++];
}

///////////// CODE

function main(){
    let D = [];

    let s = readline();
    let t = readline();

    function test(i, m)
    {
        debug('test ', i, m)
        let is = 0, it = 0;
        if (is==i)
            is += m;
        while (it<t.length)
        {
            while (t[it]!=s[is] && is<s.length)
            {
                is++;
                if (is==i)
                    is += m;
            }
            if (is==s.length)
                return false;
            it++;
            is++;
            if (is==i)
                is += m;
        }
        return it==t.length;
    }

    function check(n){
        debug('check '+n)
        for (let i=0; i<s.length-n+1; i++)
        {
            if (test(i, n))
                return true;
        }
    }

    let l = 1, r = s.length-t.length;
    while (l+1<r)
    {
        let m = (l+r)/2|0;
        if (check(m))
            l = m;
        else
            r = m;
    }
    print(check(r) ? r : r-1);

}

'use strict'

const s = readline();
const t = readline();

const a = [], b = [];
let i = -1, j = 0;

while (j < t.length && i < s.length - 1) {
    if (s[++i] === t[j]) a[j++] = i
}

i = s.length; j = t.length - 1;

while (j !== -1 && i !== 0 ) {
    if (s[--i] === t[j]) b[j--] = i
}

let max = Math.max(b[0], s.length - 1 - a[a.length - 1]);

for (let i = 0; i < t.length - 1; i++) {
    if (b[i+1] - a[i] - 1 > max) max = b[i+1] - a[i] - 1;
}

write(max);

if (process.env.ANT)
{
    global.print = this.print ||
        function(){console.log([...arguments].join(' '))} ||
        require('lol-io').print;
    global.debug = function(){console.log('debug:', [...arguments].join(' '))}
    global.write = this.write || require('lol-io').write
    global.readline = this.readline || require('lol-io').readline
    main();
}
else
{
    const rl = require('readline').createInterface({ input: process.stdin,
        output: process.stdout });
    global.print = console.log
    global.debug = ()=>{};
    global.write = (...args) => {
        process.stdout.write(args.join(' '));
    }
    const lines = []
    rl.on('line', line =>{
        lines.push(line);
    });
    rl.on('close', main)
    let rli = 0;
    global.readline = ()=>lines[rli++];
}

///////////// CODE

function main(){
    let D = [];

    let s = readline();
    let t = readline();

    function test(i, m)
    {
        debug('test ', i, m)
        let is = 0, it = 0;
        if (is==i)
            is += m;
        while (it<t.length)
        {
            while (t[it]!=s[is] && is<s.length)
            {
                is++;
                if (is==i)
                    is += m;
            }
            if (is==s.length)
                return false;
            it++;
            is++;
            if (is==i)
                is += m;
        }
        return it==t.length;
    }

    function check(n){
        debug('check '+n)
        for (let i=0; i<s.length-n+1; i++)
        {
            if (test(i, n))
                return true;
        }
    }

    let l = 1, r = s.length-t.length;
    while (l+1<r)
    {
        let m = (l+r)/2;
        if (check(m))
            l = m;
        else
            r = m;
    }
    print(check(r) ? r : r-1);

}

'use strict'

const s = readline();
const t = readline();
const d1 = (s, t) => {
    const a = [], b = [];
    let i = -1, j = 0;
    while (j < t.length && i < s.length - 1) {
        if (s[++i] === t[j]) a[j++] = i
    }
    i = s.length; j = t.length - 1;
    while (j !== -1 && i !== 0 ) {
        if (s[--i] === t[j]) b[j--] = i
    }

    let max = Math.max(b[0], s.length - 1 - a[a.length - 1]);
    for (let i = 0; i < t.length - 1; i++) {
        if (b[i+1] - a[i] - 1 > max) max = b[i+1] - a[i] - 1;
    }
    return max;
}


function multiply(x, strNum)
{
	var carry = 0;
	var num = strNum.split('').map(Number).reverse();
	var result = [];

	for(var i = 0; i < num.length; i++)
	{
		var prod = x * num[i] + carry;
		result.push(prod % 10);
		carry = Math.floor(prod / 10);
	}

	while(carry)
	{
		result.push(carry % 10);
		carry = Math.floor(carry / 10);
	}

	return result.reverse().join('');
}

function pow(x, pow)
{
	var result = '1';
	for(var i = 0; i < pow; i++)
		result = multiply(x, result);

	return result;
}

var input = readline();
var digits = input[0] + input[2] + input[4] + input[3] + input[1];

var result = pow(digits, 5);
print(result.substr(result.length - 5));

// since javascript only has 53bit number,
// we need to operate it as big number by using string
function multiply(x, strNum)
{
	var carry = 0;
	var num = strNum.split('').map(Number).reverse();
	var result = [];

	for(var i = 0; i < num.length; i++)
	{
		var prod = x * num[i] + carry;
		result.push(prod % 10);
		carry = Math.floor(prod / 10);
	}

	// the possible biggest carry is
	// 99999 * 9 = 899991
	while(carry)
	{
		result.push(carry % 10);
		carry = Math.floor(carry / 10);
	}

	return result.reverse().join('');
}

function pow(x, pow)
{
	var result = '1';
	for(var i = 0; i < pow; i++)
		result = multiply(x, result);

	return result;
}

var input = readline();
var digits = input[0] + input[2] + input[4] + input[3] + input[1];

var result = pow(digits, 5);
print(result.substr(result.length - 5));


function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt() - 'a'.charCodeAt() + 1;
  });
  word.sort((a, b) => a - b);

  let answer = word[0];
  let pre = 0;
  let number = 1;
  for (let i = 1; i < n; i += 1) {
    if (number === m)
      break;
    if (word[i] - word[pre] >= 2) {
      answer += word[i];
      pre = i;
      number += 1;
    }
  }

  console.log(number !== m ? -1 : answer);
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt() - 'a'.charCodeAt() + 1;
  });
  word.sort((a, b) => a - b);

  function theFor(i, j, accum, number) {
    if (m === number) {
      return accum;
    }
    if (j === n) {
      return -1;
    }

    if (word[j] - word[i] > 1) {
      return theFor(j, j + 1, accum + word[j], number + 1);
    }
    return theFor(i, j + 1, accum, number);
  }

  console.log(theFor(0, 1, word[0], 1));
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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

rl.on('line', (d) => {
  if (c === 0) {
    [n, k] = d.split(' ').map(Number);
    c++;
    return;
  }

  const chars = [...d];
  chars.sort();
  const alpha = 'abcdefghijklmnopqrstuvwxyz';

  let ans = -1;
  const str = [chars[0]];

  for (let i = 0; i < n; i++) {
    let prev = str[str.length - 1];
    let distance = Math.abs(alpha.indexOf(prev) - alpha.indexOf(chars[i]));

    if (distance < 2) {
      continue;
    }

    str.push(chars[i]);

    if (str.length === k) {
      break;
    }
  }

  if (str.length >= k) {
    ans = 0;
    for (let i = 0; i < k; i++) {
      ans += alpha.indexOf(str[i]) + 1;
    }
  }

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

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

rl.on('line', (d) => {
  if (c === 0) {
    [n, k] = d.split(' ').map(Number);
    c++;
    return;
  }

  const chars = [...d];
  chars.sort();
  const alpha = 'abcdefghijklmnopqrstuvwxyz';

  let ans = -1;
  const str = [chars[0]];

  for (let i = 0; i < n; i++) {
    let prev = str[str.length - 1];
    let distance = Math.abs(alpha.indexOf(prev) - alpha.indexOf(chars[i]));

    if (distance < 2) {
      continue;
    }

    str.push(chars[i]);

    if (str.length === k) {
      break;
    }
  }

  if (str.length === k) {
    ans = 0;
    for (let i = 0; i < str.length; i++) {
      ans += alpha.indexOf(str[i]) + 1;
    }
  }

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

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  });
  word.sort((a, b) => a - b);

  let answer = Infinity;

  function calc(i, accum, number) {
    if (number === m) {
      answer = Math.min(answer, accum);
    }
    if (i === n || number > m) {
      return;
    }

    if (Math.abs(word[i] - word[i + 1]) >= 2) {
      calc(i + 1, accum + word[i + 1], number + 1);
    }
    calc(i + 1, accum, number);
  }

  calc(0, word[0], 1);
  console.log(answer === Infinity ? -1 : answer);
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  });
  word.sort((a, b) => a - b);

  let answer = Infinity;

  function calc(i, accum, number) {
    if (number === m) {
      answer = Math.min(answer, accum);
    }
    if (i === n || number > m) {
      return;
    }

    if (Math.abs(word[i] - word[i + 1]) >= 2) {
      calc(i + 1, accum + word[i + 1], number + 1);
    }
    calc(i + 1, accum, number);
  }

  for (let i = 0; i < n - m + 1; i += 1) {
    calc(i, word[i], 1);
  }
  console.log(answer === Infinity ? -1 : answer);
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  });
  word.sort((a, b) => a - b);

  let answer = Infinity;

  function calc(i, accum, number) {
    if (number === m) {
      answer = Math.min(answer, accum);
      return;
    }
    if (i === n) {
      return;
    }

    if (word[i + 1] - word[i] >= 2) {
      calc(i + 1, accum + word[i + 1], number + 1);
    }
    calc(i + 1, accum, number);
  }

  for (let i = 0; i < n - m + 1; i += 1) {
    calc(i, word[i], 1);
  }
  console.log(answer === Infinity ? -1 : answer);
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt() - 'a'.charCodeAt() + 1;
  });
  word.sort((a, b) => a - b);

  function theFor(i, j, accum, number) {
    if (m === number) {
      return accum;
    }
    if (j + 1 === n) {
      return -1;
    }

    if (word[j] - word[i] > 1) {
      return theFor(j, j + 1, accum + word[j], number + 1);
    }
    return theFor(i, j + 1, accum, number);
  }

  console.log(theFor(0, 1, word[0], 1));
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const word = is.nextLine().split('');
  word.forEach((item, index, array) => {
    array[index] = item.charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  });
  word.sort((a, b) => a - b);
  console.log(word);
  let answer = Infinity;

  function calc(i, accum, number) {
    if (number === m) {
      answer = Math.min(answer, accum);
      return;
    }
    if (i === n) {
      return;
    }

    if (word[i + 1] - word[i] >= 2) {
      calc(i + 1, accum + word[i + 1], number + 1);
    }
    calc(i + 1, accum, number);
  }

  for (let i = 0; i < n - m + 1; i += 1) {
    calc(i, word[i], 1);
  }
  console.log(answer === Infinity ? -1 : answer);
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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

rl.on('line', (d) => {
  if (c === 0) {
    [n, k] = d.split(' ').map(Number);
    c++;
    return;
  }

  const chars = [...d];
  chars.sort();
  const alpha = 'abcdefghijklmnopqrstuvwxyz';

  let ans = -1;
  const str = [chars[0]];

  for (let i = 0; i < n; i++) {
    let prev = str[str.length - 1];
    let distance = Math.abs(alpha.indexOf(prev) - alpha.indexOf(chars[i]));

    if (distance <= 2) {
      continue;
    }

    str.push(chars[i]);

    if (str.length === k) {
      break;
    }
  }

  if (str.length === k) {
    ans = 0;
    for (let i = 0; i < str.length; i++) {
      ans += alpha.indexOf(str[i]) + 1;
    }
  }

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


// http://codeforces.com/contest/236/problem/B

var memObj = {};
function d(n) {
    var num = 0;
    if (memObj[n]) {
        num = memObj[n];
    } else {
        if (n == 1) return 1;
        num = 2;
        var k = Math.floor(Math.sqrt(n));
        for (var i = 2; i <= k; i++) {
            if (n%i === 0) {
                num += 2;
            }

            if (i*i ==n ) num --;
        }
        memObj[n] = num;
    }

    return num;
}

function getSum(a,b,c) {
    var sum = 0;
    for (var i = 1; i <= a; i++) {
        for (var j = 1; j <= b; j++) {
            for (var k =1; k <= c; k++) {
                sum += d(i*j*k);
            }
        }
    }

    return sum;
}

var args = readline().split(' ');
print(getSum(args[0], args[1], args[2])%1073741824);

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 numDivisors(x) {
	var count = 0;
	for (var i = 1; i*i <= x; ++i) {
		if (x%i == 0) {
			++count;
			if (i*i != x) {
				++count;
			}
		}
	}
	return count;
}

function main() {
	var data = tokenizeIntegers(readline()),
		a = data[0], b = data[1], c = data[2],
		divisors = {}, count = 0;
	for (var i = 1; i <= a; ++i) {
		for (var j = 1; j <= b; ++j) {
			for (var k = 1; k <= c; ++k) {
				var x = i*j*k;
				if (divisors[x] === undefined) {
					divisors[x] = numDivisors(x);
				}
				count = (count+divisors[x]) % 1073741824;
			}
		}
	}
	print(count);
}

main();

// http://codeforces.com/contest/236/problem/B

var memObj = {};
function d(n) {
    var num = 0;
    if (memObj[n]) {
        num = memObj[n];
    } else {
        var k = Math.floor(Math.sqrt(n));
        for (var i = 1; i <= k; i++) {
            if (n%i === 0) {
                num += 2;
            }

            if (i*i ==n ) num --;
        }
        memObj[n] = num;
    }

    return num;
}

function getSum(a,b,c) {
    var sum = 0;
    for (var i = 1; i <= a; i++) {
        for (var j = 1; j <= b; j++) {
            for (var k =1; k <= c; k++) {
                sum += d(i*j*k);
            }
        }
    }

    return sum;
}

var args = readline().split(' ');
print(getSum(args[0], args[1], args[2])%1073741824);

// http://codeforces.com/contest/236/problem/B

var memObj = {};
function d(n) {
    var num = 0;
    if (memObj[n]) {
        num = memObj[n];
    } else {
        var k = Math.floor(Math.sqrt(n));
        for (var i = 1; i <= k; i++) {
            if (n%i === 0) {
                num += 2;
            }

            if (i*i ==n ) num --;
        }
        memObj[n] = num;
    }

    return num;
}

function getSum(a,b,c) {
    var sum = 0;
    for (var i = 1; i <= a; i++) {
        for (var j = 1; j <= b; j++) {
            for (var k =1; k <= c; k++) {
                sum += d(i*j*k);
            }
        }
    }

    return sum;
}

var args = readline().split(' ');
print(getSum(args[0], args[1], args[2]));

// http://codeforces.com/contest/236/problem/B

var memObj = {};
function d(n) {
    var num = 0;
    if (memObj[n]) {
        num = memObj[n];
    } else {
        var k = Math.floor(Math.sqrt(n));
        for (var i = 1; i <= k; i++) {
            if (k%i === 0) {
                num += 2;
            }

        }
        if (k*k == n) {
            num -= 1;
        }

        memObj[n] = num;
    }

    return num;
}

function getSum(a,b,c) {
    var sum = 0;
    for (var i = 1; i <= a; i++) {
        for (var j = 1; j <= b; j++) {
            for (var k =1; k <= c; k++) {
                sum += d(i*j*k);
            }
        }
    }

    return sum;
}

var args = readline().split(' ');
print(getSum(args[0], args[1], args[2]));