const [ year, month, day ] = readline().split(" ")

const arr = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]

// 闰年分为普通闰年和世纪闰年,其判断方法为:公历年份是4的倍数,且不是100的倍数,为普通闰年。公历年份是整百数,且必须是400的倍数才是世纪闰年。
if( (year % 100 === 0 && year % 400 === 0) || ( year % 4 === 0 && year % 100 !== 0 )) {
  arr[1] = 29
}

const sum = arr.slice(0, month - 1).reduce( ( total, current ) => parseInt(total) + parseInt(current), parseInt(day) )

print( sum )