module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	int n, m;
	int[2][] friends;
}

void parseInput(T)(out Input input, T adapter)
{
	with (input)
	{
		adapter.readf!"%d %d\n"(n, m);
		friends.length = m;
		for (int i = 0; i < m-1; i++)
		{
			adapter.readf!"%d %d\n"(friends[i][0], friends[i][1]);
		}
		adapter.readf!"%d %d"(friends[$-1][0], friends[$-1][1]);
	}
}

struct Output
{
}

struct Person
{
	int group = -1;
	int[] friends;
}

auto main2(Input* input)
{
	Person[] persons;
	persons.length = 2 * 10 ^^ 5 + 1;
	int group = 0;
	with (input)
	{
		foreach (f; friends)
		{
			persons[f[0]].friends ~= f[1];
			persons[f[1]].friends ~= f[0];
		}

		bool walk(int i, int g)
		{
			if (persons[i].group != -1)
				return false;

			persons[i].group = g;
			foreach (f; persons[i].friends)
				walk(f, g);

			return true;
		}

		foreach (i, p; persons[1..n+1])
		{
			if (walk(cast(int)i + 1, group))
				group++;
		}

		int[] groupCounts;
		groupCounts.length = group;

		foreach (i, p; persons[1..n+1])
		{
			groupCounts[p.group]++;
		}

		int max = 0;
		foreach (count; groupCounts)
		{
			if (count > max)
				max = count;
		}
		return max;
	}

	uint result;
	return typeof(result).init;
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`5 3
1 2
3 4
5 1`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 3);
	}

	unittest // example2
	{
		string example =
`4 10
1 2
2 1
1 2
2 1
1 2
1 3
1 4
2 3
2 4
3 4`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 4);
	}

	unittest // example3
	{
		string example =
`10 4
3 1
4 1
5 9
2 6`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 3);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		parseInput(input, new StringAdapter(example));
	}
}

class StdinAdapter
{
	// readf!"%s"は使えない
	// https://issues.dlang.org/show_bug.cgi?id=19820
	uint readf(alias format, A...)(auto ref A args) { return std.stdio.readf!format(args); }
	string readln() { return std.stdio.readln().strip(); }
}

class StringAdapter
{
	import std.format;
	string _s;
	this(string input) { _s = input; }
	uint readf(alias format, A...)(auto ref A args) { return _s.formattedRead!format(args); }
	string readln()
	{
        string ret;
		auto i = _s.countUntil("\n");
		if (i == -1) { ret = _s; _s = ""; }
        else { ret = _s[0..i]; _s = _s[i+1..$]; }
		return ret;
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, new StdinAdapter());
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


Measured memory_bytes: 24828