/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

class CMaxGCD2 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A, B;
        cin >> A >> B;
        int diff = B - A;
        int res = 0;
        FOR(i, 1, diff) {
            int n = (A - 1) / i * i + i;
            if (n + i > B) continue;
            res = i;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CMaxGCD2 solver;
    solver.solve(in, out);
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<cmath>
#include<iomanip>
#include<map>

using namespace std;

#define M 998244353
#define INF 1e18L

int main()
{
	int n, k;
	cin >> n >> k;
	vector<vector<long long>> t(n, vector<long long>(n));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> t[i][j];
	
	vector<int> perm(n - 1);
	for(int i = 0; i < n - 1; i++)
		perm[i] = i + 1;

	int cnt = 0;

	do
	{
		long long cost = t[0][perm[0]];
		for(int i = 0; i < n - 2; i++)
		{
			cost = cost + t[perm[i]][perm[(i+1)]];
		}
		cost += t[perm[n-2]][0];
		if(cost == k)
			cnt++;
		
	}while(next_permutation(perm.begin(), perm.end()));
	cout << cnt << '\n';
	return 0;
}
