open System

[<EntryPoint>]
let main argv =
    let [|M1; D1;|] = stdin.ReadLine().Split() |> Array.map int
    let [|M2; D2;|] = stdin.ReadLine().Split() |> Array.map int
    let ret = if (D2 = 1) then 1 else 0
    printfn "%d" ret
    0