function Main(input){
	var xs = input.trim().split('').map(v=>parseInt(v,10));
    var a = 0;
    var b = 0;
    var c = 0;
    var d = 0;
    var e = 0;
    var f = 0;
    if(xs[0]==xs[1]){
    a += 1
    }
    var b = 0;
    if(xs[0]==xs[2]){
    b += 1
    }
    var c = 0;
    if(xs[0]==xs[3]){
    c += 1
    }
    var d = 0;
    if(xs[1]==xs[2]){
    d += 1
    }
    var e = 0;
    if(xs[1]==xs[3]){
    e += 1
    }
    var f = 0;
    if(xs[2]==xs[3]){
    f += 1
    }
    console.log(a+b+c+d+e+f);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));