<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!DOCTYPE html>
<html>
<body>
<h2>1000</h2>
<input type="text" onkeyup="key()" id="1">
<input type="text" onkeyup="key1()" id="2">
<input type="text" id="3">
<script>
function key(){
var lav=document.getElementById('1').value;
document.getElementById('2').value=1000-Number(lav);
if(lav==1000){
document.getElementById('2').disabled=true;
}
}
function key1(){
var lk=document.getElementById('2').value;
var lav=document.getElementById('1').value;
document.getElementById('3').value=1000-(Number(lav)+Number(lk));
}
</script>
</body>
</html>