John wrote a 4-digit number on a piece of paper and asked Peter to guess it.
Peter asked: “Is the number 2435?”
John replied: “Two of the digits are correct. The positions of those digits are also correct.”
Peter asked again: “Is the number 6397?”
John replied: “Two of the digits are correct. The positions of those digits are all wrong.”
Peter asked again: “Is the number 9823?”
John said: “All the digits are correct. The positions of those digits are all wrong.”
Given all the digits in that 4-digit number are all different, what is the number written by John?