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

void main()
{
    auto S = readln.chomp.to!(wchar[]);
    auto K = readln.chomp;

    writeln(K == "1" || S[0] != '1' ? S[0] : S[1]);
}