"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   xs.sort(); 
   if(xs[1] == xs[2]){
     console.log('No');
   }else if(xs[0] == xs[1] && xs[2] == xs[3]){
     console.log('Yes');
   }else{
     console.log('No');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));