t=tail d x=sum[1|y<-zipWith(<)x(t x),y] main=interact$show.((,).d<*>d.((zipWith3(((+).).(+))<*>t)<*>(t.t))).map read.lines