write(format(as.Date(readLines("stdin"),"%Y%m%d"),"%w"),"")