Device for discrimination of sheets, image forming apparatus and program with simplified mechanism