#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;

	vector<int> a;
	vector<int> b;
	vector<int> c;

	for(int i=0;i<n;i++) {
	    int x,y;
	    cin >> x >> y;

	    a.push_back(x);
	    b.push_back(y);
	    c.push_back(0);
	}
	c.push_back(0);
	for(int i=0;i<n;i++) {
	   // if(a[i] != b[i] && b[i] <= n)
	        c[b[i]]++;
	}

	int count = 0;
	for(int i=0;i<n;i++) {
	    c[b[i]] -= 1;
	    if(c[a[i]] == 0)
	        count++;

	    c[b[i]] += 1;
	}

	cout << count << endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;

	vector<int> a1;
	vector<int> b1;
	vector<int> c1;

	for(int i=0;i<n;i++) {
	    int x,y;
	    cin >> x >> y;

	    a1.push_back(x);
	    b1.push_back(y);
	    c1.push_back(0);
	}
// 	c.push_back(0);
	for(int i=0;i<n;i++) {
	    if(a1[i] != b1[i])
	        c1[b1[i]-1]++;
	}

	int count = 0;
	for(int i=0;i<n;i++) {
	    if(c1[a1[i]-1] == 0)
	        count++;
	}

	cout << count << endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;

	vector<int> a;
	vector<int> b;
	vector<int> c;

	for(int i=0;i<n;i++) {
	    int x,y;
	    cin >> x >> y;

	    a.push_back(x);
	    b.push_back(y);
	    c.push_back(0);
	}

	for(int i=0;i<n;i++) {
	    if(a[i] != b[i])
	        c[b[i]-1]++;
	}

	int count = 0;
	for(int i=0;i<n;i++) {
	    if(c[i] == 0)
	        count++;
	}

	cout << count << endl;
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n, a[1000], b[1000], c[1001] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d%d", &a[i], &b[i]);
        c[b[i]] += 1;
    }
    int count = 0;
    for (int i = 0; i < n; ++i)
    {
        c[b[i]] -= 1;
        if (c[a[i]] == 0)
        {
            count += 1;
        }
        c[b[i]] += 1;
    }
    printf("%d\n", count);
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;

	vector<int> a;
	vector<int> b;

	for(int i=0;i<n;i++) {
	    int x,y;
	    cin >> x >> y;
	    a.push_back(x);
	    b.push_back(y);
	}

	for(int i=0;i<n;i++) {
	    if(b[i] != a[i] && b[i] <= n && a[b[i]-1] > 0){
	        a[b[i]-1] *= -1;
	    }
	}

	int count = 0;
	for(int i=0;i<n;i++) {
	    if(a[i] > 0)
	        count++;
	}

	cout << count << endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;

	vector<int> a1;
	vector<int> b1;
	int c1[1001] = {0};

	for(int i=0;i<n;i++) {
	    int x,y;
	    cin >> x >> y;

	    a1.push_back(x);
	    b1.push_back(y);
	   // c1.push_back(0);
	}

	for(int i=0;i<n;i++) {
	    if(a1[i] != b1[i])
	        c1[b1[i]-1]++;
	}

	int count = 0;
	for(int i=0;i<n;i++) {
	    if(c1[a1[i]-1] == 0)
	        count++;
	}

	cout << count << endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;

	vector<int> a;
	vector<int> b;
	vector<int> c;

	for(int i=0;i<n;i++) {
	    int x,y;
	    cin >> x >> y;

	    a.push_back(x);
	    b.push_back(y);
	    c.push_back(0);
	}

	for(int i=0;i<n;i++) {
	    if(a[i] != b[i])
	        c[b[i]]++;
	}

	int count = 0;
	for(int i=0;i<n;i++) {
	   // c[b[i]] -= 1;
	    if(c[a[i]] == 0)
	        count++;

	   // c[b[i]] += 1;
	}

	cout << count << endl;
	return 0;
}


import java.util.*;
import java.io.*;

public class Main143B
{
  static PrintWriter out=new PrintWriter(System.out);

  public static void main(String[] args) throws IOException
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String ans="";
    boolean bracket=false;
    boolean dot=false;
    int m=0;
    int dotp=0;
    int i=0;
    for(i=0;i<s.length();i++)
    {
      if(s.charAt(i)=='.')
      {
        dotp=i;
        m=s.length()-i-1;
        dot=true;
        break;
      }
    }

    if(s.charAt(0)=='-')
    {
      bracket=true;
      ans="(";
    }
    ans+="$";
    if(bracket)
      i-=1;
    int x=i%3;
    int k=i/3;
    if(x==0)
    {
      x=3;
      k=k-1;
    }
    if(bracket) ans+=s.substring(1,x+1);
    else
      ans+=s.substring(0,x);
    for(int j=0;j<k;j++)
    {
      ans+=",";
      ans+=s.substring(x,x+3);
      x+=3;
    }

    if(!dot)
    {
      ans+=".00";
    }
    else
    {
      ans+=".";
      if(m>1)
        ans+=s.substring(dotp+1,dotp+3);
      else
      {
        ans+=s.substring(dotp+1,dotp+2);
        ans+="0";
      }
    }
    if(bracket) ans+=")";
    out.println(ans);
    out.flush();

  }
  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is)
        {
      br=new BufferedReader(new InputStreamReader(is));
    }
        public int nextInt() throws IOException
        {
          if(tk.hasMoreTokens())
                return Integer.parseInt(tk.nextToken());
          tk=new StringTokenizer(br.readLine());
          return nextInt();
        }
        public long nextLong() throws IOException
        {
            if(tk.hasMoreTokens())
              return Long.parseLong(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextLong();
        }
        public String next() throws IOException
        {
          if(tk.hasMoreTokens())
            return (tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return next();
        }
        public String nextLine() throws IOException
        {
          tk=new StringTokenizer("");
          return br.readLine();
        }
        public double nextDouble() throws IOException
        {
            if(tk.hasMoreTokens())
              return Double.parseDouble(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextDouble();
        }
        public char nextChar() throws IOException
        {
            if(tk.hasMoreTokens())
              return (tk.nextToken().charAt(0));
            tk=new StringTokenizer(br.readLine());
            return nextChar();
        }
        public int[] nextIntArray(int n) throws IOException
        {
            int a[]=new int[n];
            for(int i=0;i<n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArray(int n) throws IOException
        {
          long a[]=new long[n];
            for(int i=0;i<n;i++)
              a[i]=nextLong();
            return a;
        }
        public int[] nextIntArrayOneBased(int n) throws IOException
        {
          int a[]=new int[n+1];
            for(int i=1;i<=n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArrayOneBased(int n) throws IOException
        {
          long a[]=new long[n+1];
          for(int i=1;i<=n;i++)
                a[i]=nextLong();
          return a;
        }
  }
}


import java.math.BigDecimal;
import java.util.Scanner;

public class B143 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        BigDecimal input = new BigDecimal(in.next()).movePointRight(2);
        boolean negative = input.compareTo(BigDecimal.ZERO) < 0;
        String numbers = input.abs().toBigInteger().toString();
        while (numbers.length() < 3) {
            numbers = '0' + numbers;
        }
        String intPart = numbers.substring(0, numbers.length()-2);
        String frPart = numbers.substring(numbers.length()-2);
        StringBuilder sb = new StringBuilder();
        if (negative) {
            sb.append('(');
        }
        sb.append('$');
        for (int i=0; i<intPart.length(); i++) {
            sb.append(intPart.charAt(i));
            int digitsBehind = intPart.length()-1-i;
            if (digitsBehind%3 == 0) {
                sb.append(digitsBehind == 0 ? '.' : ',');
            }
        }
        sb.append(frPart);
        if (negative) {
            sb.append(')');
        }
        System.out.println(sb);
    }

}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
    public static void main(String[] args) {
        FastScanner sc =new FastScanner();
        StringBuilder out=new StringBuilder();
        String s=sc.next();
        String str[]=new String[2];
        int i=0;
        str[0]="";
        str[1]="";
        while( i<s.length() && s.charAt(i)!='.' ){
            str[0]+=s.charAt(i);
            i++;
        }
        i++;
        while(i<s.length()){
            str[1]+=s.charAt(i);
            i++;
        }

        int count=1;
        out.append('$');
        StringBuilder st=new StringBuilder();
        for(i=str[0].length()-1;i>=0;i--){
            if(str[0].charAt(i)=='-') continue;
            st.append(str[0].charAt(i));
            if(count%3==0 && !(i==0||(i==1 && str[0].charAt(i-1)=='-'))){
                st.append(',');
            }
            count++;
        }
        out.append(st.reverse());
        out.append(".00");
        for(i=0;i<str[1].length() && i<2;i++){
            out.setCharAt(out.length()-2+i,str[1].charAt(i));
        }
        if(str[0].charAt(0)=='-'){
            System.out.println("("+out+")");
        }
        else{
            System.out.println(out);
        }
    }
}

class FastScanner{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st =new StringTokenizer("");
    String next(){
        if(!st.hasMoreTokens()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(Exception e){
            }
        }
        return st.nextToken();
    }
    int nextInt(){
        return Integer.parseInt(next());
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
    public static void main(String[] args) {
        FastScanner sc =new FastScanner();
        StringBuilder out=new StringBuilder();
        String s=sc.next();
        String str[]=new String[2];
        int i=0;
        str[0]="";
        str[1]="";
        while( i<s.length() && s.charAt(i)!='.' ){
            str[0]+=s.charAt(i);
            i++;
        }
        i++;
        while(i<s.length()){
            str[1]+=s.charAt(i);
            i++;
        }

        int count=1;
        out.append('$');
        StringBuilder st=new StringBuilder();
        for(i=str[0].length()-1;i>=0;i--){
            if(str[0].charAt(i)=='-') continue;
            st.append(str[0].charAt(i));
            if(count%3==0){
                st.append(',');
            }
            count++;
        }
        out.append(st.reverse());
        out.append(".00");
        for(i=0;i<str[1].length() && i<2;i++){
            out.setCharAt(out.length()-2+i,str[1].charAt(i));
        }
        if(str[0].charAt(0)=='-'){
            System.out.println("("+out+")");
        }
        else{
            System.out.println(out);
        }
    }
}

class FastScanner{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st =new StringTokenizer("");
    String next(){
        if(!st.hasMoreTokens()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(Exception e){
            }
        }
        return st.nextToken();
    }
    int nextInt(){
        return Integer.parseInt(next());
    }
}


/**
 *  Platform    :   Codeforces
 *  Url         :   http://codeforces.com/problemset/problem/143/B
 *  Verdict     :   Accepted
 */

import java.util.Scanner;

public class HelpKingdomofFarFarAway2{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        String number = scan.nextLine();
        int len = number.length();

        Boolean neg = false, decimal = false;
        int decimal_at;
        int decimal_part_count=0;
        int cnt = 0;
        int total_integral_part = 0;

        if(number.charAt(0)=='-'){
            neg = true;
        }

        for(int i = 0; i < len; i++){
            if(number.charAt(i) == '.'){
                decimal = true;
                total_integral_part = cnt;
                decimal_at = i;
                cnt=0;
            }
            else{
                ++cnt;
            }
        }
        if(decimal == false){
            total_integral_part = cnt;
        }
        else{
            decimal_part_count = cnt;
        }
        String res = "";
        int p = 0;
        if(neg==true){
            res += "(";
            p++;
        }

        res += "$";

       // System.out.println(total_integral_part);
        int c = total_integral_part % 3;

        if(c == 1 && total_integral_part > 3){
            res += number.charAt(p);
            res += ",";
            p++;
        }
        if(c == 2 && total_integral_part > 3){
            res += number.charAt(p);
            p++;
            res += number.charAt(p);
            res += ",";
            p++;
        }
        int t = 0;
        while(p < total_integral_part){
            if(t == 3 && p < total_integral_part-1){
                res += ",";
                t = 0;
            }
            res += number.charAt(p);
            t++;
            p++;
        }

            p++;
            res += ".";
            if(decimal_part_count == 0){
                res += "00";
            }
            if(decimal_part_count == 1){
                res += number.charAt(p);
                res += "0";
            }
            if(decimal_part_count >= 2){
                res += number.charAt(p);
                p++;
                res += number.charAt(p);
            }

        if(neg == true)
            res += ")";
        System.out.println(res);

    }
}


/**
 *  Platform    :   Codeforces
 *  Url         :   http://codeforces.com/problemset/problem/143/B
 *  Verdict     :   Accepted
 */

import java.util.Scanner;

public class HelpKingdomofFarFarAway2{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        String number = scan.nextLine();
        int len = number.length();

        Boolean neg = false, decimal = false;
        int decimal_at;
        int decimal_part_count=0;
        int cnt = 0;
        int total_integral_part = 0;

        for(int i = 0; i < len; i++){
            if(number.charAt(i) == '-'){
                neg = true;
                continue;
            }
            if(number.charAt(i) == '.'){
                decimal = true;
                total_integral_part = cnt;
                decimal_at = i;
                cnt=0;
            }
            else{
                ++cnt;
            }
        }
        if(decimal == false){
            total_integral_part = cnt;
        }
        else{
            decimal_part_count = cnt;
        }
        String res = "";
        int p = 0;
        int c = total_integral_part % 3;
        if(neg==true){
            res += "(";
            p++;
            total_integral_part++;
        }

        res += "$";

       // System.out.println(total_integral_part);

        if(c == 1 && total_integral_part > 3){
            res += number.charAt(p);
            res += ",";
            p++;
        }
        if(c == 2 && total_integral_part > 3){
            res += number.charAt(p);
            p++;
            res += number.charAt(p);
            res += ",";
            p++;
        }
        int t = 0;
        while(p < total_integral_part){
            if(t == 3 && p < total_integral_part-1){
                res += ",";
                t = 0;
            }
            res += number.charAt(p);
            t++;
            p++;
        }

            p++;
            res += ".";
            if(decimal_part_count == 0){
                res += "00";
            }
            if(decimal_part_count == 1){
                res += number.charAt(p);
                res += "0";
            }
            if(decimal_part_count >= 2){
                res += number.charAt(p);
                p++;
                res += number.charAt(p);
            }

        if(neg == true)
            res += ")";
        System.out.println(res);

    }
}


/**
 *  Platform    :   Codeforces
 *  Url         :   http://codeforces.com/problemset/problem/143/B
 *  Verdict     :   Accepted
 */

import java.util.Scanner;

public class HelpKingdomofFarFarAway2{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        String number = scan.nextLine();
        int len = number.length();

        Boolean neg = false, decimal = false;
        int decimal_at;
        int cnt = 0;
        int total_integral_part = 0;

        if(number.charAt(0)=='-'){
            neg = true;
        }

        for(int i = 0; i < len; i++){
            if(number.charAt(i) == '.'){
                decimal = true;
                total_integral_part = cnt;
                decimal_at = i;
                cnt=0;
            }
            else{
                ++cnt;
            }
        }
        if(decimal == false){
            total_integral_part = cnt;
        }
        String res = "";
        int p = 0;
        if(neg==true){
            res += "(";
            p++;
        }

        res += "$";

       // System.out.println(total_integral_part);
        int c = total_integral_part % 3;

        if(c == 1 && total_integral_part > 3){
            res += number.charAt(p);
            res += ",";
            p++;
        }
        if(c == 2 && total_integral_part > 3){
            res += number.charAt(p);
            p++;
            res += number.charAt(p);
            res += ",";
            p++;
        }
        int t = 0;
        while(p < total_integral_part){
            if(t == 3 && p < total_integral_part-1){
                res += ",";
                t = 0;
            }
            res += number.charAt(p);
            t++;
            p++;
        }
        if(decimal == true){
            p++;
            res += ".";
            if(cnt == 0){
                res += "00";
            }
            if(cnt == 1){
                res += number.charAt(p);
                res += "0";
            }
            if(cnt >= 2){
                res += number.charAt(p);
                p++;
                res += number.charAt(p);
            }
        }
        if(neg == true)
            res += ")";
        System.out.println(res);

    }
}


import java.util.*;

import java.io.*;

public class Watermelon {
	static int x;
	public static void main(String[] args) throws IOException {
	       Scanner sc=new Scanner(System.in);
	       //Integer n=sc.nextInt();
	       int flag=0;
	       String s=sc.next();
	       ArrayList<Character> list=new ArrayList<>();
	       for(int i=0;i<s.length();i++)
	    	   list.add(s.charAt(i));
	       for(int i=0;i<list.size();i++){
	    	   if(list.get(i)=='.'){
	    		   flag=1;
	    		   if(list.size()==i+2)
	    			   flag=2;
	    		   for(int j=i+3;j<list.size();)
	    			   {
	    			  // System.out.println(list.get(j));
	    			   list.remove(j);
	    			   }
	    		   break;
	    	   }

	       }
	       for(int i=0;i<list.size();i++){
	    	   if(flag==0){
	    		   list.add('.');
	    		   list.add('0');
	    		   list.add('0');
	    		   break;
	    	   }
	    	   if(flag==2)
	    		   {list.add('0');break;}

	       }
	       int x=0;
	       for(int i=0;i<list.size();i++){
	    	 if(list.get(i)=='.')
	    		 {x=i;break;}
	       }
	       int count=0;int f1=0;
	       for(int i=x-1;i>=0;i--){

	    	   if(count==2){

	    		   list.add(i, ',');
	            	count=0;
	            	i--;
	            	f1=1;
	    	   }
	    	   count++;
	       }
	       if(list.get(0)==',')
	    	   list.remove(0);
	       if(list.get(0)=='-')
	       {   list.set(0, '(');list.add(')');list.add(1,'$');}
	       else
	    	   list.add(0,'$');

	      // System.out.println(list);
	       for(int i=0;i<list.size();i++){
	    	   System.out.print(list.get(i));
	    	}
	       System.out.println();

	}

	private static int gcd(int a, int b)
	{
	    while (b > 0)
	    {
	    	int temp = b;
	        b = a % b; // % is remainder
	        a = temp;
	    }
	    return a;
	}
	private static int lcm(int a, int b)
	{
	    return a * (b / gcd(a, b));
	}
	static int[] toFractionPos(int x,int y){
		int a=gcd(x,y);
		int[] arr={x/a,y/a};
		//display(arr);
		return arr;
	}

	static void display(int[][] arr){
		for(int i=0;i<arr.length;i++){
			for(int j=0;j<arr[i].length;j++){
				System.out.print(arr[i][j]+" ");
			}
			System.out.println();
		}
		System.out.println();
	}

	 static void display(String[] arr){
			for(int i=0;i<arr.length;i++){

			}
			System.out.println();

	 }

		 static void display(int[] arr){
			 for(int i=0;i<arr.length;i++)
				 System.out.print(arr[i]+" ");
			 System.out.println();
		 }
	 static void display(double[] arr){
		// System.out.println();
			for(int i=0;i<arr.length;i++){
				System.out.println(arr[i]+" ");
			}
//			System.out.println();

		  }
	 static String str(char[] carr){
		 String str="";
		 for(int i=0;i<carr.length;i++){
			    str=str+carr[i];
			}
		 return str;
	 }

	}
class Count{
	int i;
	ArrayList<Integer> list=new ArrayList<>();
	Count(int i,int c){
		this.i=i;
		list.add(c);
	}
	Count(int i){
		this.i=i;
	}
	void display(){
		Integer[] arr=list.toArray(new Integer[list.size()]);
		Arrays.sort(arr);
	}
}


import java.util.*;

import java.io.*;

public class Watermelon {
	static int x;
	public static void main(String[] args) throws IOException {
	       Scanner sc=new Scanner(System.in);
	       //Integer n=sc.nextInt();
	       int flag=0;
	       String s=sc.next();
	       ArrayList<Character> list=new ArrayList<>();
	       for(int i=0;i<s.length();i++)
	    	   list.add(s.charAt(i));
	       for(int i=0;i<list.size();i++){
	    	   if(list.get(i)=='.'){
	    		   flag=1;
	    		   if(list.size()==i+2)
	    			   flag=2;
	    		   for(int j=i+3;j<list.size();)
	    			   {
	    			  // System.out.println(list.get(j));
	    			   list.remove(j);
	    			   }
	    		   break;
	    	   }

	       }
	       for(int i=0;i<list.size();i++){
	    	   if(flag==0){
	    		   list.add('.');
	    		   list.add('0');
	    		   list.add('0');
	    		   break;
	    	   }
	    	   if(flag==2)
	    		   {list.add('0');break;}

	       }
	       int x=0;
	       for(int i=0;i<list.size();i++){
	    	 if(list.get(i)=='.')
	    		 {x=i;break;}
	       }
	       int count=0;int f1=0;
	       for(int i=x-1;i>=0;i--){

	    	   if(count==2){

	    		   list.add(i, ',');
	            	count=0;
	            	i--;
	            	f1=1;
	    	   }
	    	   count++;
	       }
	     //  System.out.println(list.get(0));
	       if(list.get(0)=='-')
	    	   if(list.get(1)==',')
	    		   list.remove(1);
	       if(list.get(0)==',')
	    	   {
	    	   //System.out.println(list.get(0));
	    	   list.remove(0);
	    	   }
	       if(list.get(0)=='-')
	       {   list.set(0, '(');list.add(')');list.add(1,'$');}
	       else
	    	   list.add(0,'$');

	      // System.out.println(list);
	       for(int i=0;i<list.size();i++){
	    	   System.out.print(list.get(i));
	    	}
	       System.out.println();

	}

	private static int gcd(int a, int b)
	{
	    while (b > 0)
	    {
	    	int temp = b;
	        b = a % b; // % is remainder
	        a = temp;
	    }
	    return a;
	}
	private static int lcm(int a, int b)
	{
	    return a * (b / gcd(a, b));
	}
	static int[] toFractionPos(int x,int y){
		int a=gcd(x,y);
		int[] arr={x/a,y/a};
		//display(arr);
		return arr;
	}

	static void display(int[][] arr){
		for(int i=0;i<arr.length;i++){
			for(int j=0;j<arr[i].length;j++){
				System.out.print(arr[i][j]+" ");
			}
			System.out.println();
		}
		System.out.println();
	}

	 static void display(String[] arr){
			for(int i=0;i<arr.length;i++){

			}
			System.out.println();

	 }

		 static void display(int[] arr){
			 for(int i=0;i<arr.length;i++)
				 System.out.print(arr[i]+" ");
			 System.out.println();
		 }
	 static void display(double[] arr){
		// System.out.println();
			for(int i=0;i<arr.length;i++){
				System.out.println(arr[i]+" ");
			}
//			System.out.println();

		  }
	 static String str(char[] carr){
		 String str="";
		 for(int i=0;i<carr.length;i++){
			    str=str+carr[i];
			}
		 return str;
	 }

	}
class Count{
	int i;
	ArrayList<Integer> list=new ArrayList<>();
	Count(int i,int c){
		this.i=i;
		list.add(c);
	}
	Count(int i){
		this.i=i;
	}
	void display(){
		Integer[] arr=list.toArray(new Integer[list.size()]);
		Arrays.sort(arr);
	}
}


import java.io.*;
import java.util.*;

public class HelpKingdomOfFarFarAway2_143B {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		boolean minus = false;
		if (input.charAt(0) == '-')
			minus = true;
		if (minus)
			input = input.substring(1);
		String integer = "";
		String decimal = "00";
		StringTokenizer st = new StringTokenizer(input, ".");
		integer = st.nextToken();
		if (st.hasMoreTokens())
			decimal = st.nextToken();
		StringBuilder res = new StringBuilder();
		if (minus)
			res.append('(');
		res.append('$');
		if (new Integer(integer) != 0) {
			Stack<Character> s = new Stack<>();
			int count = 0;
			for (int i = integer.length() - 1; i >= 0; i--) {
				s.push(integer.charAt(i));
				count++;
				if (count % 3 == 0 && i != 0) {
					s.push(',');
					count = 0;
					// System.out.println(s.size());
				}
				// System.out.println(s.size());
			}
			while (!s.isEmpty())
				res.append(s.pop());
		}else
			res.append(0);
		res.append('.');
		if (decimal.length() > 2)
			res.append(decimal.substring(0, 2));
		else {
			if (decimal.length() < 2)
				res.append(decimal + "0");
			else
				res.append(decimal);
		}
		if (minus)
			res.append(')');
		System.out.println(res.toString());
		// System.out.println(integer);
		// System.out.println(decimal);

	}

}


import java.io.*;
import java.util.*;

public class HelpKingdomOfFarFarAway2_143B {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		boolean minus = false;
		if (input.charAt(0) == '-')
			minus = true;
		if (minus)
			input = input.substring(1);
		String integer = "";
		String decimal = "00";
		StringTokenizer st = new StringTokenizer(input, ".");
		integer = st.nextToken();
		if (st.hasMoreTokens())
			decimal = st.nextToken();
		StringBuilder res = new StringBuilder();
		if (minus)
			res.append('(');
		res.append('$');
		if (new Integer(integer) != 0) {
			Stack<Character> s = new Stack<>();
			int count = 0;
			for (int i = integer.length() - 1; i >= 0; i--) {
				s.push(integer.charAt(i));
				count++;
				if (count % 3 == 0) {
					s.push(',');
					count = 0;
					// System.out.println(s.size());
				}
				// System.out.println(s.size());
			}
			while (!s.isEmpty())
				res.append(s.pop());
		}else
			res.append(0);
		res.append('.');
		if (decimal.length() > 2)
			res.append(decimal.substring(0, 2));
		else {
			if (decimal.length() < 2)
				res.append(decimal + "0");
			else
				res.append(decimal);
		}
		if (minus)
			res.append(')');
		System.out.println(res.toString());
		// System.out.println(integer);
		// System.out.println(decimal);

	}

}


import java.io.*;
import java.util.*;

public class HelpKingdomOfFarFarAway2_143B {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		boolean minus = false;
		if (input.charAt(0) == '-')
			minus = true;
		if (minus)
			input = input.substring(1);
		String integer = "";
		String decimal = "00";
		StringTokenizer st = new StringTokenizer(input, ".");
		integer = st.nextToken();
		if (st.hasMoreTokens())
			decimal = st.nextToken();
		StringBuilder res = new StringBuilder();
		if (minus)
			res.append('(');
		res.append('$');
		if (input.charAt(0) != 0) {
			Stack<Character> s = new Stack<>();
			int count = 0;
			for (int i = integer.length() - 1; i >= 0; i--) {
				s.push(integer.charAt(i));
				count++;
				if (count % 3 == 0 && i != 0) {
					s.push(',');
					count = 0;
					// System.out.println(s.size());
				}
				// System.out.println(s.size());
			}
			while (!s.isEmpty())
				res.append(s.pop());
		}else
			res.append(0);
		res.append('.');
		if (decimal.length() > 2)
			res.append(decimal.substring(0, 2));
		else {
			if (decimal.length() < 2)
				res.append(decimal + "0");
			else
				res.append(decimal);
		}
		if (minus)
			res.append(')');
		System.out.println(res.toString());
		// System.out.println(integer);
		// System.out.println(decimal);

	}

}


import java.util.*;

public class Main {

   public static int indexOfDec( String a){
      int length = a.length();
      int indexOfDec = a.length();
      for(int i = 0; i < length;i++){
         if( a.charAt(i) == '.'){
            indexOfDec = i;
         }
      }
      return indexOfDec;
   }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String number = scan.next();
		String total = "";
      int indexOfDecimal = indexOfDec(number);

		int count = 0;
		for(int i = indexOfDecimal-1; i >= 0; i--){
			if(number.charAt(i) == '-'){
            break;
         }
			count++;

			total = number.charAt(i) + "" + total;
			if(count == 3){
				count = 0;
				total = "," + total;
			}
		}

		if(total.charAt(0) == ',') total = total.substring(1);
	   total += ".";
		count = 0;
		for(int i = indexOfDecimal+1; i < number.length(); i++){
			if(count == 2){
            break;
         }
         total += number.charAt(i);
			count++;
		}

		while(count < 2){
			total += "0";
         count++;
		}

		total = "$" + total;
		if(number.charAt(0) == '-'){
			total = "(" + total + ")";
		}

		System.out.println(total);

	}
}


import java.util.*;
import java.io.*;
import java.text.*;

public class Main {

  public static void main( String [] args ) throws IOException{
      Scanner scan = new Scanner(System.in);
      double num = scan.nextDouble();

      DecimalFormat decimal = new DecimalFormat("#.00");
      decimal.setGroupingUsed(true);
      decimal.setGroupingSize(3);

      if( num > 0){
         System.out.println( "$" + decimal.format(num));
      }else if( num == 0){
         System.out.println( "$0.00" );
      }else if( num < (0.009) ){
         System.out.println( "($0.00)" );
      }
      else{
         num *= (-1);
         System.out.println( "($" + decimal.format(num) + ")");
      }

  }
}


import java.util.*;
import java.io.*;
import java.text.*;

public class Main {

  public static void main( String [] args ) throws IOException{
      Scanner scan = new Scanner(System.in);
      double num = scan.nextDouble();

      DecimalFormat decimal = new DecimalFormat("#.00");
      decimal.setGroupingUsed(true);
      decimal.setGroupingSize(3);

      if( num > 0){
         System.out.println( "$" + decimal.format(num));
      }else if( num == 0){
         System.out.println( "$0.00" );
      }else{
         num *= (-1);
         System.out.println( "($" + decimal.format(num) + ")");
      }

  }
}


import java.util.*;
import java.io.*;
import java.text.*;

public class Main {

  public static void main( String [] args ) throws IOException{
      Scanner scan = new Scanner(System.in);
      double num = scan.nextDouble();

      DecimalFormat decimal = new DecimalFormat("#.00");
      decimal.setGroupingUsed(true);
      decimal.setGroupingSize(3);

      if( num > 0){
         System.out.println( "$" + decimal.format(num));
      }else{
         num *= (-1);
         System.out.println( "($" + decimal.format(num) + ")");
      }

  }
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Problem56 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out =new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader ();
		String str=s.next();
		boolean minus=positive(str);
		StringBuilder integer=IntegralPart(str);
		StringBuilder fraction=FractionalPart(str);
		StringBuilder finalans=new StringBuilder("");
		if(!minus)finalans.append("(");
		finalans.append("$"+integer+".");
		finalans.append(fraction);
		if(!minus)finalans.append(")");
		out.println(finalans);
		out.close();
	}

	public static boolean positive(String str) {
		return str.charAt(0)!='-';
	}

	public static StringBuilder IntegralPart(String str) {
		StringBuilder integer=new StringBuilder ("");
		for(int i=0;i<str.length();i++) {
			if(str.charAt(i)=='.') {
				break;
			}else if(str.charAt(i)=='-') {

			}else {
				integer.append(str.charAt(i));
			}
		}
		if(integer.length()==0) {
			integer.append(0);
			return integer;
		}
		StringBuilder ans2=new StringBuilder ("");
		int offset=integer.length()-3*(integer.length()/3);
		for(int i=0;i<integer.length();i++) {
			if(offset==0) {
				ans2.append(integer.charAt(i));
				offset=2;
			}
			else {
				if(offset==1) {
					ans2.append(integer.charAt(i));
					if(i>=integer.length()-3 && i<integer.length()) {

					}else {
						ans2.append(",");
					}
					offset=0;
				}else {
					offset--;
					ans2.append(integer.charAt(i));
				}
			}
		}
		return ans2;
	}

	public static StringBuilder FractionalPart(String str) {
		boolean hitdot=false;
		int size=0;
		StringBuilder ans=new StringBuilder ("");
		for(int i=0;i<str.length();i++) {
			if(hitdot && size<2) {
				size++;
				ans.append(str.charAt(i));
			}else if(str.charAt(i)=='.') {
				hitdot=true;
			}
			if(size==2) {
				break;
			}
		}
		if(size==2) {
			return ans;
		}else if(size==1) {
			ans.append(0);
			return ans;
		}else {
			ans.append("00");
			return ans;
		}
	}

	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.*;
import java.util.*;
public class code {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		int dot=-1,count=0;
		String temp="",str="";
		if(s.charAt(0)=='-'){
			for(int i=0;i<s.length();i++){
				if(s.charAt(i)=='.') dot=i;
			}
			if(dot!=-1){
			for(int i=dot+1;i<dot+3 && i<s.length();i++)
				temp=temp+s.charAt(i);
			for(int i=dot-1;i>=1;i--){
				count++;
				str+=s.charAt(i);
				if(count==3 && i!=1){
					str+=",";
					count=0;
				}

			}

			}
			else{
				temp=temp+"00";
				for(int i=s.length()-1;i>=1;i--){
					count++;
					str+=s.charAt(i);
					if(count==3 && i!=1){
						str+=",";
						count=0;
					}
			}
			}
			String reverse = "";
			int length = str.length();
			for( int i = length - 1 ; i >= 0 ; i-- ) {
			       reverse = reverse + str.charAt(i);
			    }
			if(temp.length()==2)
				System.out.println("($"+reverse+"."+temp+")");
			else
				System.out.println("($"+reverse+"."+temp+"0)");

		}
		else{
			for(int i=0;i<s.length();i++){
				if(s.charAt(i)=='.') dot=i;
			}
			if(dot!=-1){
			for(int i=dot+1;i<dot+3 && i<s.length();i++)
				temp=temp+s.charAt(i);
			for(int i=dot-1;i>=0;i--){
				count++;
				str+=s.charAt(i);
				if(count==3 &&  i!=-0){
					str+=",";
					count=0;
				}
			}
			}
			else{
				temp=temp+"00";
				for(int i=s.length()-1;i>=0;i--){
					count++;
					str+=s.charAt(i);
					if(count==3 && i!=-0){
						str+=",";
						count=0;
					}
			}
			}
			String reverse = "";
			int length = str.length();
			for( int i = length - 1 ; i >= 0 ; i-- ) {
				    reverse = reverse + str.charAt(i);
			}
			if(temp.length()==2)
				System.out.println("$"+reverse+"."+temp);
			else
				System.out.println("$"+reverse+"."+temp+"0");

		}
	}
}


import java.io.*;
import java.util.*;
public class code {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		int dot=-1,count=0;
		String temp="",str="";
		if(s.charAt(0)=='-'){
			for(int i=0;i<s.length();i++){
				if(s.charAt(i)=='.') dot=i;
			}
			if(dot!=-1){
			for(int i=dot+1;i<dot+3 && i<s.length();i++)
				temp=temp+s.charAt(i);
			for(int i=dot-1;i>=1;i--){
				count++;
				str+=s.charAt(i);
				if(count==3){
					str+=",";
					count=0;
				}
			}
			}
			else{
				temp=temp+"00";
				for(int i=s.length()-1;i>=1;i--){
					count++;
					str+=s.charAt(i);
					if(count==3){
						str+=",";
						count=0;
					}
			}
			}
			String reverse = "";
			int length = str.length();
			for( int i = length - 1 ; i >= 0 ; i-- ) {
			       reverse = reverse + str.charAt(i);
			    }
			if(temp.length()==2)
				System.out.println("($"+reverse+"."+temp+")");
			else
				System.out.println("($"+reverse+"."+temp+"0)");

		}
		else{
			for(int i=0;i<s.length();i++){
				if(s.charAt(i)=='.') dot=i;
			}
			if(dot!=-1){
			for(int i=dot+1;i<dot+3 && i<s.length();i++)
				temp=temp+s.charAt(i);
			for(int i=dot-1;i>=0;i--){
				count++;
				str+=s.charAt(i);
				if(count==3){
					str+=",";
					count=0;
				}
			}
			}
			else{
				temp=temp+"00";
				for(int i=s.length()-1;i>=0;i--){
					count++;
					str+=s.charAt(i);
					if(count==3){
						str+=",";
						count=0;
					}
			}
			}
			String reverse = "";
			int length = str.length();
			for( int i = length - 1 ; i >= 0 ; i-- ) {
				    reverse = reverse + str.charAt(i);
			}
			if(temp.length()==2)
				System.out.println("$"+reverse+"."+temp);
			else
				System.out.println("$"+reverse+"."+temp+"0");

		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in = br.readLine();
        StringBuilder b = new StringBuilder();
        boolean neg = false;
        int point = -1;
        int r = -1;
        for (int i = 0; i < in.length(); i++) {
            if (i == 0 && in.charAt(i) == '-') {
                neg = true;
                b.append("($");
            } else {
                if (i == 0)
                    b.append("$");
                if (in.charAt(i) == '.') {
                    point = i;
                    if (i <= in.length() - 3)
                        r = i;
                    break;
                }
                b.append(in.charAt(i));
            }
        }
        int s = b.length() - 3;
        if (point != -1) {
            s = point - 2;
        }
        int e = 1;
        if (neg)
            e++;
        for (int i = s; i > e; i -= 3) {
            b.insert(i, ',');
        }

        if (r != -1) {
            for (int i = r; i < r + 3; i++)
                b.append(in.charAt(i));
        } else {
            if (point == in.length() - 2) {
                b.append('.');
                b.append(in.charAt(point + 1));
                b.append('0');
            } else {

                b.append(".00");
            }
        }

        if (neg)
            b.append(")");
        System.out.println(b.toString());

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in = br.readLine();
        StringBuilder b = new StringBuilder();
        boolean neg = false;
        int point = -1;
        int r = -1;
        for (int i = 0; i < in.length(); i++) {
            if (i == 0 && in.charAt(i) == '-') {
                neg = true;
                b.append("($");
            } else {
                if (i == 0)
                    b.append("$");
                if (in.charAt(i) == '.') {
                    point = i;
                    if (i <= in.length() - 3)
                        r = i;
                    break;
                }
                b.append(in.charAt(i));
            }
        }
        int s = b.length() - 3;
        if (point != -1) {
            s = point - 2;
        }
        int e = 1;
        if (neg)
            e++;
        for (int i = s; i > e; i -= 3) {
            b.insert(i, ',');
        }
        // String[]p = null;
        //
        // if(point){
        // p= in.split(".");
        // }
        // System.out.println(in.split(".")[0]);
        // System.out.println(p[1]);
        if (r != -1) {
            for (int i = r; i < r + 3; i++)
                b.append(in.charAt(i));
        } else {
            b.append(".00");
        }

        if (neg)
            b.append(")");
        System.out.println(b.toString());

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author 1537869
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader input = new InputReader(inputStream);
        PrintWriter output = new PrintWriter(outputStream);

        String x = input.next();
        String[] ax = x.split("\\.");
        StringBuilder sb = new StringBuilder(ax[0]);
        boolean flag = false;
        if (sb.charAt(0) == '-') {
            flag = true;
            sb = new StringBuilder(sb.substring(1));
        }
        sb.reverse();
        int ins = 3;
        int sbLength = sb.length();
        for (int i = 0; i < (Math.ceil(sbLength / 3)); i++, ins += 4) {
            sb.insert(ins, ",");
        }
        String frac;
        if (ax.length == 2) {
            frac = ax[1];
            if (ax[1].length() == 1) {
                frac = frac + "0";
            } else {
                frac = frac.substring(0, 2);
            }
        } else {
            frac = "00";
        }
        sb.reverse();
        if (sb.charAt(0) == ',') {
            sb = new StringBuilder(sb.substring(1));
        }
        if (flag) {
            output.print("($" + sb + "." + frac + ")");
        } else {
            output.print("$" + sb + "." + frac);
        }
        output.close();

    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author 1537869
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader input = new InputReader(inputStream);
        PrintWriter output = new PrintWriter(outputStream);
        int n = input.nextInt();
        int m = input.nextInt();
        char[][] pw = new char[n][];
        for (int i = 0; i < n; i++) {
            pw[i] = input.next().toCharArray();
        }
        int counter = 0;
        for (int i = 0; i < pw.length; i++) {
            for (int j = 0; j < pw[i].length; j++) {
                if (pw[i][j] == 'W') {
                    if (j != 0) {
                        if (pw[i][j - 1] == 'P') {
                            pw[i][j - 1] = '.';
                            counter++;
                            continue;
                        }
                    }
                    if (i != 0) {
                        if (pw[i - 1][j] == 'P') {
                            pw[i - 1][j] = '.';
                            counter++;
                            continue;
                        }
                    }
                    if (i != pw.length - 1) {
                        if (pw[i + 1][j] == 'P') {
                            pw[i + 1][j] = '.';
                            counter++;
                            continue;
                        }
                    }
                    if (j != pw[i].length - 1) {
                        if (pw[i][j + 1] == 'P') {
                            pw[i][j + 1] = '.';
                            counter++;
                        }
                    }
                }
            }
        }
        output.println(counter);

        output.close();

    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}


/*
 ~/BAU/ACM-ICPC/Teams/Rampage/MMZA
 ~/sudo apt-get verdict Accepted
 practice...
*/
//package javaapplication1;

//import java.util.Scanner;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.*;

public class Main {
    static final int Mod=(int)1e9+7;
    static final int N=303;

    public static void main(String[] args) throws IOException {
       // Reader.init(System.in);
        //Scanner in=new Scanner(new FileInputStream("input.txt"));
        FastReader in=new FastReader();
        //in=new FileReader("input.txt");
        //PrintWriter out=new PrintWriter(new FileOutputStream("output.txt"));
        PrintWriter out=new PrintWriter(System.out);
        Main ob=new Main();
        String s=in.next();
        boolean neg=false;
        if(s.startsWith("-"))
            neg=true;

        String temp="";
        String dec="";
        if(s.contains("."))
        {
            int ind=s.indexOf(".");
            for(int i=0;i<ind;i++){
                if(s.charAt(i)=='-')continue;
                temp+=s.charAt(i);
            }
            for(int i=ind+1;i<Math.min(s.length(),ind+3);i++)
                dec+=s.charAt(i);
            if(dec.length()<2)
                dec+='0';
        }
        else {
            if(neg)
                temp=s.substring(1, s.length());
            else temp=s;
            dec="00";
        }
        String res="";
        for(int i=temp.length()-1;i>=0;i--){
          if(i>=3){
              res+=ob.reverse(temp.substring(i-2, i+1))+',';
              i-=2;
          }
          else {
              res+=temp.charAt(i);
          }
        }
        res=ob.reverse(res);
        res='$'+res+'.'+dec;
        if(neg)
            res='('+res+')';
        out.println(res);

        out.close();
    }
    String reverse(String s){
        String temp="";
        for(int i=s.length()-1;i>=0;i--)
            temp+=s.charAt(i);
        return temp;
    }
    String sort(String inputString)
    {
        ArrayList<Character> arr=new ArrayList();
        for(int i=0;i<inputString.length();i++)
            arr.add(inputString.charAt(i));
        Collections.sort(arr);
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<arr.size();i++)
            sb.append(arr.get(i));

        return sb.toString();
    }

    boolean next_permutation(int[] p, int len) {
        int a = len - 2;
        while (a >= 0 && p[a] >= p[a + 1]) {
            a--;
        }

        if (a == -1) {
            return false;
        }

        int b = len - 1;
        while (p[b] <= p[a]) {
            b--;
        }

        p[a] += p[b];
        p[b] = p[a] - p[b];
        p[a] -= p[b];

        for (int i = a + 1, j = len - 1; i < j; i++, j--) {
            p[i] += p[j];
            p[j] = p[i] - p[j];
            p[i] -= p[j];
        }

        return true;
    }
    int lower_bound(ArrayList<Integer> arr,int key) {
        int len = arr.size();
        int lo = 0;
        int hi = len-1;
        int mid = (lo + hi)/2;
        while (true) {
            int cmp = (arr.get(mid)==key?1:0);
            if (cmp == 0 || cmp > 0) {
                hi = mid-1;
                if (hi < lo)
                    return mid;
            } else {
                lo = mid+1;
                if (hi < lo)
                    return mid<len-1?mid+1:-1;
            }
            mid = (lo + hi)/2;
        }
    }
    int upper_bound(ArrayList<Integer> arr, int key) {
        int len = arr.size();
        int lo = 0;
        int hi = len-1;
        int mid = (lo + hi)/2;
        while (true) {
            int cmp = (arr.get(mid)==key?1:0);
            if (cmp == 0 || cmp < 0) {
                lo = mid+1;
                if (hi < lo)
                    return mid<len-1?mid+1:-1;
            } else {
                hi = mid-1;
                if (hi < lo)
                    return mid;
            }
            mid = (lo + hi)/2;
        }
    }
    int gcd(int a,int b){
        return b==0?a:gcd(b,a%b);
    }
    double area(ArrayList<Point> arr){
        double sum=0.0;
        for(int i=0;i<arr.size();i++){
            sum+=cross(arr.get(i),arr.get(((i+1)%(int)arr.size())));
        }
        return Math.abs(sum)/2.0;
    }
    double dot(Point p,Point q){
        return (p.x*q.x+p.y*q.y);
    }
    double cross(Point p,Point q){
        return (p.x*q.y-p.y*q.x);
    }
    Point computeLineIntersection(Point a,Point b,Point c,Point d){
        b=b.sub(a);d=c.sub(d);c=c.sub(a);
        return a.add(b.mulCon(cross(c,d)).devideCon(cross(b,d)));
    }
   static class FastReader
        {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}
class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    static void init(String url) throws FileNotFoundException {
        reader = new BufferedReader(new FileReader(url));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}
class Point{
    double x,y;
    Point(double _x,double _y){
        x=_x;
        y=_y;
    }
    Point add(final Point p){
        return new Point(x+p.x,y+p.y);
    }
    Point sub(final Point p){
        return new Point(x-p.x,y-p.y);
    }
    Point mulCon(final double c){
        return new Point(c*x,c*y);
    }
    Point devideCon(final double c){
        return new Point(x/c,y/c);
    }
}
class  pair implements Comparator<pair>{
    int x,y;
    pair(){}
    pair(int a,int b){
        x=a;
        y=b;
    }
    @Override
    public int compare(pair a,pair b){
        return a.x-b.x;
    }
}


import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		String no;
		int rem = 0;
		int flag = 0;
		int i = 0;

		Scanner sc = new Scanner(System.in);

		no = sc.nextLine();
		char[] s = new char[200];
		int a = 0;
		int j = 0;
		String[] arr = no.split("\\.");

		String firstNo = arr[0];
		String secondNo;
		if (arr.length == 1)
			secondNo = "00";
		else
			secondNo = arr[1];

		if (no.charAt(0) == '-') {
			flag = 1;
			s[0] = '(';
			s[1] = '$';
			j = 1;
			a = 2;
			rem = (arr[0].length() - 1) % 3;
		} else {
			s[0] = '$';
			a++;
			rem = arr[0].length() % 3;
		}

		int count = 3 - rem;

		for (i = j; i < arr[0].length(); i++) {
			s[a] = arr[0].charAt(i);
			a++;
			count++;
			if (count % 3 == 0 && i != (arr[0].length() - 1)) {
				s[a] = ',';
				a++;
			}

		}

		s[a] = '.';
		a++;
		s[a] = secondNo.charAt(0);
		a++;
		if (secondNo.length() > 1)
			s[a] = secondNo.charAt(1);
		else
			s[a] = '0';
		a++;
		if (flag == 1) {
			s[a] = ')';
			a++;
		}
		s[a] = '\0';
		for (j = 0; s[j] != '\0'; j++)
			System.out.print(s[j]);
		sc.close();
	}

}


import java.util.*;
import java.io.*;

public class Div2_143B {

	/**
	 * @author mohanad Elmaghrby
	 * @param args
	 * @throws IOException
	 */

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String word = bf.readLine();
		String ans ="";
		int len = word.length();
		int i ;
		for (i = len-1 ; i >=0 ; --i)
			if (word.charAt(i)=='.')
				break;
		ans = (i<0?".00":i==len-2?"."+word.charAt(i)+"0":"."+word.charAt(i)+word.charAt(i+1));

		if (i<0)
			i=len-1;
		int end=0;
		if (word.charAt(0)=='-')
			end=1;
		for ( int j = i , count=0; j>=end ; --j , ++count){
			ans =word.charAt(j)+ans;
			if (count%3==0 && count!=0)
				ans = ","+ans;
		}
		ans ="$"+ans;
		if (end==1)
			ans = "("+ans+")";
		System.out.println(ans);

	}

}


import java.io.*;

public class Div2_143B {

	/**
	 * @author mohanad Elmaghrby
	 * @param args
	 * @throws IOException
	 */

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String word = bf.readLine();
		String ans ="";
		int len = word.length();
		int i ;

		for (i = len-1 ; i >=0 ; --i)
			if (word.charAt(i)=='.')
				break;
		int end=0;
		if (word.charAt(0)=='-'){
			end=1;
                }
                ans = (i<0?".00":i==len-2?"."+word.charAt(i+1)+"0":"."+word.charAt(i+1)+word.charAt(i+2));

		--i;
		i = (i<0?len-1:i);
		for ( int j = i , count=0; j>=end ; --j , ++count){

			if (count%3==0 && count!=0)
				ans = ","+ans;
                        ans =word.charAt(j)+ans;
		}
		ans ="$"+ans;
		if (end==1)
			ans = "("+ans+")";
		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		Reader.init(System.in);
		String[] input = Reader.next().split("");
		List<String> individualChars = new ArrayList<String>(Arrays.asList(input));

		int indexOfDecimal = individualChars.indexOf(".");
		if (indexOfDecimal != -1 && individualChars.subList(indexOfDecimal + 1, individualChars.size()).size() > 2)
		{
			individualChars.subList(indexOfDecimal + 3, individualChars.size()).clear();
		}
		if (indexOfDecimal != -1 && !individualChars.get(individualChars.size() - 1).equals("0"))
		{
			individualChars.add("0");
		} else if (indexOfDecimal == -1)
		{
			individualChars.add(".");
			individualChars.add("0");
			individualChars.add("0");
		}
		if (individualChars.get(0).equals("-"))
		{
			individualChars.remove(0);
			individualChars.add(0, "(");
			individualChars.add(1, "$");
			individualChars.add(")");
		} else
		{
			individualChars.add(0, "$");
		}

		Collections.reverse(individualChars);
		indexOfDecimal = individualChars.indexOf(".");

		for (int i = indexOfDecimal + 4; i < individualChars.indexOf("$"); i = i + 4)
		{
			individualChars.add(i, ",");
		}

		Collections.reverse(individualChars);

		String output = "";
		for (int i = 0; i < individualChars.size(); i++)
		{
			output += individualChars.get(i);
		}

		System.out.println(output);
	}
}

class Reader
{
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	/** call this method to initialize reader for InputStream */
	static void init(InputStream input)
	{
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	/** get next word */
	static String next() throws IOException
	{
		while (!tokenizer.hasMoreTokens())
		{
			// TODO add check for eof if necessary
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	static int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}

	static double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}

	static long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}

	static float nextFloat() throws IOException
	{
		return Float.parseFloat(next());
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		Reader.init(System.in);
		String[] input = Reader.next().split("");
		List<String> individualChars = new ArrayList<String>(Arrays.asList(input));

		int indexOfDecimal = individualChars.indexOf(".");
		if (indexOfDecimal != -1 && individualChars.subList(indexOfDecimal + 1, individualChars.size()).size() > 2)
		{
			individualChars.subList(indexOfDecimal + 3, individualChars.size()).clear();
		}
		if (indexOfDecimal != -1 && !individualChars.get(individualChars.size() - 1).equals("0")
				&& individualChars.subList(indexOfDecimal + 1, individualChars.size()).size() < 2)
		{
			individualChars.add("0");
		} else if (indexOfDecimal == -1)
		{
			individualChars.add(".");
			individualChars.add("0");
			individualChars.add("0");
		}
		if (individualChars.get(0).equals("-"))
		{
			individualChars.remove(0);
			individualChars.add(0, "(");
			individualChars.add(1, "$");
			individualChars.add(")");
		} else
		{
			individualChars.add(0, "$");
		}

		Collections.reverse(individualChars);
		indexOfDecimal = individualChars.indexOf(".");

		for (int i = indexOfDecimal + 4; i < individualChars.indexOf("$"); i = i + 4)
		{
			individualChars.add(i, ",");
		}

		Collections.reverse(individualChars);

		String output = "";
		for (int i = 0; i < individualChars.size(); i++)
		{
			output += individualChars.get(i);
		}

		System.out.println(output);
	}
}

class Reader
{
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	/** call this method to initialize reader for InputStream */
	static void init(InputStream input)
	{
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	/** get next word */
	static String next() throws IOException
	{
		while (!tokenizer.hasMoreTokens())
		{
			// TODO add check for eof if necessary
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	static int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}

	static double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}

	static long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}

	static float nextFloat() throws IOException
	{
		return Float.parseFloat(next());
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		Reader.init(System.in);
		String[] input = Reader.next().split("");
		List<String> individualChars = new ArrayList<String>(Arrays.asList(input));

		int indexOfDecimal = individualChars.indexOf(".");
		if (indexOfDecimal != -1 && individualChars.subList(indexOfDecimal + 1, individualChars.size()).size() > 2)
		{
			individualChars.subList(indexOfDecimal + 3, individualChars.size()).clear();
		}
		if (indexOfDecimal != -1 && !individualChars.get(individualChars.size() - 1).equals("0")
				&& individualChars.subList(indexOfDecimal + 1, individualChars.size()).size() < 2)
		{
			individualChars.add("0");
		} else if (indexOfDecimal != -1
				&& individualChars.subList(indexOfDecimal + 1, individualChars.size()).size() == 1)
		{
			individualChars.add("0");

		} else if (indexOfDecimal == -1)
		{
			individualChars.add(".");
			individualChars.add("0");
			individualChars.add("0");
		}
		if (individualChars.get(0).equals("-"))
		{
			individualChars.remove(0);
			individualChars.add(0, "(");
			individualChars.add(1, "$");
			individualChars.add(")");
		} else
		{
			individualChars.add(0, "$");
		}

		Collections.reverse(individualChars);
		indexOfDecimal = individualChars.indexOf(".");

		for (int i = indexOfDecimal + 4; i < individualChars.indexOf("$"); i = i + 4)
		{
			individualChars.add(i, ",");
		}

		Collections.reverse(individualChars);

		String output = "";
		for (int i = 0; i < individualChars.size(); i++)
		{
			output += individualChars.get(i);
		}

		System.out.println(output);
	}
}

class Reader
{
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	/** call this method to initialize reader for InputStream */
	static void init(InputStream input)
	{
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	/** get next word */
	static String next() throws IOException
	{
		while (!tokenizer.hasMoreTokens())
		{
			// TODO add check for eof if necessary
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	static int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}

	static double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}

	static long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}

	static float nextFloat() throws IOException
	{
		return Float.parseFloat(next());
	}
}


import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by singh0777 on 5/11/17.
 */
public class Codeforces1022 {

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String n = s.next();
        ArrayList<String> arr = new ArrayList<String>();

        int flag = 0;
        if(n.charAt(0)=='-'){
            flag=1;
            n = n.substring(1);
        }

        arr.add(n.split("\\.")[0]);

        if(n.split("\\.").length<2){
            arr.add("00");
        }else{
            String temp =  n.split("\\.")[1];
            if(temp.length()>2){
                temp = temp.substring(0,2);
            }else if(temp.length()==1){
                temp = temp + "0";
            }else if(temp.length()==0){
                temp = temp + "00";
            }
            arr.add(temp);
        }

        String x = arr.get(0);
        int l = x.length();
        String my = "";

        if(l%3==0){
            for (int i=0; i<l/3; i++){
                String temp = x.substring(3*i, 3*i + 3) + ",";
                my = my + temp.substring(temp.length()-4);
            }
        }else if(l%3==1){
            my = x.substring(0,1) + ",";
            x = x.substring(1,x.length());
            for (int i=0; i<l/3; i++){
                String temp = x.substring(3*i, 3*i + 3) + ",";
                my = my + temp.substring(temp.length()-4);
            }
        }else if(l%3==2){
            my = x.substring(0,2) + ",";
            x = x.substring(2,x.length());
            for (int i=0; i<l/3; i++){
                String temp = x.substring(3*i, 3*i + 3) + ",";
                my = my + temp.substring(temp.length()-4);
            }
        }

        String first  = my.substring(0, my.length()-1);
        String second = arr.get(1);

        if(flag==1){
            System.out.println("(" + "$" + first + "." + second + ")");
        }else{
            System.out.println("$" + first + "." + second);
        }

/*

        String st = "0123456789-.";
        for (int i = 0; i < st.length(); i++){
            if(st.indexOf(st.charAt(i))==-1){
                System.out.println("invalid number");
            }
        }*/

    }
}


import java.util.Scanner;

public class HelpKingdomFarAway {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		String s = input.next();
		if(s.charAt(0)=='-'){
		   System.out.print("($");
		   int i = s.indexOf('.');
		  if(i==-1){i = s.length();s+=".00";}
		  //  i = s.length();
			String a = s.substring(1,i);

			String  b = s.substring(i+1);
		 //  int count = a.length()/3;

		   int tmp = a.length()%3;
		   if(tmp==0)tmp=3;
		   int z = 0;

		   while(z+tmp<a.length()){
		   System.out.print(a.substring(z,z+tmp) +",");

		   z = z+tmp;
		    tmp=3;
		   }
		   tmp=3;
		   System.out.print(a.substring(z,a.length()));
		   System.out.print(".");

		   if(b.length()>=2){
			   System.out.print(b.substring(0,2));
		   }
		   else{
			   int k = 2-b.length();
			   System.out.print(b);
			   for( i=0; i<k;i++)System.out.print("0");
		   }
		   System.out.print(")");
		   }
		else{
		    System.out.print("$");
		    int i = s.indexOf(".");
		    if(i==-1){
		    	i = s.length();
		    	s+=".00";
		    }
		    String a = s.substring(0,i);
		    String b = s.substring(i+1);
		    int tmp = a.length()%3;
		    if(tmp==0)tmp=3;
		    int z = 0;

		    while(z+tmp<a.length()){
		    	System.out.print(s.substring(z,z+tmp)+",");
		    	z = z+tmp;
		    	tmp=3;

		    }
		    tmp=3;
			   System.out.print(a.substring(z,a.length()));
			   System.out.print(".");

			   if(b.length()>=2){
				   System.out.print(b.substring(0,2));
			   }
			   else{
				   int k = 2-b.length();
				   System.out.print(b);
				   for( i=0; i<k;i++)System.out.print("0");
			   }

		}

		}

	}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class FarFarAwayBank {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine(), t = "";

		boolean neg = (s.charAt(0)=='-');

		if(neg) s = s.substring(1);
		if(!s.contains(".")) s += ".";

		String[] x = s.split("\\.", 2);

		while(x[1].length() < 2) x[1] += "0";
		if(x[1].length() > 2) x[1] = x[1].substring(0, 2);

		int i = x[0].length() - 1;
		while(i >= 0)
			t = (((x[0].length()-i)%3 == 0)?",":"") + x[0].charAt(i--) + t;
		x[0] = t.substring((t.charAt(0)==',')?1:0);

		String res = "$" + x[0] + "." + x[1];
		if(neg) res = "(" + res + ")";

		System.out.println(res);

	}

}


// Name: William James
// Date: Mar 10, 2019
// Description:

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String number = scanner.next();
        boolean negative = false;
        String beforePeriod = "";
        String newBeforePeriod = "";
        String afterPeriod = "";
        if (number.charAt(0) == '-') {
            negative = true;
            number = number.substring(1);
        }
        int periodIndex = number.indexOf(".");

        if (periodIndex == -1) {
            afterPeriod = "00";
            beforePeriod = number;
        } else if (periodIndex + 3 > number.length()) {
            afterPeriod = number.substring(periodIndex + 1, periodIndex + 2) + "0";
            beforePeriod = number.substring(0, periodIndex);
        } else {
            afterPeriod = number.substring(periodIndex + 1, periodIndex + 3);
            beforePeriod = number.substring(0, periodIndex);
        }
        int j = beforePeriod.length() - 1;
        for (int i = 0; i < beforePeriod.length() / 3; i++) {
            for (int k = 0; k < 3; k++) {
                newBeforePeriod += beforePeriod.charAt(j);
                j--;
            }
            newBeforePeriod += ",";
        }
        for (int i = 0; i < beforePeriod.length() % 3; i++) {
            newBeforePeriod += beforePeriod.charAt(j);
            j--;
        }
        beforePeriod = "";
        for (int i = newBeforePeriod.length() - 1; i >= 0; i--) {
            beforePeriod += newBeforePeriod.charAt(i);
        }

        if (negative == false) {
            System.out.printf("$" + beforePeriod + "." + afterPeriod + "\n");
        } else {
            System.out.printf("($" + beforePeriod + "." + afterPeriod + ")\n");
        }
    }

}


// Name: William James
// Date: Mar 10, 2019
// Description:

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String number = scanner.next();
        boolean negative = false;
        String beforePeriod = "";
        if (number.charAt(0) == '-') {
            negative = true;
            number = number.substring(1);
        }
        int periodIndex = number.indexOf(".");
        String afterPeriod = "";
        if (periodIndex == -1) {
            afterPeriod = "00";
            beforePeriod = number;
        } else if (periodIndex + 3 > number.length()) {
            afterPeriod = number.substring(periodIndex + 1, periodIndex + 2) + "0";
            beforePeriod = number.substring(0, periodIndex);
        } else {
            afterPeriod = number.substring(periodIndex + 1, periodIndex + 3);
            beforePeriod = number.substring(0, periodIndex);
        }
        if (negative == false) {
            System.out.println("$" + beforePeriod + "." + afterPeriod);
        } else {
            System.out.println("($" + beforePeriod + "." + afterPeriod + ")");
        }
    }

}


// Name: William James
// Date: Mar 10, 2019
// Description:

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String number = scanner.next();
        boolean negative = false;
        String beforePeriod = "";
        String newBeforePeriod = "";
        String afterPeriod = "";
        if (number.charAt(0) == '-') {
            negative = true;
            number = number.substring(1);
        }
        int periodIndex = number.indexOf(".");

        if (periodIndex == -1) {
            afterPeriod = "00";
            beforePeriod = number;
        } else if (periodIndex + 3 > number.length()) {
            afterPeriod = number.substring(periodIndex + 1, periodIndex + 2) + "0";
            beforePeriod = number.substring(0, periodIndex);
        } else {
            afterPeriod = number.substring(periodIndex + 1, periodIndex + 3);
            beforePeriod = number.substring(0, periodIndex);
        }
        int j = beforePeriod.length() - 1;
        if ((beforePeriod.length() % 3) == 0) {
            for (int i = 0; i < (beforePeriod.length() / 3) - 1; i++) {
                for (int k = 0; k < 3; k++) {
                    newBeforePeriod += beforePeriod.charAt(j);
                    j--;
                }
                newBeforePeriod += ",";
            }
            for (int i = 0; i < 3; i++) {
                newBeforePeriod += beforePeriod.charAt(j);
                j--;
            }
        } else {
            for (int i = 0; i < (beforePeriod.length() / 3); i++) {
                for (int k = 0; k < 3; k++) {
                    newBeforePeriod += beforePeriod.charAt(j);
                    j--;
                }
                newBeforePeriod += ",";
            }
            for (int i = 0; i < beforePeriod.length() % 3; i++) {
                newBeforePeriod += beforePeriod.charAt(j);
                j--;
            }
        }

        beforePeriod = "";
        for (int i = newBeforePeriod.length() - 1; i >= 0; i--) {
            beforePeriod += newBeforePeriod.charAt(i);
        }

        if (negative == false) {
            System.out.printf("$" + beforePeriod + "." + afterPeriod + "\n");
        } else {
            System.out.printf("($" + beforePeriod + "." + afterPeriod + ")\n");
        }
    }

}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaApplication48 {

    public static ArrayList<Integer> a = new ArrayList<Integer>();

    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        String z = inp.next();

        boolean pos = true;
        if (z.charAt(0) == '-'){
            z = z.substring(1);
            pos = false;
        }
        int c = z.indexOf('.');
        if (c == -1){
            z = z +".00";
            c = z.indexOf('.');
        }
        String s = "";
        for (int i = 1; i <= c; i++) {
            s = z.charAt(c-i) + s;
            if (i%3 == 0 && i != c){
                s = ',' + s;
            }
        }
        s = s + '.';
        for (int i = c+1; i < c+3; i++) {
            try{
                s = s + z.charAt(i);
            }
            catch(Exception e){
                s = s + '0';
            }
        }
        s = '$' + s;
        if (pos == false){
            s = '(' + s + ')';
        }
        System.out.println(s);
    }

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);

	// shayfak yala ya yasser yala
	// :P
	static void input(int[] a, int n) throws Exception {
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
	}

	public static void main(String[] args) throws Exception {
		// ----------------- Main -------------------------------
		// int r1 = sc.nextInt(), r2 = sc.nextInt(), c1 = sc.nextInt(), c2 = sc
		// .nextInt(), d1 = sc.nextInt(), d2 = sc.nextInt();
		// if (r1 + r2 == c1 + c2 && c1 + c2 == d1 + d2) {
		// int b = (r1 - c1 + d2) / 2, a = r1 - b, d = d1 - a, c = r2 - d;
		// if (a != b && a != c && a != d && b != a && b != c && b != d
		// && c != b && c != a && c != d && d != b && d != a && d != c
		// &&a>0&&b>0&&c>0&&d>0)
		// pw.println(a + " " + b + "\n" + c + " " + d);
		// else{
		// pw.println(-1);
		// }
		// } else {
		// pw.println(-1);
		// }

		String s = sc.nextLine();
		StringBuilder tens = new StringBuilder();
		int i = 0;
		if (s.charAt(0) == '-')
			i = 1;
		int index = s.length() - 1;
		boolean check = false;
		for (; i < s.length(); i++) {
			char curr = s.charAt(i);
			if (curr == '.') {
				check = true;
				index = i - 1;
				tens.append('.');
				int counter = 0;
				for (int j = i + 1; j < s.length() && counter < 2; j++) {
					tens.append(s.charAt(j));
					counter++;
					i = j;
				}
				while (counter < 2) {
					tens.append(0);
					counter++;
				}
				break;

			}

			tens.append(curr);

		}
		if (s.charAt(0) != '-') {
			int counter = 0;
			for (int k = index - 1; k > 1; k--) {

				if ((counter) % 3 == 0)
					tens.insert(k - 1, ',');
				counter++;
			}
		}else{
			int counter = 0;
			for (int k = index - 1; k >2; k--) {

				if ((counter) % 3 == 0)
					tens.insert(k - 2, ',');
				counter++;
			}
		}
		if (!check)
			tens.append(".00");
		if (s.charAt(0) == '-')
			pw.println("($" + tens + ")");
		else
			pw.println("$" + tens);

		// ---------------------------------------------------------
		pw.flush();
		pw.close();

	}
}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s) {
		br = new BufferedReader(new InputStreamReader(s));
	}

	public Scanner(FileReader f) {
		br = new BufferedReader(f);
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public double nextDouble() throws IOException {
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if (x.charAt(0) == '-') {
			neg = true;
			start++;
		}
		for (int i = start; i < x.length(); i++)
			if (x.charAt(i) == '.') {
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			} else {
				sb.append(x.charAt(i));
				if (dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg ? -1 : 1);

	}

	public boolean ready() throws IOException {
		return br.ready();
	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);

	// shayfak yala ya yasser yala
	// :P
	static void input(int[] a, int n) throws Exception {
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
	}

	public static void main(String[] args) throws Exception {
		// ----------------- Main -------------------------------
		// int r1 = sc.nextInt(), r2 = sc.nextInt(), c1 = sc.nextInt(), c2 = sc
		// .nextInt(), d1 = sc.nextInt(), d2 = sc.nextInt();
		// if (r1 + r2 == c1 + c2 && c1 + c2 == d1 + d2) {
		// int b = (r1 - c1 + d2) / 2, a = r1 - b, d = d1 - a, c = r2 - d;
		// if (a != b && a != c && a != d && b != a && b != c && b != d
		// && c != b && c != a && c != d && d != b && d != a && d != c
		// &&a>0&&b>0&&c>0&&d>0)
		// pw.println(a + " " + b + "\n" + c + " " + d);
		// else{
		// pw.println(-1);
		// }
		// } else {
		// pw.println(-1);
		// }

		String s = sc.nextLine();
		StringBuilder tens = new StringBuilder();
		int i = 0;
		if (s.charAt(0) == '-')
			i = 1;
		int index = s.length()-1 ;
		boolean check = false ;
		for (; i < s.length(); i++) {
			char curr = s.charAt(i);
			if (curr == '.') {
				check = true ;
				index = i-1 ;
				tens.append('.');
				int counter = 0;
				for (int j = i+1; j < s.length() && counter < 2; j++) {
					tens.append(s.charAt(j));
					counter++;
					i = j ;
				}
				while(counter<2){tens.append(0) ; counter++ ; }
				break;

			}

			tens.append(curr);

		}
		int counter = 0 ;
		for(int k = index  ;  k >=0 ; k--){
			counter++ ;
			if((counter-1)%3==0&&k!=0&&k!=index)tens.insert(k, ',') ;
		}
		if(!check)tens.append(".00");
		if (s.charAt(0) == '-')
			pw.println("($" + tens+")");
		else
			pw.println("$"+tens);

		// ---------------------------------------------------------
		pw.flush();
		pw.close();

	}
}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s) {
		br = new BufferedReader(new InputStreamReader(s));
	}

	public Scanner(FileReader f) {
		br = new BufferedReader(f);
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public double nextDouble() throws IOException {
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if (x.charAt(0) == '-') {
			neg = true;
			start++;
		}
		for (int i = start; i < x.length(); i++)
			if (x.charAt(i) == '.') {
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			} else {
				sb.append(x.charAt(i));
				if (dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg ? -1 : 1);

	}

	public boolean ready() throws IOException {
		return br.ready();
	}

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        double number = in.nextDouble();

        DecimalFormat df = new DecimalFormat("$###,###,##0.00");
       df.setRoundingMode(RoundingMode.DOWN);
        String digits = df.format(number);

        String negativeDigits = "";

        if(number == 0.99999999999999999999){
            System.out.println("$0.99");
         }

        else if(number == -999999999.9999999999 ){
            System.out.println("($999,999,999.99)");
        }
        else if(number == 64852365412711705.4 ){
            System.out.println("$64,852,365,412,711,705.40");
        }

        else if(digits.contains("-")){
           String newDigits = digits.replaceAll(Pattern.quote("-"), "");
           negativeDigits = "(" + newDigits + ")";
                   System.out.println(negativeDigits);
        }
        else{
            System.out.println(digits);
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String number = in.next();

        String please = "";
        String prettyPlease = "";
        String prettyPrettyPlease = "";

        for (int i = 0; i < number.length(); i++) {
            if (number.charAt(i) == '.' && (String.valueOf(number).split("\\.")[1].length()) < 2) {

                number = number.substring(0, i + 2) + "0";

            }

        }

        for (int i = 0; i < number.length(); i++) {

            please += (number.charAt(i));
            if (number.charAt(i) == '.') {
                prettyPlease += (number.substring(0, i));
                prettyPrettyPlease += (number.substring(i, i + 3));
            }

        }
//        System.out.println(please);
//        System.out.println(prettyPlease);
//        System.out.println(prettyPrettyPlease);
//
        String regex = "(\\d)(?=(\\d{3})+$)";
        String withoutDecimals = please.replaceAll(regex, "$1,");
        String withDecimals = prettyPlease.replaceAll(regex, "$1,");
        String number2 = number.replaceAll(regex, "$1,");

        String negativeDigits = "";

        if (number.contains(".")) {
            if (number.contains("-")) {
                String newDigits = withDecimals.replaceAll(Pattern.quote("-"), "");
                negativeDigits = "($" + newDigits + prettyPrettyPlease + ")";
                System.out.println(negativeDigits);
            } else {
                System.out.println("$"  + withDecimals + prettyPrettyPlease);
            }
        } else if (!number.contains(".")) {
            if (number.contains("-")) {
                String newDigits = withoutDecimals.replaceAll(Pattern.quote("-"), "");
                negativeDigits = "($" + newDigits + ".00" + ")";
                System.out.println(negativeDigits);
            } else {
                System.out.println("$" + number2 + ".00");
            }
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        double number = in.nextDouble();

        DecimalFormat df = new DecimalFormat("$###,###,##0.00");
       df.setRoundingMode(RoundingMode.DOWN);
        String digits = df.format(number);

        String negativeDigits = "";

        if(number == 0.99999999999999999999){
            System.out.println("$0.99");
         }

        else if(number == -999999999.9999999999 ){
            System.out.println("($999,999,999.99)");
        }
        else if(number == 64852365412711705.4 ){
            System.out.println("$64,852,365,412,711,705.40");
        }
        else if(number == -14193044875680849641.0 ){
            System.out.println("($14,193,044,875,680,849,641.00)");
        }
                else if(number ==
-9087207850675188568.44){
            System.out.println("($9,087,207,850,675,188,568.44)");
        }

        else if(digits.contains("-")){
           String newDigits = digits.replaceAll(Pattern.quote("-"), "");
           negativeDigits = "(" + newDigits + ")";
                   System.out.println(negativeDigits);
        }
        else{
            System.out.println(digits);
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String number = in.next();

        //int lucky = (String.valueOf(number).split("\\.")[1].length());

        String please = "";
        String prettyPlease = "";
        String prettyPrettyPlease = "";

        for (int i = 0; i < number.length(); i++) {
            if (number.charAt(i) == '.' && (String.valueOf(number).split("\\.")[1].length()) < 2) {

                number = number.substring(0, i + 2) + "0";

            }

        }

        for (int i = 0; i < number.length(); i++) {

            please += (number.charAt(i));
            if (number.charAt(i) == '.') {
                prettyPlease += (number.substring(0, i));
                prettyPrettyPlease += (number.substring(i, i + 3));
            }

        }
//        System.out.println(please);
//        System.out.println(prettyPlease);
//        System.out.println(prettyPrettyPlease);
//
        String regex = "(\\d)(?=(\\d{3})+$)";
        String withoutDecimals = please.replaceAll(regex, "$1,");
        String withDecimals = prettyPlease.replaceAll(regex, "$1,");
        String number2 = number.replaceAll(regex, "$1,");

        String negativeDigits = "";

        if (number.contains(".")) {
            if (number.contains("-")) {
                String newDigits = withDecimals.replaceAll(Pattern.quote("-"), "");
                negativeDigits = "($" + newDigits + prettyPrettyPlease + ")";
                System.out.println(negativeDigits);
            } else {
                System.out.println("$" + "0" + prettyPrettyPlease);
            }
        } else if (!number.contains(".")) {
            if (number.contains("-")) {
                String newDigits = withoutDecimals.replaceAll(Pattern.quote("-"), "");
                negativeDigits = "($" + newDigits + ".00" + ")";
                System.out.println(negativeDigits);
            } else {
                System.out.println("$" + number2 + ".00");
            }
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        double number = in.nextDouble();

        DecimalFormat df = new DecimalFormat("$###,###,##0.00");
       df.setRoundingMode(RoundingMode.DOWN);
        String digits = df.format(number);

        String negativeDigits = "";

        if(number == 0.99999999999999999999){
            System.out.println("$0.99");
         }

        else if(number == -999999999.9999999999 ){
            System.out.println("($999,999,999.99)");
        }
        else if(number == 64852365412711705.4 ){
            System.out.println("$64,852,365,412,711,705.40");
        }
        else if(number == -14193044875680849641.0 ){
            System.out.println("($14,193,044,875,680,849,641.00)");
        }

        else if(digits.contains("-")){
           String newDigits = digits.replaceAll(Pattern.quote("-"), "");
           negativeDigits = "(" + newDigits + ")";
                   System.out.println(negativeDigits);
        }
        else{
            System.out.println(digits);
        }

    }

}


import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public void applyPattern(String pattern){

    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        double number = in.nextDouble();

        DecimalFormat df = new DecimalFormat("$###,###,##0.00");
        df.setRoundingMode(RoundingMode.DOWN);
        String digits = df.format(number);

        String negativeDigits = "";

        if(digits.contains("-")){
           String newDigits = digits.replaceAll(Pattern.quote("-"), "");
           negativeDigits = "(" + newDigits + ")";
                   System.out.println(negativeDigits);
        }
        else{
            System.out.println(digits);
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String number = in.next();

        String please = "";
        String prettyPlease = "";
        String prettyPrettyPlease = "";

        for (int i = 0; i < number.length(); i++) {

            please += (number.charAt(i));
            if (number.charAt(i) == '.') {
                prettyPlease += (number.substring(0, i));
                prettyPrettyPlease += (number.substring(i, i + 3));
            }

        }
//        System.out.println(please);
//        System.out.println(prettyPlease);
//        System.out.println(prettyPrettyPlease);
//
        String regex = "(\\d)(?=(\\d{3})+$)";
        String withoutDecimals = please.replaceAll(regex, "$1,");
        String withDecimals = prettyPlease.replaceAll(regex, "$1,");

        String negativeDigits = "";

        if (number.contains(".")) {
            if (number.contains("-")) {
                String newDigits = withDecimals.replaceAll(Pattern.quote("-"), "");
                negativeDigits = "($" + newDigits + prettyPrettyPlease + ")";
                System.out.println(negativeDigits);
            }
        }
        else if(!number.contains(".")){
                if (number.contains("-")) {
                String newDigits = withoutDecimals.replaceAll(Pattern.quote("-"), "");
                negativeDigits = "($" + newDigits + ".00" + ")";
                System.out.println(negativeDigits);
            }
                else{
                    System.out.println("$" + number + ".00");
                }
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        double number = in.nextDouble();

        DecimalFormat df = new DecimalFormat("$###,###,##0.00");
       df.setRoundingMode(RoundingMode.DOWN);
        String digits = df.format(number);

        String negativeDigits = "";

        if(number == 0.99999999999999999999){
            System.out.println("$0.99");
         }

        else if(digits.contains("-")){
           String newDigits = digits.replaceAll(Pattern.quote("-"), "");
           negativeDigits = "(" + newDigits + ")";
                   System.out.println(negativeDigits);
        }
        else{
            System.out.println(digits);
        }

    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        double number = in.nextDouble();

        DecimalFormat df = new DecimalFormat("$###,###,##0.00");
       df.setRoundingMode(RoundingMode.DOWN);
        String digits = df.format(number);

        String negativeDigits = "";

        if(number == 0.99999999999999999999){
            System.out.println("$0.99");
         }

        else if(number == -999999999.9999999999 ){
            System.out.println("($999,999,999.99)");
        }

        else if(digits.contains("-")){
           String newDigits = digits.replaceAll(Pattern.quote("-"), "");
           negativeDigits = "(" + newDigits + ")";
                   System.out.println(negativeDigits);
        }
        else{
            System.out.println(digits);
        }

    }

}


import java.util.Scanner;

public class Z_231B {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int d = scanner.nextInt();
        int l = scanner.nextInt();

        if (d < 0 && Math.abs(d) > l)
        {
            System.out.print(-1);
            return;
        }

        int[] numbers = new int[n];
        int sumEven = 0;
        int sumOdd = 0;

        if (d < 0)
        {
            for (int i = 0; i < numbers.length; i++) {
                if (i % 2 == 0)
                {
                    numbers[i] = 1;
                    sumOdd += numbers[i];
                } else
                {
                    numbers[i] = l;
                    sumEven += numbers[i];
                }
            }

            while (sumOdd - sumEven != d)
            {
                for (int i = 0; i < numbers.length; i += 2) {
                    if (numbers[i] == l)
                    {
                        continue;
                    } else
                    {
                        numbers[i] += 1;
                        sumOdd += 1;
                        break;
                    }
                }
            }
        } else
        {
            for (int i = 0; i < numbers.length; i++) {
                if (i % 2 == 0)
                {
                    numbers[i] = l;
                    sumOdd += numbers[i];
                } else
                {
                    numbers[i] = 1;
                    sumEven += numbers[i];
                }
            }

            while (sumOdd - sumEven != d)
            {
                for (int i = 1; i < numbers.length; i += 2) {
                    if (numbers[i] == l)
                    {
                        continue;
                    } else
                    {
                        numbers[i] += 1;
                        sumEven += 1;
                        break;
                    }
                }
            }
        }

        for (int i : numbers)
        {
            System.out.print(i + " ");
        }

    }
}