#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	int a[10];
	int b;
	scanf("%d", &b);
	for (int i = 0; i < 4; i++) {
		a[i] = b % 10;
		b = b / 10;
	}
	sort(a, a+4);
	int t = 1;
	int k = a[0];
	for (int i = 1; i < 4; i++) {
		if (k == a[i]) t++;
	}
	k = a[1];
	int x = 1;
	for (int i = 2; i < 4; i++) {
		if (k == a[i]) x++;
	}
	int y = max(x, t);
	if (y < 3) printf("No\n");
	else printf("Yes\n");
	return 0;
} 