function main(input) {
  const n = parseInt(input, 10);
  var hako=[];
  var a = Math.floor(n/100);
  var b = Math.floor((n-a*100)/10);
  var c =n-a*100-b*10;
  hako.push(a);
  hako.push(b);
  hako.push(c);
  for(var i=0; i<3; i++){
    if(hako[i]==1){
      hako[i]=9
    }else if(hako[i]==9){
      hako[i]=1
    }
  }
  console.log(100*hako[0]+10*hako[1]+hako[2]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));