#define f(n)d[n]+=d[n-1], d[10];main(i){for(;read(0,&i,1);)i&1?f(4)f(9)0:i&4?f(2)d[1]=*d,*d=0,f(8)d[7]=d[6],d[6]=0:i%5?f(3)d[2]=0,f(6)d[5]=0:i&2?:++*d+d[5]++;printf("%d %d",d[4],d[9]);}