cf----2019-11-06(Quadcopter Competition, Almost Identity Permutations,Lost in Transliteration)

世上只有一种英雄主义,就是在认清生活真相之后依然热爱生活。

Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:

  • start the race from some point of a field,
  • go around the flag,
  • close cycle returning back to the starting point.

Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of the point where the flag is situated (x2, y2). Polycarp’s quadcopter can fly only parallel to the sides of the field each tick changing exactly one coordinate by 1. It means that in one tick the quadcopter can fly from the point (x, y) to any of four points: (x - 1, y), (x + 1, y), (x, y - 1) or (x, y + 1).

Thus the quadcopter path is a closed cycle starting and finishing in (x1, y1) and containing the point (x2, y2) strictly inside.

The picture corresponds to the first example: the starting (and finishing) point is in (1, 5) and the flag is in (5, 2).

What is the minimal length of the quadcopter path?

Input

The first line contains two integer numbers x1 and y1 ( - 100 ≤ x1, y1 ≤ 100) — coordinates of the quadcopter starting (and finishing) point.

The second line contains two integer numbers x2 and y2 ( - 100 ≤ x2, y2 ≤ 100) — coordinates of the flag.

It is guaranteed that the quadcopter starting point and the flag do not coincide.

Output

Print the length of minimal path of the quadcopter to surround the flag and return back.

Examples

input

Copy

1 5
5 2

output

Copy

18

input

Copy

0 1
0 0

output

Copy

8
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int x1,y1,x2,y2,jg;
int main()
{scanf("%d%d",&x1,&y1);scanf("%d%d",&x2,&y2);jg=(abs(x1-x2)+abs(y1-y2)+2)<<1;if(!(x1-x2)||!(y1-y2))jg+=2;printf("%d\n",jg);return 0;
}

A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.

Let's call a permutation an almost identity permutation iff there exist at least n - k indices i(1 ≤ i ≤ n) such that pi = i.

Your task is to count the number of almost identity permutations for given numbers n and k.

Input

The first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).

Output

Print the number of almost identity permutations for given n and k.

Examples

input

Copy

4 1

output

Copy

1

input

Copy

4 2

output

Copy

7

input

Copy

5 3

output

Copy

31

input

Copy

5 4

output

Copy

76
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define inf 0x3f3f3f3f
typedef long long LL;
using namespace std;
int n,k;
LL c[1010][6],jg;
void plC()
{c[0][0]=1;for(int i=0; i<1005; i++)c[i][0]=1;for(int i=1; i<1005; i++){for(int j=1; j<5&&j<=i; j++){if(j==i)c[i][j]=1;elsec[i][j]=c[i-1][j-1]+c[i-1][j];}}
}
int main()
{plC();scanf("%d%d",&n,&k);jg=0;for(int i=0; i<=k; i++){if(i==3)jg+=c[n][i]*2;else if(i==4)jg+=c[n][i]*9;else if(i!=1)jg+=c[n][i];}printf("%lld\n",jg);return 0;
}

There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.

For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" and "oolyana" denote the same name.

The second ambiguity is about the Berland sound h: one can use both "h" and "kh" to write it. For example, the words "mihail" and "mikhail" denote the same name.

There are n users registered on the Polycarp's website. Each of them indicated a name represented by the Latin letters. How many distinct names are there among them, if two ambiguities described above are taken into account?

Formally, we assume that two words denote the same name, if using the replacements "u"  "oo" and "h"  "kh", you can make the words equal. One can make replacements in both directions, in any of the two words an arbitrary number of times. A letter that resulted from the previous replacement can participate in the next replacements.

For example, the following pairs of words denote the same name:

  • "koouper" and "kuooper". Making the replacements described above, you can make both words to be equal: "koouper"  "kuuper" and "kuooper"  "kuuper".
  • "khun" and "kkkhoon". With the replacements described above you can make both words to be equal: "khun"  "khoon" and "kkkhoon"  "kkhoon"  "khoon".

For a given list of words, find the minimal number of groups where the words in each group denote the same name.

Input

The first line contains integer number n (2 ≤ n ≤ 400) — number of the words in the list.

The following n lines contain words, one word per line. Each word consists of only lowercase Latin letters. The length of each word is between 1 and 20 letters inclusive.

Output

Print the minimal number of groups where the words in each group denote the same name.

Examples

input

Copy

10
mihail
oolyana
kooooper
hoon
ulyana
koouper
mikhail
khun
kuooper
kkkhoon

output

Copy

4

input

Copy

9
hariton
hkariton
buoi
kkkhariton
boooi
bui
khariton
boui
boi

output

Copy

5

input

Copy

2
alex
alex

output

Copy

1

Note

There are four groups of words in the first example. Words in each group denote same name:

  1. "mihail", "mikhail"
  2. "oolyana", "ulyana"
  3. "kooooper", "koouper"
  4. "hoon", "khun", "kkkhoon"

There are five groups of words in the second example. Words in each group denote same name:

  1. "hariton", "kkkhariton", "khariton"
  2. "hkariton"
  3. "buoi", "boooi", "boui"
  4. "bui"
  5. "boi"

In the third example the words are equal, so they denote the same name.

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int n;
int main()
{while(cin>>n){string s;set st;while(n--){cin>>s;for(int i=s.length(); i>=0; i--){if(s[i]=='u')s.replace(i,1,"oo");else if(s[i]=='k'&&s[i+1]=='h')s.replace(i,2,"h");}st.insert(s);}cout<

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部