Index: trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 8249)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 8250)
@@ -397,5 +397,5 @@
                 .addKeyword("child <i>expr</i>", "child ", tr("all children of objects matching the expression"), "child building")
                 .addKeyword("parent <i>expr</i>", "parent ", tr("all parents of objects matching the expression"), "parent bus_stop")
-                .addKeyword("nth:<i>7</i>", "nth: ", tr("n-th member of relation and/or n-th node of way"), "nth:5 (child type:relation)")
+                .addKeyword("nth:<i>7</i>", "nth: ", tr("n-th member of relation and/or n-th node of way"), "nth:5 (child type:relation)", "nth:-1")
                 .addKeyword("nth%:<i>7</i>", "nth%: ", tr("every n-th member of relation and/or every n-th node of way"), "nth%:100 (child waterway)")
                 , GBC.eol());
Index: trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 8249)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 8250)
@@ -846,7 +846,4 @@
 
         private Nth(int nth, boolean modulo) throws ParseError {
-            if (nth <= 0) {
-                throw new ParseError(tr("Positive integer expected"));
-            }
             this.nth = nth;
             this.modulo = modulo;
@@ -856,19 +853,28 @@
         public boolean match(OsmPrimitive osm) {
             for (OsmPrimitive p : osm.getReferrers()) {
-                Integer idx = null;
+                final int idx;
+                final int maxIndex;
                 if (p instanceof Way) {
                     Way w = (Way) p;
                     idx = w.getNodes().indexOf(osm);
+                    maxIndex = w.getNodesCount();
                 } else if (p instanceof Relation) {
                     Relation r = (Relation) p;
                     idx = r.getMemberPrimitivesList().indexOf(osm);
-                }
-                if (idx != null) {
-                    if (idx.intValue() == nth || (modulo && idx.intValue() % nth == 0)) {
-                        return true;
-                    }
-                }
+                    maxIndex = r.getMembersCount();
+                } else {
+                    continue;
+                }
+                if (nth < 0 && idx - maxIndex == nth) {
+                    return true;
+                } else if (idx == nth || (modulo && idx % nth == 0))
+                    return true;
             }
             return false;
+        }
+
+        @Override
+        public String toString() {
+            return "Nth{nth=" + nth + ", modulo=" + modulo + '}';
         }
     }
Index: trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 8249)
+++ trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 8250)
@@ -1,10 +1,14 @@
 package org.openstreetmap.josm.actions.search;
 
+import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Way;
 
 public class SearchCompilerTest {
@@ -63,3 +67,33 @@
 
     }
+
+    @Test
+    public void testNth() throws Exception {
+        final DataSet dataSet = new DataSet();
+        final Way way = new Way();
+        final Node node0 = new Node(new LatLon(1, 1));
+        final Node node1 = new Node(new LatLon(2, 2));
+        final Node node2 = new Node(new LatLon(3, 3));
+        dataSet.addPrimitive(way);
+        dataSet.addPrimitive(node0);
+        dataSet.addPrimitive(node1);
+        dataSet.addPrimitive(node2);
+        way.addNode(node0);
+        way.addNode(node1);
+        way.addNode(node2);
+        Assert.assertFalse(SearchCompiler.compile("nth:2", false, false).match(node1));
+        Assert.assertTrue(SearchCompiler.compile("nth:1", false, false).match(node1));
+        Assert.assertFalse(SearchCompiler.compile("nth:0", false, false).match(node1));
+        Assert.assertTrue(SearchCompiler.compile("nth:0", false, false).match(node0));
+        Assert.assertTrue(SearchCompiler.compile("nth:2", false, false).match(node2));
+        Assert.assertTrue(SearchCompiler.compile("nth:-1", false, false).match(node2));
+        Assert.assertTrue(SearchCompiler.compile("nth:-2", false, false).match(node1));
+        Assert.assertTrue(SearchCompiler.compile("nth:-3", false, false).match(node0));
+    }
+
+    @Test
+    public void testNthParseNegative() throws Exception {
+        Assert.assertThat(SearchCompiler.compile("nth:-1", false, false).toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}"));
+
+    }
 }
