A. Prefixes

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Nikolay got a string ss of even length nn, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 11 to nn.

He wants to modify his string so that every its prefix of even length has an equal amount of letters 'a' and 'b'. To achieve that, Nikolay can perform the following operation arbitrary number of times (possibly, zero): choose some position in his string and replace the letter on this position with the other letter (i.e. replace 'a' with 'b' or replace 'b' with 'a'). Nikolay can use no letters except 'a' and 'b'.

The prefix of string ss of length ll (1≤l≤n1≤l≤n) is a string s[1..l]s[1..l].

For example, for the string s=s="abba" there are two prefixes of the even length. The first is s[1…2]=s[1…2]="ab" and the second s[1…4]=s[1…4]="abba". Both of them have the same number of 'a' and 'b'.

Your task is to calculate the minimum number of operations Nikolay has to perform with the string ss to modify it so that every its prefix of even length has an equal amount of letters 'a' and 'b'.

Input

The first line of the input contains one even integer nn (2≤n≤2⋅105)(2≤n≤2⋅105) — the length of string ss.

The second line of the input contains the string ss of length nn, which consists only of lowercase Latin letters 'a' and 'b'.

Output

In the first line print the minimum number of operations Nikolay has to perform with the string ss to modify it so that every its prefix of even length has an equal amount of letters 'a' and 'b'.

In the second line print the string Nikolay obtains after applying all the operations. If there are multiple answers, you can print any of them.

Examples

input

Copy

4
bbbb

output

Copy

2
abba

input

Copy

6
ababab

output

Copy

0
ababab

input

Copy

2
aa

output

Copy

1
ba

Note

In the first example Nikolay has to perform two operations. For example, he can replace the first 'b' with 'a' and the last 'b' with 'a'.

In the second example Nikolay doesn't need to do anything because each prefix of an even length of the initial string already contains an equal amount of letters 'a' and 'b'.

解题说明:此题是一道字符串题,按照题目意思必须要求ab两个字母连续出现,对字符串进行遍历,确保每一对中都有ab即可。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int n, k = 0;
	scanf("%d", &n);
	char s[200004];
	scanf("%s", s);
	for (int i = 1; i < n; i += 2)
	{
		if (s[i] == s[i - 1])
		{
			if (s[i] == 'a')
			{
				s[i] = 'b';
				k++;
			}
			else
			{
				s[i] = 'a';
				k++;
			}
		}
	}
	printf("%d\n%s", k, s);
	return 0;
}
发布了1729 篇原创文章 · 获赞 371 · 访问量 273万+

猜你喜欢

转载自blog.csdn.net/jj12345jj198999/article/details/102768752