import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.datetime;

void main() {
    const tmp = readln.split.to!(int[]);
    const a = tmp[0], b = tmp[1];

    auto current = DateTime(2018, 1, 1);
    auto end = DateTime(2018, a, b);
    end += 1.days;

    int cnt;
    while (current != end) {
        if (current.month.to!int == current.day.to!int) cnt++;
        current += 1.days;
    }
    writeln(cnt);
}

